Dive into Deep Learning · §20.2
Quality Filtering
heuristic rules · perplexity · classifiers on model labels · label noise · thresholds · audits
The problem
FineWeb-Edu keeps 7.26% of FineWeb’s 265,662,695 documents of one crawl.
| page, from FineWeb’s output | rules | our classifier |
|---|---|---|
| “I NEED REVENGE DEATH SPELL … Call/WhatsApp ‹phone›”, 1,500+ characters | keep | lowest score among such pages |
| a company’s guide to hiring software engineers, after a sales pitch | keep | remove |
Before tuning a threshold: what does the filter mean by quality, and whose pages does it remove?
Goals
Running example: our 3,288 crawl documents (c0) and 20,000 documents of FineWeb’s output for the same crawl (the audit stream).
Where this fits
| step | section |
|---|---|
| get text | Document Extraction from Web Crawls |
| choose text | Quality Filtering |
| Deduplication and Decontamination | |
| mix text | Data Mixtures |
| Synthetic and Rephrased Data | |
| cut text | Tokenizers at Scale |
Heuristic rules
| family | catches | codes |
|---|---|---|
| Gopher repetition | repeated lines, paragraphs, n-grams | 3 |
| Gopher quality | 50 to 100,000 words; mean length 3 to 10; 80% of words with a letter; 2 of 8 stop words (the, of, with, …) | 7 |
| C4 | fewer than 5 sentences, “lorem ipsum”, { |
1 |
| FineWeb | lines without terminal punctuation, short lines, duplicated characters, line breaks per word | 4 |
A document is charged to the first rule that fires. Thresholds: datatrove 0.10.1, the code that built FineWeb.
The rules at work
| corpus | in | removed |
|---|---|---|
| c0, our crawl documents | 3,288 | 2,256 (69%) |
| audit stream, FineWeb’s output | 20,000 | 317 (1.6%) |
On the stream, FineWeb’s own four rules never fire.
Other languages
| FineWeb-2, 500 pages each | removed | first rule |
|---|---|---|
| German | 96% | stop words |
| Swahili | 93% | stop words |
| Hindi | 100% | mean word length (our \w) |
| Chinese, Thai | 100% | alphabetic words |
| Japanese | 100% | word count |
\w skips Devanagari vowel signs and words shatter; datatrove’s tokenizer keeps them. An artifact of our code.Every page had passed FineWeb-2’s rules for its language.
Check
The rule asks for 2 of the, be, to, of, and, that, have, with. With it, German loses 96%.
Answer. Without it German loses 28%, Swahili 16% instead of 93%. Chinese, Japanese, Thai and Hindi still lose 100%: their losses come from the word rules (for Hindi, from our word pattern), not from English vocabulary.
Perplexity
Mean NLL per token, first 512 tokens, Qwen3-0.6B-Base, 3,000 stream pages: median 2.9 nats.
| lowest NLL | highest NLL |
|---|---|
| “Please be mindful of our community standards” | “As have a peek at these guys you can see regarding the …” |
| “In today’s digital age, a strong online presence is crucial …” | spun text about pokies, loans, Discord |
| “Greetings, readers! I am excited to delve into …” | a garden-blog comment, a railway photo site |
Low perplexity means resemblance to the model’s training text, not quality.
The recipe
| corpus | labeller | small model | rule |
|---|---|---|---|
| FineWeb-Edu | Llama-3-70B, 450k pages | frozen 109M encoder + regression | rounded score ≥ 3 |
| DCLM | instruction data and explanations vs web | fastText | top 10% |
| Nemotron-CC | several classifiers | ensemble | quality buckets |
Labelling
Answer prefix Educational score:; one forward pass:
p(d) \;+\; p(\textrm{space})\,p(d \mid \textrm{space}), \qquad d = 0, \ldots, 5
Batching changes the arithmetic, and near ties flip. One request at a time: identical bits on any server.
Two labellers
| share of 22,000 pages | score ≥ 1 | ≥ 2 | ≥ 3 | ≥ 4 |
|---|---|---|---|---|
| Llama-3-70B (2024) | 0.88 | 0.31 | 0.091 | 0.018 |
| Qwen3.8-27B | 0.82 | 0.064 | 0.014 | 0.0001 |
Agreement with one labeller cannot show which labels are better; training runs decide.
Classifiers
2,000 test rows, 36 positives (Qwen ≥ 3); t^* from 2,000 validation rows.
| classifier | trained parameters | F1 [95% interval] | AUC |
|---|---|---|---|
| regression head, frozen 0.6B embedder | 1,025 | 0.44 [0.32, 0.55] | 0.98 |
| logistic head, same embedder | 1,025 | 0.56 [0.41, 0.68] | 0.98 |
| hashed bag (fastText), CPU | 67M | 0.26 [0.17, 0.34] | 0.90 |
| released, trained on Llama | head only | 0.47 [0.35, 0.57] | 0.98 |
Paired: regression head − released F1 = −0.02 [−0.14, +0.09].
Check
The label is “score ≥ 3”; the head fits the score by squared error.
Answer. A linear head on a frozen vector cannot tell every page apart; under squared error it predicts the mean score of the pages it confuses. Only 1.4% of labels reach 3, so such a group hardly ever has a mean near 3: the predictions bunch between 0 and 2. A cut at 2.5 keeps nothing.
An identity
\pi: share of positive labels; TPR: recall; \rho: share of documents kept.
\textrm{precision} = \frac{\pi\,\textrm{TPR}}{\rho} \quad\Rightarrow\quad \textrm{F1} = \frac{2PR}{P+R} = \frac{2\pi\,\textrm{TPR}}{\pi + \rho}
Label noise
If labels flip the true label y^* with probability \eta either way, a perfect classifier of y^* scores
P = 1 - \eta, \qquad R = \frac{\pi^*(1-\eta)}{\pi^*(1-\eta) + (1-\pi^*)\eta}
The threshold
Regression head, stream shares and test precision and recall (Qwen ≥ 3):
| cut | documents | tokens | precision | recall |
|---|---|---|---|---|
| 1.5 | 5.1% | 8.0% | 0.27 | 0.92 |
| t^* = 1.61 | 2.9% | 4.8% | 0.33 | 0.67 |
| 2.0 | 0.3% | 0.5% | 0.64 | 0.19 |
| 2.5, 3.0 | 0 | 0 | — | 0 |
The audit
A filter keyed on a classifier’s score is a covariate shift toward what the classifier prefers.
Audit results
| group | arm | removal − reference | 95% interval |
|---|---|---|---|
| .au vs .com | classifier | +1.9 points | [+0.9, +2.7] |
| shop vs other | classifier | +2.6 points | [+1.9, +3.1] |
| news vs other | rules | −1.4 points | [−1.7, −0.9] |
| .uk, .ca, .in, .nz, .za | classifier | intervals include 0 |
The classifier removes 97.2% of the stream: it keeps about 3% of .com pages and about 1% of .au pages (6 of 544), so the third is rough.
Check
A filter removes 97.0% of group A and 98.9% of group B.
Answer. No. The corpus receives what is kept: 3.0% of A and 1.1% of B, so B enters at about a third of A’s rate. When a filter keeps little, compare retention, not removal.
Reading removals
Judge: Qwen3.8-27B, reasoning on and uncapped, rubric “would a reader want this page in a general-purpose corpus?”
| 100 removed pages each | judged “drop” | 95% interval |
|---|---|---|
| classifier only, score within 0.3 of t^* | 0.11 | [0.06, 0.19] |
| rules | 0.70 | [0.60, 0.78] |
The classifier follows its rubric; the gap is between two definitions of quality.
In the pipeline
| stage | in | out | recorded |
|---|---|---|---|
heuristics |
3,288 | 1,032 | drops by first reason code |
edu_score |
1,032 | 1,032 | threshold 1.611, head SHA-256, embedder revision |
Recap
Next: the same page, or nearly the same, appears many times.