Maps to: UC Berkeley EE 290/194 Scalable AI, Fall 2026 Lecture 9, Pre-Training (Part 2): Data for Pre-Training — sources, filtering, repetition, synthetic data, mixtures, and curation at scale (slides
lecture9.pdf). Also drawn on: Spring 2026 Lecture 6 Part D (corpora as pipelines: C4, FineWeb, the curation pipeline, data KPIs) and Spring 2026 Lecture 7, Data Curation with NeMo Curator (NVIDIA guest lecture: throughput, streaming, autobalancing, the Nemotron-CC workflow, failure cases). The slides’ synthetic-data section is the subject of Lecture 11. Recommended reading (as cited on the slides): FineWeb (arXiv:2406.17557); DCLM (arXiv:2406.11794); Nemotron-CC (arXiv:2412.02595); Muennighoff et al., Scaling Data-Constrained Language Models (arXiv:2305.16264); Lee et al., Deduplicating Training Data Makes Language Models Better (arXiv:2107.06499); RegMix (arXiv:2407.01492) and DoReMi (arXiv:2305.10429); the NeMo Curator repository. Code:code/lecture10/containscrawl.py(a toy web crawl with the truth attached to every page),curate.py(extraction, language ID, rules, quality models, MinHash + LSH) and seven demos. Models are trained with Lecture 9’spretrain.pyon Atlas World, so every filter is judged both against the true labels and by the model it trains. Reading time: ~2.5 hours for the prose; ~8 minutes to run all demos.
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Size the data problem. Explain why current runs need 4–40T tokens, and why the largest filtered web datasets hold about one run’s worth.
- Design a curation pipeline. Order its stages from cheap to expensive: extraction → language ID → heuristic rules → dedup → quality models → mixing. Say what each stage removes, by mistake as well as on purpose.
- Judge a filter correctly. By what it keeps and, above all, by the model it trains (the ablation), not by how clean its output looks. Recognize that “quality” means whatever the filter compares against.
- Reason about quantity vs repetition. Use the data-constrained scaling results: about 4 epochs is nearly free, 16+ is not, and a repeated small subset hurts. Explain why heavy filtering stops paying as compute grows.
- Set and check a mixture. Know that facts are learned in proportion to frequency. Know how proxy models choose weights and why the choice must be verified at scale. Know why the best data goes at the end (annealing).
- Run curation as a system. Explain why throughput beats latency. Know how streaming, balancing and backpressure turn 13,000 s into 1,000 s, and why dedup is the hardest stage to scale.
0.2 Prerequisites and scope
- Prerequisites: Lecture 9 (Atlas World, bits per byte, the floor,
pretrain.py, ablations on small models). - Scope: sources and scale; text extraction; language ID; heuristic filters and their biases; learned quality classifiers (distillation from LLM judges, DCLM-style, perplexity); what filtering unsafe text does; repetition, epochs and data-constrained scaling; exact and fuzzy dedup; mixtures, proxy-model search and annealing; the cost and systems engineering of curation (NeMo Curator).
- Not in scope today: synthetic data (rephrasing, distillation, model collapse; Lecture 11); post-training data (Lecture 17). The slide on filtering hazardous knowledge from pre-training data is not covered here.
0.3 Section → code map
| Section | Idea | Code in code/lecture10/ |
|---|---|---|
| §1 | how much data, from where | 01_sources_and_scale.py |
| §2.1 | a toy crawl with true labels | crawl.py |
| §2.2–2.4 | extraction, language ID, heuristic rules, the ablation | curate.py, 02_filters_vs_truth.py |
| §2.5–2.6 | learned quality filters and their disagreement | 03_quality_classifiers.py |
| §3.1–3.3 | repetition, epochs, filtering vs compute | 05_repetition_and_epochs.py |
| §3.4–3.6 | exact and fuzzy dedup, decontamination, global vs per-snapshot | 04_dedup_minhash.py |
| §4 | facts by frequency, proxy-model mixture search, annealing | 06_mixtures.py |
| §5 | FLOPs of curation; streaming, balancing, backpressure; measured stage costs | 07_curation_at_scale.py |
0.4 Notation
- = parameters, = training tokens.
- Epoch (轮次) = training tokens / unique tokens.
- = natural share of source ; = its sampling weight.
- = Jaccard similarity; = LSH bands × rows.
- Junk = pages with no usable content (word salad, spam, repeated phrases, gibberish, fragments, template-only pages).
1. Sources and scale
1.1 Where data enters training
Pre-training uses web text, code, papers, books and math: 4–40T tokens today. Mid-training uses less data but higher quality (top web, math, code, synthetic): 50B–1T tokens. Post-training data (chat, reasoning, RL) comes in Part III.
Model reports describe the architecture in detail but say little about their data, because data is a competitive advantage. The Spring slides put it bluntly: for frontier models, data curation is often as important as architecture changes, and “bad data can waste compute faster than any systems inefficiency”.
1.2 Runs need far more data than Chinchilla said
Open models train on about 2.2× more tokens every year (slides). The reason is in the economics (demo 01):
- Chinchilla’s optimum, about 20 tokens per parameter, counts only training cost.
- A model is trained once and served for many tokens, so a smaller model trained on more data is often the better deal (Sardana et al.).
- Llama 3 8B trained at 94× Chinchilla-optimal (15T tokens), and Qwen3 0.6B at about 3,000× (36T).
- Each step past 20 tokens per parameter raises the amount of data a run needs.
The Spring guest lecture adds that MoE makes this worse. Data needs scale with total parameters while compute scales with active ones, and repetition hurts MoE models sooner (§3).
1.3 A filtered web dataset is about one training run
Dataset sizes have grown from BooksCorpus (0.8B words) and English Wikipedia (2.5B words, BERT’s diet) through C4 (156B tokens), The Pile (300B) and RefinedWeb (600B) to Dolma (3T), DCLM-Baseline (3.8T), Nemotron-CC (6.3T) and FineWeb (15T).
After filtering, the largest public web datasets hold about one run’s worth of tokens. The unfiltered pool, DCLM-Pool at 240T, is 16× larger. Villalobos et al. put the stock of public human text at about 300T tokens and project that runs use the whole stock around 2028. A 15T run on DCLM-Baseline alone would see each document 3.9 times. Section 3 asks whether that is a problem.
1.4 What a mixture is made of
Web text is 95.1% of OLMo 2’s pre-training mix (DCLM-Baseline, 3.71T of 3.90T tokens). The other sources are small but each is added on purpose:
| source | why add it |
|---|---|
| code (StarCoder, 83B) | programming; rare on web pages |
| math (OpenWebMath, Algebraic Stack; 12B each) | HTML extraction loses notation |
| papers (peS2o 59B, arXiv 21B) | mostly PDFs, so missing from HTML crawls |
| Wikipedia (3.7B) | clean, factual, broad |
Common Crawl (通用网页爬取) has released a snapshot of about 2B pages roughly once a month since 2013, and it is the source of almost all web text. It ships raw HTML (WARC files) and its own extracted text (WET files). The slide shows one document from each stage of the same pipeline:
- a raw C4 page that is a navigation menu and shopping cart;
- a FineWeb page of chatty prose (passed rules and dedup);
- a FineWeb-Edu page about deep-space communication (classifier score 3.9/5);
- a Wikipedia stub about frogs.
The slide asks: is the FineWeb sample good training data? Is the Wikipedia sample better than the FineWeb-Edu one? These questions have no context-free answer. That is why the field answers them with ablations.
Every curation choice is tested with an ablation (消融实验). Fix the model and the training recipe, change only the data (one filter, one threshold, one dedup setting), and compare benchmark scores. The runs are kept small to keep this cheap (FineWeb used 1.71B parameters and 28B tokens), so the benchmarks must give signal at that scale (Lecture 9 §5.5). This lecture’s demos do exactly this on Atlas World: the same model, the same token budget, a different version of the data.
2. Filtering: which documents to keep
2.1 The pipeline, and a crawl whose truth we know
raw crawl (WARC) → text extraction → language ID → heuristic filters → dedup → quality classifiers → decontaminate, mix
└──────── CPU, per document, cheap ────────┘ └ global ┘ └ model inference (CPU or GPU) ┘
The curation pipeline keeps 1–10% of the crawl. In DCLM (reported), 240T tokens go in and 3.8T come out. By documents:
- heuristic filters keep 19.9%;
- dedup leaves 13.7%;
- the quality classifier leaves 1.4%.
Keeping only English alone removes about half the documents. Stages are ordered from cheap to expensive, so the expensive models see the fewest documents.
To score every stage, crawl.py builds a toy crawl on top of Atlas World. Every page carries its site’s template lines (a link bar, a cookie notice, a footer) around its content, and its true kind is recorded:
| kind | what it is | truth |
|---|---|---|
| good | an Atlas World document, one sentence per line | real content |
| noisy | a good document with typos and filler (“lol”, ”!!”) | mediocre content |
| foreign | a good document in “language B” (a letter cipher) | real content, wrong language |
| shuffled | a good document with its words in random order | junk (word salad) |
| spam | keyword-stuffed shop text | junk |
| repeated | one phrase repeated dozens of times (“255 255 255 …”) | junk |
| gibberish | random characters (broken encodings) | junk |
| short | a 1–4-word fragment | junk |
| template | only boilerplate (login, contact) | junk |
On top come exact and near duplicates, with heavy-tailed cluster sizes. The demos’ crawl has 7,500 pages from 6,000 unique ones.
2.2 Text extraction and language ID
Extraction (正文抽取). A WET-style dump strips tags but keeps menus, cookie notices and footers. FineWeb and DCLM found that extracting text from WARC with trafilatura beats using WET (same model and crawl; only the extraction differs).
curate.extract is a readability-style extractor: it drops link bars and known boilerplate lines. On the toy crawl (demo 02):
- 23.3% of the words in the raw dump are site templates;
- extraction returns the true content of 95.5% of good pages exactly (the rest are re-posts whose edited line differs by design);
- training on the raw dump instead of extracted text costs +0.157 bits/byte on clean held-out text (1.011 vs 0.854), because the model spends capacity on menus.
Boilerplate is also extreme duplication, which shows up as memorization and loss spikes (Spring slides).
Language identification (语种识别, LID). curate.LangID is a character-trigram naive Bayes classifier trained on 300 documents per language. It detects 100% of foreign pages that contain words. It misses all foreign math pages, because digits look the same in every language. Real LID misfires the same way on code, math, short documents and transliterated text. Mixed-language pages need segment-level LID. Track the language proportions over time: a sudden drift usually indicates a pipeline regression.
2.3 Heuristic rules: sharp, cheap, and biased
The C4 rules, applied to one page on the slide:
- drop lines without terminal punctuation, and cookie lines;
- drop pages with fewer than 3 sentences;
- drop pages containing a word from a bad-words list, or a
{.
FineWeb ablated each C4 rule separately. Terminal punctuation helped most, but it removes about 30% of tokens, so FineWeb left it out. Gopher-style rules add fractions of symbols, mean word length, stop-word counts and repeated-line or n-gram statistics. Regexes find emails, phone numbers and IP addresses and mask them (Dolma).
Demo 02 applies six rules one at a time, on extracted text:
| rule | junk removed | good pages removed | worst-hit domain |
|---|---|---|---|
| min 3 lines | 64.5% | 15.6% | math 20.5% |
| terminal punctuation | 84.9% | 0.0% | — |
| bad-words list | 22.6% | 14.5% | story 20.2% |
| symbol ratio | 10.0% | 0.0% | — |
| repetition (≥ 10 back-to-back n-gram repeats) | 11.7% | 0.0% | — |
| stop words (≥ 2) | 86.9% | 22.0% | math 100% |
Three lessons:
- Every rule that catches a lot of junk also removes good text, unevenly.
- The stop-word rule deletes every math page and 41% of code, which have few or no stop words.
- The bad-words list removes 79.7% of benign market-topic pages and 0% of the other topics. “Cheap” is both a spam word and an ordinary word about markets. This is the mechanism behind the slide’s finding that C4’s word list disproportionately removed text about LGBTQ+ people and text in African American English (Dodge et al.). Blocklists are easy to implement and easy to miscalibrate.
The ablation decides (same model, same 512K-token budget; validation bits/byte on clean held-out text):
| training data | documents | story | wiki | math | code | all |
|---|---|---|---|---|---|---|
| raw dump (WET-style) | 7,500 | 0.924 | 1.083 | 1.675 | 1.127 | 1.011 |
| extracted | 7,500 | 0.813 | 0.902 | 1.421 | 0.813 | 0.854 |
| extracted + LID + 3 light rules | 4,297 | 0.793 | 0.822 | 1.372 | 0.780 | 0.819 |
| + all six rules | 2,386 | 0.872 | 0.864 | 5.087 | 0.789 | 1.022 |
“All six rules” produces the cleanest-looking data and the worst model. The stop-word rule removed all math, so the model never learned arithmetic (5.087 bits/byte on math, where the floor is 0.891). Rules also leave junk behind: 10.5% of the light-rule output, almost all shuffled word salad, which has the right words, punctuation and length. Catching it needs a model of what good text looks like.
2.4 How filters have defined “good” text
Each generation of filter defined quality by what it compares a page against:
| filter | quality means | example |
|---|---|---|
| GPT-2 WebText (2019) | people link to it | outbound Reddit links |
| CCNet, GPT-3 (2019–20) | it looks like Wikipedia and books | perplexity / classifier vs reference |
| FineWeb-Edu (2024) | an LLM rates it educational | distilled LLM judge |
| DCLM (2024) | it looks like instruction data | fastText: OH-2.5 + ELI5 vs random web |
| Nemotron-CC (2024) | an ensemble of classifiers rates it highly | ensemble + quality buckets |
Since CCNet and GPT-3, the comparison has been made by a learned classifier.
2.5 Learned quality filters
Distilling an LLM judge into a cheap classifier (FineWeb-Edu):
- sample 460K pages;
- Llama-3-70B scores each one for educational value (0–5);
- train a small classifier (110M parameters) on the scores;
- score all 15T tokens and keep score ≥ 3, leaving 1.3T tokens.
Threshold 3 scored best among 2, 3 and 4 against unfiltered FineWeb (reported).
A cheap classifier can beat asking an LLM. DCLM trained the same model on the same pool and changed only the filter. A fastText bigram classifier (positives: instruction data and ELI5 answers; negatives: random web pages; keep the top-scored 10%) scored 30.2 on CORE, beating:
- prompting an LLM to judge each document (AskLLM, 28.6);
- perplexity filtering (29.0);
- top-k logits (29.2);
- BGE embeddings (27.2);
- semantic dedup (27.1);
- rules only (27.5);
- PageRank top 20% (26.1).
The fastText classifier costs a fraction of AskLLM. Keeping the most-linked pages did worse than rules alone.
Perplexity filtering (困惑度过滤) keeps text that a reference LM finds likely. It removes gibberish and boilerplate. As the Spring slides warn, it also removes code, math and low-resource languages unless the reference model covers them. Nemotron-CC’s pipeline still uses it, as one stage among many.
Demo 03 runs these after the light rules (4,297 candidate pages), each keeping the top half:
| filter | junk kept | good story | good wiki | good math | good code | model (val bits/byte) |
|---|---|---|---|---|---|---|
| random half | 10.3% | 50% | 51% | 48% | 50% | 0.831 |
| judge on every page (AskLLM-style) | 0.0% | 50% | 93% | 94% | 91% | (not trained) |
| distilled judge classifier (800 labels) | 0.0% | 53% | 78% | 86% | 87% | 0.818 |
| DCLM-style (wiki reference vs crawl) | 2.1% | 81% | 97% | 0% | 0% | 1.664 |
| perplexity (bigram LM on wiki) | 0.0% | 95% | 99% | 0% | 0% | 1.573 |
| oracle (true quality) | 0.0% | 70% | 69% | 69% | 75% | 0.796 |
- The student is nearly as good as its teacher. The distilled classifier agrees with the truth on 82.2% of unseen pages, against 89.0% for the judge itself. Used to pick the top half, it is almost as clean (0.0% junk, 3.7% noisy, vs 0.0% and 2.9%). It costs one small forward pass per page instead of an LLM call.
- “Quality” is whatever the reference is. The DCLM-style classifier was trained against wiki-style reference text, and the perplexity filter scored against a wiki bigram model. Both keep no math or code, and the models they train score 9–10 bits/byte on math. Real DCLM positives (instruction data) do contain code and math; a reference set without a domain silently deletes it. A filter is judged by the model it trains.
2.6 Classifiers disagree about quality
The learned filters’ kept halves overlap with Jaccard 32–75%, and only 30.3% of the pages any of them keeps is kept by all three (demo 03). On real data, Nemotron-CC found that among high-quality documents in one snapshot, only 10% were chosen by both FineWeb-Edu and DCLM (35% by FineWeb-Edu only, 54% by DCLM only).
FineWeb-Edu’s notion of quality favours education, history and health, and disfavours business, entertainment, travel and recipes. Each classifier encodes its own notion of quality; combining them (Nemotron-CC’s ensemble) finds more good documents. Two operational rules from the Spring slides:
- Track the score distribution and the acceptance rate. Large shifts often mean an upstream extraction bug.
- Prefer soft weighting (downsampling) to hard drops when you can: it gives smoother distributions (§3.3).
2.7 What filtering unsafe text does
Pipelines drop unsafe pages with URL blocklists and toxicity classifiers. The slide’s evidence, from Safety Pretraining (Maini et al.) and Korbak et al., is that removal has a cost:
- Removal alone backfires. Training only on documents scored safe raised the attack success rate after benign fine-tuning, from 38.8% to 43.8%. The model never learned how to respond to unsafe content.
- Rewriting works better. Keeping that content, rewritten with context and paired with refusals, lowered the rate to 23.0%; adding harm tags brought it to 20.0%.
- Tagging helps generation. Tagging text
<|good|>/<|bad|>and generating after<|good|>cut toxicity about 10×.
The defensive lesson matches §2.3: removing data removes what the data teaches, including how to recognize and respond to bad content. Curation choices for safety are ablated like any other.
3. Quantity, repetition and deduplication
3.1 Up to ~4 epochs, repeated data is almost as good as new data
With runs catching up with the stock of text, repetition is unavoidable. Muennighoff et al. trained many models on repeated data:
- each repetition is worth less than the one before;
- up to about 4 epochs, repeating is almost as good as new data;
- past about 16 epochs the returns fall off quickly;
- at 40 epochs, repeating is worthless.
So 4 passes over DCLM-Baseline cost little, but much longer runs need more unique tokens. The Spring guest lecture adds that past about 2 epochs repetition is even more detrimental for MoE models.
Demo 05 Part A (measured) spends the same 614K training tokens on of the data, repeated times:
| epochs | 1 | 2 | 4 | 8 | 16 | 32 | 64 |
|---|---|---|---|---|---|---|---|
| val bits/byte | 0.769 | 0.771 | 0.774 | 0.794 | 0.939 | 1.994 | 2.449 |
| vs fresh data | — | +0.002 | +0.005 | +0.025 | +0.170 | +1.225 | +1.680 |
| train loss (nats/token) | 1.767 | 1.752 | 1.758 | 1.716 | 1.329 | 0.066 | 0.015 |
This is the same shape, in miniature. At 32 epochs the training loss is near zero while held-out quality collapses: the model has memorized its training set.
3.2 Repeating a small subset many times hurts
Hernandez et al. trained on 90% unique data plus 10% from a small subset repeated many times. Repeating 0.1% of the data 100 times made an 800M model perform like a 400M model. Demo 05 Part B does the same in miniature: 90% fresh data plus 83 copies of a 738-token subset costs +0.007 bits/byte. That is more than repeating the whole dataset 4 times (+0.005), even though only 10% of the tokens are repeats.
Why repetition matters in practice: the web is full of repeated text. In C4 (Lee et al.):
- most documents are unique, but some appear thousands of times;
- 4.6% of C4’s validation documents have a near duplicate in training (contamination);
- deduplication cut verbatim regurgitation of training text by 10×.
Duplicates cause three problems: repetition (a few documents repeated many times), contamination and memorization. Hence dedup (§3.4).
3.3 How much to filter depends on the budget
Soft filtering. Long runs keep more data and weight it by quality, instead of applying a hard threshold. Nemotron-CC uses an ensemble of classifiers to sort documents into quality buckets. It repeats the top buckets more and keeps some middle-quality data. It keeps 4× DCLM’s unique tokens at the same MMLU. An 8B model trained on 15T tokens (7.2T from Nemotron-CC) scored MMLU 70.3 vs Llama 3.1 8B’s 65.3 (reported).
With enough compute, filtering stops helping (Mohri, Duchi and Hashimoto, A Bitter Lesson for Data Filtering):
- At low compute, filtered data wins. There are enough unique good tokens, and bad tokens waste the budget.
- At high compute, the unfiltered pool wins. The filtered set has to be repeated many times, and each repeat is worth less.
- Where the crossover sits. For all of DCLM-Pool they project the unfiltered pool overtaking the RefinedWeb filter at about FLOPs. Frontier runs today are about , so filtering still pays, and pays less as budgets grow.
Demo 05 Part C reproduces the crossover in miniature: filtered = good pages only (81K tokens); unfiltered = good + noisy pages (170K tokens).
| steps | epochs (filtered) | epochs (unfiltered) | filtered | unfiltered |
|---|---|---|---|---|
| 100 | 1.3 | 0.6 | 1.115 | 1.403 |
| 400 | 5.1 | 2.4 | 0.788 | 0.811 |
| 1,600 | 20.2 | 9.6 | 0.979 | 0.784 |
Better data also moves the compute-optimal point toward larger models. For a budget , the optimal sizes grow as and . Chinchilla’s “20 tokens per parameter” comes from fitting on one dataset. DeepSeek LLM refit on three datasets of increasing quality and got larger for better data (0.450 → 0.524 → 0.578). So more of the budget should go to parameters. Scaling-law fits do not transfer across datasets, which matches Lecture 9’s ladder.
3.4 Exact and fuzzy deduplication
Exact dedup (精确去重) hashes each document (MD5 in Curator) and keeps one per hash. It misses pages that differ only by a date or an ad.
Fuzzy dedup (模糊去重) with MinHash + LSH works in four steps:
- Shingles. Each document becomes a set of word 5-grams (shingles, 词片).
- MinHash. For a random hash function , , the Jaccard similarity . So independent MinHashes form a signature whose agreement rate estimates .
- LSH banding. Split the signature into bands of rows. Two documents become a candidate pair if all values agree in any band:
- Clusters. The connected components of the candidate pairs (union-find, 并查集) are the duplicate clusters; keep one document per cluster.
and set the threshold and its sharpness. Demo 04 measures the curve on document pairs with controlled similarity:
| Jaccard | 0.5–0.6 | 0.6–0.7 | 0.7–0.8 | 0.8–0.9 | 0.9–1.0 |
|---|---|---|---|---|---|
| FineWeb 14 × 8 analytic / measured | 0.14 / 0.13 | 0.34 / 0.40 | 0.79 / 0.81 | 0.98 / 0.96 | 1.00 / 1.00 |
| RefinedWeb 450 × 20 analytic / measured | 0.01 / 0.00 | 0.08 / 0.07 | 0.77 / 0.69 | 1.00 / 1.00 | 1.00 / 1.00 |
at for 14 × 8 and for 450 × 20. RefinedWeb’s curve is much steeper, at 80× the hashing cost (9,000 vs 112 hashes per document).
Scored against the true clusters (7,500 pages; 2,265 true duplicates to remove, 468 of them near copies):
| method | precision | recall | near copies found |
|---|---|---|---|
| exact (MD5 of extracted text) | 100% | 86.3% | 51.3% |
| MinHash 14 × 8 on extracted text | 93.3% | 95.8% | 84.0% |
| MinHash 14 × 8 on the raw page | 93.2% | 89.4% | 66.7% |
| MinHash 20 × 5 on extracted text | 93.4% | 97.4% | 89.3% |
The 155 “mistakes” of MinHash on extracted text are all repeated-phrase pages of different lengths (“0 0 0 …”). Their shingle sets are identical: duplicates in content, just not in the crawl’s copy records. Run on raw pages, MinHash does worse. Template and date lines dilute the shingle sets of short pages, so recall drops, and it merges 34 pages whose only overlap is their site template. Dedup runs after extraction.
The clusters found are heavy-tailed: most pages are unique, and the largest cluster has 696 pages. Both kinds of dedup compare documents across the whole dataset, so neither can run one document at a time. This is what makes dedup the hardest stage to scale (§5).
3.5 Decontamination
Evaluation is part of the data pipeline (Spring slides). If training data contains your benchmarks or their near duplicates, scores are inflated. To guard against this:
- build a “do-not-train” set from the benchmarks;
- dedup against it at the n-gram level, not just the document level;
- track provenance so a source can be removed retroactively.
Demo 04 plants 12 benchmark documents in the training crawl, half of them edited. An 8-gram overlap check (≥ 50% of a page’s 8-grams in the benchmark) catches all 12, with 5 false alarms. Lecture 9 §5.5 noted the real case: Marin 32B found GSM8K in its cooldown data.
3.6 Global dedup can remove the wrong copies
FineWeb found that global dedup across 96 snapshots gained little over no dedup. In one old snapshot, the 90% of documents that global dedup removed trained a better model than the 10% it kept. The explanation: pages that are never re-crawled tend to be low quality. Global dedup keeps those and removes good pages that were crawled again. FineWeb therefore dedups each snapshot separately.
Demo 04 Part E simulates this: good pages are re-crawled with probability 0.6 per snapshot, noisy 0.3, junk 0.05, and global dedup keeps the newest copy. In the oldest snapshot:
| pages | good | junk | model trained on them (bits/byte) | |
|---|---|---|---|---|
| kept by global dedup | 799 | 1.0% | 77.8% | 1.465 |
| removed by global dedup | 1,189 | 69.6% | 12.6% | 0.852 |
The re-crawl probabilities are assumptions, but the mechanism is general: a dedup policy is also a sampling policy, and which copy it keeps matters.
4. Mixtures
4.1 Models learn facts in proportion to how often they appear
Kandpal et al. took each TriviaQA question and counted the pre-training documents that mention it. Accuracy rises with that count at every model size, from BLOOM 560M to 176B. Rare facts would need an absurdly large model. The mixture decides which facts are common, so it decides what the model knows.
Atlas World mentions its 100 countries with Zipf frequency. Demo 06 Part A trains a model for 800 steps on the natural mix and tests all 400 facts (rank the right answer first among the relation’s candidates; chance 5.1%):
| documents stating the fact | 0 | 1–2 | 3–5 | 6–15 | 16–50 | 51+ |
|---|---|---|---|---|---|---|
| facts | 25 | 91 | 147 | 87 | 36 | 14 |
| accuracy | 4.0% | 8.8% | 10.2% | 12.6% | 66.7% | 100% |
Only 50 of the 400 facts are stated more than 15 times; overall accuracy is 18.2%. Knowledge follows frequency.
4.2 Mixture weights oversample small, valuable sources
Each next document comes from source with probability instead of its natural share . GPT-3 cut Common Crawl and Books2, and boosted WebText2, Books1 and Wikipedia (demo 01):
- Wikipedia is 0.6% of the tokens available but got a 3% weight, about 3 epochs;
- Common Crawl got less than half an epoch.
A common rule, especially across languages (mT5, XLM-R), is temperature sampling: with , which flattens the mixture. With , GPT-3’s sources would give Wikipedia about 9 epochs. Upweighting repeats a small source, so its weight is capped at a few epochs: repetition is nearly free up to about 4 (§3.1).
4.3 Choosing mixture weights with small proxy models
The recipe:
- train many small models, each on a different mixture;
- fit a model of loss as a function of the weights;
- pick the mixture with the best predicted loss;
- train the large model on it.
RegMix fits a regression on 512 tiny models trained on random mixtures; its predicted ranking orders 64 mixtures correctly. DoReMi uses one 280M proxy; its weights gave an 8B model +6.5 points few-shot on the Pile. Both assume the best mixture for a small model stays best for a large one. Since the best filtering choice changes with compute (§3.3), the chosen mixture should be checked at scale.
Demo 06 Part B fits to 24 tiny proxies (width 32, 200 steps; mean error 0.019 bits/byte). Minimizing on the simplex gives in closed form. The proxies favour story and wiki and give math and code less weight than uniform. A plausible reason: proxies that small barely learn arithmetic or value tracking, so more of those domains does not help them. At 3× the width and 2.5× the steps:
| mixture | weights story/wiki/math/code | proxy prediction | large model (val bits/byte) |
|---|---|---|---|
| natural | 0.55 / 0.15 / 0.15 / 0.15 | 1.134 | 0.795 |
| uniform | 0.25 / 0.25 / 0.25 / 0.25 | 1.127 | 0.792 |
| proxy-chosen | 0.36 / 0.32 / 0.15 / 0.18 | 1.112 | 0.797 |
| best proxy run | 0.53 / 0.21 / 0.13 / 0.13 | 1.124 | 0.799 |
The four land within 0.007 bits/byte of each other. Three samples of the same natural mix span 0.010. The differences are inside the noise floor, and the proxies’ ranking did not carry over (Spearman −0.60).
This is not a refutation of RegMix: at 512 proxies and real data its rank predictions held. But it is exactly the failure the slides warn about: a proxy that cannot learn a domain cannot value it, and a verification run without a noise floor (Lecture 8) would have declared a winner.
4.4 Save the best data for the end
While the learning rate decays, switch to higher-quality data:
- the top quality buckets;
- math and code;
- instruction-style and synthetic text.
OLMo 2 7B trained on 3.9T tokens of mostly web text, then on 50B tokens of a curated mid-training mix (reported). An anneal continues a partly trained model on candidate data while the learning rate decays. Its effect shows up within tens of billions of tokens, far less than training from scratch, so anneals are how mid-training data is chosen. OLMo 2 ran 19 microanneals (130B tokens in total); adding math data lifted a 7B model’s GSM8K from 28.5 to 61. Llama 3’s final pre-training mix was 50% general, 25% math and reasoning, 17% code and 8% multilingual, chosen with small models and scaling laws.
Demo 06 Part C runs two otherwise identical 800-step WSD runs. In one, the final 160 steps (the decay) switch to a wiki- and math-heavy mix:
| run | story | wiki | math | code | all | fact accuracy |
|---|---|---|---|---|---|---|
| decay on the main mix | 0.761 | 0.706 | 1.305 | 0.730 | 0.765 | 18.2% |
| decay on the high-quality mix | 0.765 | 0.674 | 1.266 | 0.736 | 0.763 | 29.2% |
Twenty percent of the steps lift fact accuracy by 11 points and improve math, at a 0.004 cost on story text.
5. Curation at scale
5.1 Running an LLM over the whole crawl costs more than training
Training costs about FLOPs; inference about per token. Demo 05 of Lecture 9 checked the training side; demo 07 here computes the curation side:
| step | FLOPs | × training an 8B model on 15T |
|---|---|---|
| 70B judge labels 460K pages | 6.4e19 | 0.0001 |
| 110M classifier scores 15T tokens | 3.3e21 | 0.005 |
| 110M classifier scores 240T tokens | 5.3e22 | 0.07 |
| 12B model rephrases 1.8T tokens (output only) | 4.3e22 | 0.06 |
| 70B model scores all 240T tokens | 3.4e25 | 47 |
This is why the pipeline runs rules first, then a small classifier distilled from an LLM. As a check, FineWeb-Edu reports 6,000 H100-hours for 15T tokens, about 15% of H100 peak. Small-model inference over short documents is far from the roofline.
5.2 Throughput, not latency
Curation processes billions of documents, so total throughput matters far more than the latency of one document. The Curator lecture’s example: you have 2 GPUs, and a sample takes 2 s on one GPU or 1.5 s on two. Giving each sample both GPUs makes one sample faster, but 1,000 samples take 1,500 s instead of 1,000 s (demo 07 Part B).
The worked example (from the slides): 1,000 inputs and 1 GPU with 102 GB. The three stages are language ID (0.5B model, 1 GB, 2 s), tokenization (CPU, 1 s) and a 5B model (10 GB, 10 s). Demo 07 simulates it:
| plan | total time | model workers busy | GPU memory | max queue before the model |
|---|---|---|---|---|
| one input at a time through all stages | 13,000 s | 77% | 11 GB | 1 |
| streaming, 1 copy per stage, unbounded queues | 10,004 s | 100% | 11 GB | 800 |
| streaming, 1 copy per stage, queues capped at 8 | 10,004 s | 100% | 11 GB | 8 |
| streaming + balanced copies (2, 1, 10) | 1,013 s | 99% | 102 GB | 1 |
- Streaming (流式处理) lets an input move on as soon as a stage finishes it, so the stages overlap. Alone it is limited by the slowest stage.
- Backpressure (背压) pauses a fast stage when the queue to a slow stage is full. Without it, the queue in front of the model grew to 800 inputs: memory filled with work the slow stage had not reached.
- Balancing (负载均衡) gives each stage copies in proportion to its cost, so every stage runs at the same rate (1 input/s). It needs the memory to fit them: 2 × 1 GB + 10 × 10 GB = 102 GB.
The slide’s caveat: this assumes copies on the same GPU do not slow each other down, i.e. that one copy leaves most of the GPU’s compute idle. On real hardware, measure the rate per copy as you add copies.
5.3 NeMo Curator
NeMo Curator (v1.3) turns this into four abstractions:
- a Task (a
DocumentBatch: a table of documents, in practice a pandas DataFrame); - a Stage (takes and returns tasks, and declares its CPU/GPU resources);
- a Pipeline (a list of stages);
- an Executor (Cosmos-Xenna on Ray, Ray Actor Pool, or Ray Data), which runs the pipeline on a Ray cluster.
The executor measures each stage’s throughput and reassigns workers, so the balancing above happens without hand-tuning. Backpressure is built in, and GPU stages stay above 99% busy after warm-up (reported). Filters, classifiers and rephrasing handle one document at a time and stream this way. Deduplication cannot: it runs as a separate GPU workflow (MD5 grouping for exact; MinHash, LSH and a graph of duplicate relations for fuzzy) and is the hardest stage to scale.
Demo 07 Part D measures this lecture’s own stages per document on a laptop:
| stage | time per document |
|---|---|
| extraction | ~4 µs |
| rules | ~19 µs |
| classifier | ~24 µs |
| language ID | ~69 µs |
| MinHash signatures | ~70 µs |
A balanced deployment gives the slowest stages the most workers. The signatures stream; the bucketing and clustering do not.
The Nemotron-CC workflow in Curator:
- download and extract Common Crawl;
- language ID and filtering;
- Unicode fixing (
I'd→I'd); - exact dedup;
- fuzzy dedup;
- 20+ heuristic filters (e.g. > 25% non-alphanumeric, > 20% URLs, or a word longer than 1,000 characters → discard);
- perplexity filtering;
- quality classification by an ensemble of FineWeb-style educational classifiers into buckets;
- synthetic data generation: a Wikipedia-style rephraser for low-quality documents; diverse QA pairs, distillation, knowledge extraction and knowledge lists for high-quality ones (Lecture 11).
Failure modes (both lectures):
| symptom | fix |
|---|---|
| OOM when reading input (e.g. 10 GB Parquet files; pyarrow “offset overflow”) | reshard into ~256 MB files; fewer files per partition |
| OOM in classifier inference | lower the inference batch size |
| dead CPU workers or Ray subprocesses | limit the CPUs given to Ray; each worker has memory overhead |
The design rules of thumb:
- Partitions should fail cheaply.
- Budget memory per stage, not globally.
- If you didn’t log it, you can’t debug it. Log throughput, memory and drop rates for every stage.
- Connect curation techniques to training outcomes.
Data KPIs (Spring slides): unique documents and tokens; domain and language distributions; classifier-score distributions; toxicity and PII hit rates; perplexity by domain; exact-duplicate rate and near-duplicate cluster sizes; n-gram overlap with eval sets. Treat the dataset as code: version it, test it, monitor it.
6. Summary
- Runs need more data than Chinchilla said (Llama 3 8B: 94× its optimum), and the largest filtered web datasets hold about one 15T run’s worth. Data is the least documented part of model reports.
- Curation is mostly deciding what to throw away, in stages ordered cheap to expensive (DCLM keeps 1.4% of documents). Each decision is an ablation on small models.
- Every filter removes good data too, unevenly. In the toy crawl, a stop-word rule deleted all math (5.087 bits/byte on math), and a blocklist removed 80% of one benign topic. Raw dumps cost +0.157 bits/byte against extracted text.
- “Quality” means whatever a filter was built to find. A distilled judge classifier trained the best non-oracle model. Wiki-referenced classifiers and perplexity filters deleted math and code entirely. Learned filters disagree (30% kept by all three; 10% by both FineWeb-Edu and DCLM on real data).
- Up to ~4 epochs repetition is nearly free (+0.005 bits/byte), 16+ is not (+0.170, then collapse). A small repeated subset hurts. Filtering stops paying as compute grows: filtered data won at 100 steps and lost at 1,600. Long runs keep more data and weight it by quality.
- Dedup: exact is precise but misses near copies. MinHash + LSH finds 96% at FineWeb’s 14 × 8 (threshold ≈ 0.68). Run it on extracted text, per snapshot, and decontaminate against benchmarks.
- Mixtures decide what the model knows. Facts stated 51+ times were 100% correct, 0 times 4%. Proxy-chosen weights must be verified at scale against a noise floor. Annealing on the best data during the decay lifted fact accuracy from 18% to 29% in 20% of the steps.
- At web scale, curation is a distributed system whose cost is set by model inference and global dedup. Streaming, balancing and backpressure turned 13,000 s into 1,013 s; dedup cannot stream.
7. Common pitfalls
- Judging a filter by how clean its output looks instead of by the model it trains.
- Keeping a rule because it removes junk, without checking which good data it removes (stop words vs math; blocklists vs topics and dialects).
- Training a quality classifier on a reference set that lacks a domain you need.
- Dedup on raw HTML or WET text (templates dilute and merge), or global dedup across snapshots without checking which copies are kept.
- Forgetting decontamination after adding a new data source.
- Treating mixture search with tiny proxies as final, or comparing mixtures without a noise floor.
- Filtering as hard at 1e26 FLOPs as at 1e21: with enough compute, unique tokens matter more.
- Optimizing the latency of one document instead of total throughput; unbounded queues between unbalanced stages.
- 10 GB input files in a distributed pipeline.
8. Exercises
- Epochs. You plan an 8B model on 30T tokens; your filtered pool has 6T unique tokens. How many epochs? What do Muennighoff et al. suggest about the value of the repeated passes, and what would you do instead?
Answer
5 epochs. Up to about 4 epochs repeated tokens are nearly as valuable as new ones, and the 5th is somewhat less so. That is acceptable, but at the margin you would loosen the filter (soft filtering: keep middle-quality buckets at lower weight, à la Nemotron-CC) or add rephrased synthetic data (Lecture 11) to raise the unique tokens, rather than repeat the top bucket many times.
- The LSH curve. With , , what is the probability that documents with become candidates? With ? Compare with FineWeb’s 14 × 8.
Answer
. At : . For 14 × 8: ; . So 20 × 5 is looser: higher recall (demo 04: 97.4% vs 95.8%) and more false candidates at moderate similarity, which then cost more verification.
- Rule audit. A new rule “drop documents where fewer than 70% of tokens are dictionary words” removes 30% of the crawl. What two measurements would you make before adopting it?
Answer
(1) What it removes, broken down by domain, language and topic, with samples read by a human: code, math, names, technical text and other languages will fail a dictionary test. (2) An ablation: the same small model and token budget, with and without the rule, scored on per-domain validation loss and early-signal benchmarks. Adopt it only if the model improves without a regression on a domain you need.
- Temperature sampling. Three languages have 900B, 90B and 10B tokens. With , what are the sampling weights? For a 300B-token run, how many epochs does the smallest language get?
Answer
; ; normalized . The smallest gets tokens = 2.2 epochs, within the “nearly free” range. With it would get more (weight 0.147, 44B tokens, about 4.4 epochs), approaching the point where repetition costs.
- The cost of a judge. Labelling 1M documents (1,000 tokens each) with a 70B model, and training a 150M classifier on them, then scoring 20T tokens: compare the FLOPs with scoring all 20T tokens with the 70B model.
Answer
Labelling: . Scoring with the classifier: (training the classifier is negligible). Total ≈ . Scoring everything with the 70B model: , about 460× more.
- Balancing. A pipeline has stages taking 0.5 s (CPU), 4 s (GPU model A, 8 GB) and 12 s (GPU model B, 20 GB) per item on a 80 GB GPU. What copy counts balance it, and what throughput do you get?
Answer
Balance to the same per-stage rate: copies ∝ time, i.e. 1 : 8 : 24 for a rate of 2 items/s. That needs GB, which does not fit. Under 80 GB, maximize subject to GB: , so items/s (e.g. 1 copy of A and 3 of B: rates 0.25 and 0.25 items/s with 68 GB). More GPUs or smaller models raise it. Measure the per-copy rate, since copies may contend.
- Why per-snapshot? Explain in two sentences why global dedup across crawl snapshots can lower data quality, and propose a dedup policy that avoids it.
Answer
Good pages tend to be re-crawled in later snapshots while low-quality pages appear once. So global dedup removes good pages from each old snapshot (they reappear elsewhere) and keeps the never-re-crawled junk, biasing the kept set. Dedup within each snapshot (FineWeb), or dedup globally but choose which copy to keep by quality score rather than by order.
9. The related assignment (concepts only)
Assignment 2 (pre-train from scratch on one 8×H100 node) depends on data choices made before the run:
- which public corpus or mixture to start from;
- whether to filter further or weight by quality;
- how many epochs your token budget implies;
- which domains your evaluation needs (do not filter them away);
- what to anneal on at the end.
The Spring 2026 course also had a NeMo Curator lab: build usable pre-training datasets with Curator’s stages. No assignment solutions are given here; crawl.py and curate.py are independent of the course materials.
10. Research directions
- Filtering that scales with compute. If filtering pays less as budgets grow, what replaces it: soft weighting, quality-aware curricula, rephrasing (Lecture 11)? How should the optimal filter strength be predicted from the budget?
- Proxies that can see every domain. Mixture search fails when proxies cannot learn a domain. Can mixtures be chosen from per-domain scaling curves rather than from one small model’s loss?
- Auditing filter bias. Blocklists and classifiers remove text about some topics, groups and dialects. Cheap, systematic audits of what each filter removes, by slice, before it is adopted.
- Dedup policies as sampling policies. Which copy a dedup keeps changes the data distribution (FineWeb’s global-dedup finding). Quality-aware and temporally aware dedup.
- Curation systems. Streaming global dedup; autobalancing across heterogeneous CPU/GPU stages; making curation runs as reproducible and versioned as training runs.
11. Further reading
- FineWeb (arXiv:2406.17557): extraction, dedup per snapshot, FineWeb-Edu.
- DCLM (arXiv:2406.11794): the filter ablations (Table 4), the funnel.
- Nemotron-CC (arXiv:2412.02595): classifier ensembles, quality buckets, soft filtering, rephrasing.
- C4 / T5 (arXiv:1910.10683) §2.2; Dodge et al., Documenting Large Webtext Corpora (arXiv:2104.08758).
- Lee et al., Deduplicating Training Data Makes Language Models Better (arXiv:2107.06499).
- Muennighoff et al. (arXiv:2305.16264); Hernandez et al. (arXiv:2205.10487); Villalobos et al. (arXiv:2211.04325).
- Mohri, Duchi, Hashimoto, A Bitter Lesson for Data Filtering (arXiv:2605.19407).
- Kandpal et al., Large Language Models Struggle to Learn Long-Tail Knowledge (arXiv:2211.08411).
- DoReMi (arXiv:2305.10429); RegMix (arXiv:2407.01492); OLMo 2 §4 (mid-training, microanneals).
- Maini et al., Safety Pretraining (arXiv:2504.16980).
- NeMo Curator (github.com/NVIDIA-NeMo/Curator): the quickstart tutorial and the Nemotron-CC workflow.
12. Next lecture
Lecture 11 · Synthetic Data for Pre-Training. Filtering only removes; the stock of human text is finite. Lecture 11 covers making new training data with models:
- rephrasing web pages into new forms that carry the same facts;
- textbook-style generation from seed topics, and its narrow coverage;
- distillation, where the teacher writes the targets;
- the quality control and reproducibility of generation pipelines;
- model collapse when models train on their own outputs.
It starts from this lecture’s crawl.
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| pre-training / mid-training data | 预训练数据 / 中期训练数据 |
| Common Crawl / WARC / WET / snapshot | 通用网页爬取 / 原始网页存档 / 纯文本导出 / 快照 |
| curation pipeline / funnel | 数据整理流水线 / 漏斗 |
| ablation | 消融实验 |
| text extraction / boilerplate | 正文抽取 / 模板噪声 |
| language identification (LID) | 语种识别 |
| heuristic filter / terminal punctuation / stop words / blocklist | 启发式过滤 / 句末标点 / 停用词 / 屏蔽词表 |
| filter bias | 过滤偏差 |
| quality classifier / LLM judge / distillation | 质量分类器 / 大模型评审 / 蒸馏 |
| reference data (positives) / random web (negatives) | 参考数据(正例) / 随机网页(负例) |
| perplexity filter | 困惑度过滤 |
| hard filtering / soft filtering / quality bucket | 硬过滤 / 软过滤 / 质量分桶 |
| data-constrained scaling / epoch / repetition | 数据受限缩放 / 轮次 / 重复 |
| memorization / regurgitation | 记忆 / 逐字复现 |
| exact / fuzzy deduplication | 精确 / 模糊去重 |
| shingle / MinHash / LSH / band / row | 词片 / 最小哈希 / 局部敏感哈希 / 带 / 行 |
| Jaccard similarity / candidate pair / connected component / union-find | 杰卡德相似度 / 候选对 / 连通分量 / 并查集 |
| contamination / decontamination | 测试集污染 / 去污染 |
| mixture weights / temperature sampling | 数据配比权重 / 温度采样 |
| proxy model / mixture search / rank invariance | 代理模型 / 配比搜索 / 排序不变性 |
| annealing / microanneal | 退火 / 微退火 |
| long-tail knowledge | 长尾知识 |
| throughput / latency | 吞吐量 / 延迟 |
| streaming / backpressure / load balancing / autobalancing | 流式处理 / 背压 / 负载均衡 / 自动均衡 |
| executor / stage / task / partition | 执行器 / 阶段 / 任务 / 分区 |
| provenance / data versioning | 数据溯源 / 数据版本管理 |