loubnabnl HF staff commited on
Commit
215da67
1 Parent(s): af020c6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ ---
5
+
6
+ # FineWeb-Edu classifier
7
+
8
+ ## Model summary
9
+ This is a classifier for judging the educational value of web pages. It was developed to filter and curate educational content from web datasets and was trained on annotation generated by [LLama3-70B-instruct](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct) for web samples from [FineWeb](https://huggingface.co/datasets/HuggingFaceFW/fineweb) dataset.
10
+
11
+ This is the classifier we used to build [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) dataset.
12
+ ### How to use in transformers
13
+ To load the FineWeb-Edu classifier, use the following code:
14
+
15
+ ```python
16
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
17
+
18
+ tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/fineweb-edu-classifier")
19
+ model = AutoModelForSequenceClassification.from_pretrained("HuggingFaceTB/fineweb-edu-classifier")
20
+
21
+ inputs = tokenizer("Your text here", return_tensors="pt", padding="longest", truncation=True)
22
+ inputs = tokenizer(texts, return_tensors="pt", padding="longest", truncation=True).
23
+ outputs = model(**inputs)
24
+ logits = outputs.logits.squeeze(-1).float().numpy()
25
+ score = logits.item()
26
+ record = {
27
+ "text": text,
28
+ "score": score,
29
+ "int_score": int(round(max(0, min(score, 5))))
30
+ }
31
+
32
+ print(record)
33
+ ```
34
+
35
+ ## Training
36
+ The classifier was trained on 450,000 pairs of web samples and their scores from 0 to 5, generated by Llama3. The samples were annotated based on their educational quality with 0 being not educational and 5 being highly educational.
37
+
38
+ Below is the prompt used for LLama3 annotations:
39
+ <div style="text-align: center; margin: 20px 0;">
40
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/fjZQ4izIj1rx1xQnBTKKr.png" alt="Prompt for LLM annotation" style="width: 90%; max-width: 800px; height: auto;">
41
+ </div>
42
+
43
+ We added a classification head with a single regression output to [Snowflake-arctic-embed](https://huggingface.co/Snowflake/snowflake-arctic-embed-m) and trained the model for 20 epochs with a learning rate of 3e-4. During training, the embedding and encoder layers were frozen to focus on the classification head. The model achieved an F1 score of 82% when converted to a binary classifier using a score threshold of 3.
44
+
45
+ **Training Details:**
46
+
47
+ - Model: Snowflake-arctic-embed with a classification head
48
+ - Dataset: 450,000 samples from Llama3 annotations
49
+ - Epochs: 20
50
+ - Learning Rate: 3e-4
51
+ - Evaluation Metric: F1 score
52
+ - Final F1 Score: 82%
53
+
54
+
55
+ ## Limitations
56
+ While the FineWeb-Edu classifier performs well in distinguishing high-quality educational content for FineWeb dataset, there are some limitations:
57
+
58
+ - Scope: The model's performance might chnage for other datasets, in particular for out of distribution samples. It is also focused on educational content relevant to primary and grade school levels and may not perform as well on content intended for higher education or specialized domains.
59
+ - Bias: The model's performance is dependent on the quality and representativeness of the training data and the LLM used for the annotation. Biases in both can affect the classifier's judgments.
60
+ - Context: The classifier evaluates individual web pages or extracts without considering broader context, which might impact its effectiveness in certain scenarios.
61
+
62
+ The training and inference code is available on GitHub (to add).