Step 7 · Data is the product
Architecture is nearly free — you can copy it. Data is where models actually differ, and where almost all the work is.
In 60 seconds
Step 7 · Data is the product
Architecture is nearly free — you can copy it. Data is where models actually differ, and where almost all the work is.
The pipeline, in order
- 1
1 · Acquire
Web crawls, books, code, papers, curated collections. Check the licence. "It was on the internet" is not a licence, and this is now litigated regularly. - 2
2 · Extract
HTML to text is harder than it looks. Boilerplate, navigation, cookie banners and comment spam all end up in naive extractions and all poison the model. - 3
3 · Filter for quality
Language identification, a classifier trained on known-good text, perplexity filters, heuristics on punctuation and line length. Most crawled text is discarded — often 90% or more. - 4
4 · Deduplicate
Exact and near-duplicate removal, usually with MinHash. This is the highest-value single step: duplicated text wastes compute and causes memorisation. - 5
5 · Decontaminate
Remove anything matching your evaluation sets. Skip this and your benchmark numbers are fiction — see Module 28. - 6
6 · Mix
Choose proportions per source and how many times each is repeated. This is a design decision with large effects on the final model. - 7
7 · Tokenize and shard
Pre-tokenise into flat binary shards. Reading tokenised uint16 arrays is dramatically faster than tokenising on the fly.
from datasketch import MinHash, MinHashLSH
def shingles(text, k=5):
words = text.split()
return {" ".join(words[i:i+k]) for i in range(len(words) - k + 1)}
lsh = MinHashLSH(threshold=0.8, num_perm=128)
kept = []
for i, doc in enumerate(documents):
m = MinHash(num_perm=128)
for sh in shingles(doc):
m.update(sh.encode("utf-8"))
if not lsh.query(m): # nothing similar seen yet
lsh.insert(str(i), m)
kept.append(doc)A realistic mixture
| Source | Share | Why |
|---|---|---|
| Filtered web text | 50–65% | Breadth, and the only source available at scale |
| Code | 10–20% | Improves reasoning and structure even for non-code tasks |
| Books and long-form | 5–15% | Long-range coherence, which web text rarely has |
| Academic and reference | 5–10% | Factual density |
| Curated / synthetic | 5–15% | Targeted skills, instruction shapes, underrepresented languages |
| Multilingual | varies | Deliberate, or your model will be an English model that stumbles elsewhere |
Synthetic data: the current frontier
- Rewriting scrappy text into clear explanations.
- Reasoning traces that can be verified — maths with checkable answers, code with tests.
- Instruction and format diversity.
- Filling gaps: rare languages, rare domains.
- Unverified facts — the generator's errors become training targets.
- Style collapse: everything starts sounding the same.
- Narrowing diversity, generation after generation.
- Quietly training on your own benchmark answers.
How much data?
Watch and read more
Lab
A data pipeline that throws most of its input away, correctly.
The problem
stages = ["raw", "extracted", "quality", "deduped", "decontaminated"]
for a, b in zip(stages, stages[1:]):
print(f"{a:16} -> {b:16} {len(sets[b])/len(sets[a]):.1%} survived")You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1Your quality filter keeps 8% of the crawl. Argue that this is too aggressive, then argue it is not.Reveal
Questions people ask
Can I just use a public dataset?
Yes, and you should to learn. FineWeb, The Pile, RedPajama, Dolma and similar collections are already filtered and deduplicated. Read their datasheets — the filtering choices they made are now your choices.
How much does deduplication matter?
A great deal. Published results show meaningful improvements in final loss and large reductions in verbatim memorisation. It is the highest return-per-hour step in the entire pipeline.
Is training on copyrighted text legal?
Actively contested, differs by jurisdiction, and being decided in court right now. If you are shipping commercially, get advice specific to your market rather than following what the big labs appear to do.
What about personal data in the crawl?
It is there, and models can memorise and reproduce it. Filter for personal information, support deletion requests, and understand that "the model memorised it" is not a defence under most privacy regimes.
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.
Sign in with your phone number to take the test and save your progress