Unit 3 · Training
Lesson 10 · Available to read
Data Curation: Quality, Diversity and Contamination
Where training data comes from and how it is filtered, deduplicated and mixed — plus the problem of benchmark contamination.
"Garbage in, garbage out" is truer for LLMs than for almost any other software. The pretraining corpus determines what a model knows, what languages it speaks, which biases it absorbs, and even how honest its benchmark scores are. Labs often consider their data pipelines among their most valuable — and most closely guarded — assets.
Where the text comes from
Typical sources include:
- Web crawls — the largest source by far. Common Crawl, a non-profit, publishes regular snapshots of billions of public web pages; many labs also run their own crawlers.
- Code — public source repositories, which also seem to help models with structured reasoning.
- Books and long-form writing — useful for long-range coherence and style.
- Scientific papers, encyclopedias, reference works — dense, high-quality information.
- Licensed or partner data, and increasingly synthetic data generated by other models.
How that material may be used is the subject of ongoing legal and ethical debate — over copyright, consent, website opt-outs such as robots.txt, and compensation for creators. Practices and court rulings are still evolving, and they differ between countries.
The curation pipeline
Raw web data is mostly unusable: navigation menus, ads, spam, machine-generated junk, duplicated pages and broken encoding. A pipeline narrows it down step by step.
1. Extraction. Strip HTML, boilerplate and markup to recover the main text.
2. Language identification. Label each document's language so the mixture can be controlled.
3. Heuristic filters. Simple rules remove obvious junk: too short or too long, too many symbols or numbers, lines that repeat, missing punctuation, lists of keywords.
4. Model-based quality filtering. Train a small classifier to recognise text that resembles high-quality references or educational material, and keep documents it scores highly. Public projects have shown that filtering for "educational value" this way can noticeably improve downstream performance for the same number of tokens.
5. Deduplication. The web is full of copies: mirrored sites, templates, quoted passages. Remove exact duplicates with hashing and near-duplicates with techniques such as MinHash, which estimate how many short word sequences two documents share.
6. Safety and privacy filters. Remove or mask personal information (emails, phone numbers, addresses) and filter toxic or harmful content — carefully, because aggressive filters can also delete legitimate text about health, identity or minority dialects.
7. Decontamination and mixing. Remove copies of evaluation benchmarks, then decide how much of each domain to include.
Why deduplication matters so much
Duplicates do more harm than wasting compute:
- Memorisation. Text seen many times is far more likely to be reproduced word for word — including personal data or copyrighted passages.
- Skewed learning. A spam template repeated a million times gets a million times the influence of a unique, careful article.
- Misleading evaluation. Duplicates that straddle the training and test splits make models look better than they are.
Mixing: the recipe
A corpus is a blend. Labs choose mixture weights for each domain and often upsample precious high-quality sources (repeating them a few times) while downsampling the noisy bulk.
Mixture choices have visible effects: more code tends to help programming and structured reasoning; more multilingual data helps other languages but competes for capacity; a final phase of very high-quality data can lift benchmark scores. Teams test candidate mixtures on small models before committing — another use of scaling experiments.
Quality vs. quantity — and synthetic data
As the supply of fresh, high-quality human text becomes a constraint, curation matters more than raw size. Filtering harder can mean training on fewer tokens yet getting a better model.
Synthetic data — text written by existing models, such as worked solutions, rewritten passages or simulated dialogues — is now common, especially for maths, code and reasoning. It must be generated and filtered carefully: training repeatedly on a model's own unfiltered outputs can narrow diversity and amplify errors, a failure sometimes called model collapse.
Benchmark contamination
If questions from a test set appear in the training data, a high score may reflect memory rather than ability. This happens easily: benchmarks get posted, discussed and copied all over the web.
Defences include:
- n-gram overlap checks — search the training data for long word sequences from the test set and remove them;
- canary strings — unique marker text placed in benchmark files so their presence in a corpus can be detected;
- private or freshly written test sets, and benchmarks built from problems published after a model's knowledge cutoff;
- reporting contamination analyses alongside results.
Lesson 17 returns to what this means for interpreting leaderboards.
Data shapes behaviour
Everything here has downstream consequences you'll meet later: biases in the data appear in model outputs (Lesson 18), memorised text creates privacy and copyright risks, and gaps in the data become gaps in knowledge. Curation is not a one-time cleaning step; it is one of the main levers for making a model capable, fair and safe.
The takeaway
A model is shaped by what it reads: training data is extracted, filtered for quality, deduplicated, cleaned of personal and harmful content, mixed across domains and checked against benchmarks — and careless curation shows up as memorisation, bias or inflated test scores.
Practice
0 of 7 attempted
- 1Recall
List the main stages of a pretraining data pipeline in order.
Saved in this browser
- 2Explain in your own words
Give three reasons why duplicate documents are harmful in a training corpus.
Saved in this browser
- 3Calculate
A crawl yields 200 trillion raw tokens. Extraction keeps 50%, heuristic filters keep 40% of what remains, the quality classifier keeps 30% of that, and deduplication removes half of what's left. How many tokens remain? What fraction of the original is that?
Saved in this browser
- 4Multiple choice
What is a canary string used for?
- 5Apply
Write five heuristic rules you would use to filter low-quality web pages, and name one risk of filtering too aggressively.
Saved in this browser
- 6Explain in your own words
What is benchmark contamination, and why does it make a leaderboard score less trustworthy?
Saved in this browser
- 7Explain in your own words
What is 'model collapse', and how can labs use synthetic data while avoiding it?
Saved in this browser