Where data comes from, and what you're allowed to use
Data is arguably the most important thing to get right in a language model — and the one thing companies won't disclose. This lecture builds data up from scratch: where raw data actually comes from (and why "trained on the internet" is wrong), the copyright/legal landscape, the key sources, and a chronological tour of the datasets that built modern LMs.
Why data dominates — and why it's secret
Open-weight reports tell you everything about architecture and even training procedure — but the Llama 3 paper says essentially nothing about data. Two reasons: competitive secrecy (data is the secret sauce) and copyright liability (don't announce what you trained on).
The Llama 3 data section: full architecture transparency, but data is "a variety of sources." Source: CS336 Lecture 13.
Data scales with human effort (a long-tail problem), which is why data teams are huge. It enters at three stages, trending from large amounts of low-quality data → small amounts of high-quality data:
| Stage | Data |
|---|---|
| Pre-training | raw web documents (large, lower quality) |
| Mid-training | higher-quality data + long context + synthetic |
| Post-training | chat transcripts, RL environments (task-specific) |
"Base model" = after pre+mid-training; "instruct/chat model" = after post-training — though the lines blur, and the biggest models increasingly release only the instruct model (no base checkpoint).
"Trained on the internet" is wrong
The web is live servers — you need a crawler, and you can't get it all
The web is a set of live servers; you can't train on those directly (unless you're an RL agent), so a crawler discovers and downloads pages from a seed set. But you can't download everything:
- Dynamic content
- Modern sites are apps; the URL isn't the content — you click buttons / submit forms (Discord, dashboards). The "deep web" isn't reachable by following hyperlinks.
- Authentication / walled gardens
- Huge content needs login/payment (Facebook, X, LinkedIn, NYTimes). Only the owner can train on it.
- Technical restrictions
- robots.txt (voluntary, lists disallowed bots), Cloudflare/CAPTCHAs, IP/country blocks, rate limits.
- Legal restrictions
- Terms of service may prohibit bot downloading; you may lack a license to copy pages for training.
"Consent in Crisis": robots.txt and ToS restrictions on common datasets' URLs shot up around mid-2023 — the legally-crawlable web is far smaller than the web. Source: CS336 Lecture 13.
Crawlers can also misbehave (Anthropic was accused of hitting a site ~1M times/24h) — overloading servers costs the host money before copyright even enters. And shadow libraries (LibGen, Anna's Archive, Sci-Hub) host millions of copyrighted books/papers for free — legally, piracy and copyright infringement.
Copyright: everything online is copyrighted
Intellectual-property law exists to incentivize creation. Under the US Copyright Act (1976): protection applies to "original works of authorship fixed in a tangible medium." Key facts: it covers expression, not ideas (you can't copyright quicksort); collections aren't copyrightable (a phone book) unless creatively arranged; no registration needed (your website is copyrighted the moment it's fixed; $65 to register before suing); it lasts 75 years, then enters the public domain. Net: basically everything on the internet is copyrighted. Two ways to use it:
License = "a promise not to sue" — e.g. Creative Commons (Wikipedia, Khan Academy) or paid deals (Reddit↔Google, Shutterstock/StackExchange↔OpenAI). Fair use (§107) is judged on four factors: (1) purpose/character (transformative & educational favored over reproductive/commercial), (2) nature (factual over creative), (3) amount used (a snippet over the whole), (4) effect on the market.
Copyright is about semantics and economics, not verbatim n-gram overlap — characters/plots (Harry Potter) are protectable; parody is likely fair use. For LMs: copying data is already a potential violation; training feels transformative (extracting ideas, not re-hosting); but LMs can clearly affect the market. And ToS adds a layer (YouTube forbids downloading even CC-licensed videos). Recent rulings:
| Case | Outcome |
|---|---|
| NYT v. OpenAI (2023) | alleged training + near-verbatim reproduction; pending |
| Authors v. Anthropic (2024) | training is fair use, but pirating is not → Anthropic paid $1.5B (~$3K/book) |
| Authors v. Meta (2025) | training (this instance) fair use; torrenting allegation pending |
So far: training has been deemed fair use in specific instances (not in general); pirating books is clearly illegal; the area is active and evolving.
The key specialized sources
- Common Crawl
- Non-profit (since 2007); a monthly crawl adds ~2–5B pages (300B+ total). Two formats: WARC (raw HTTP/HTML) and WET (lossily converted to text). The HTML→text tool matters for downstream accuracy — trafilatura/resiliparse beat WET.
- Wikipedia
- 67M articles; no original thought (everything cited), notability-gated. Download the periodic dumps (don't crawl). Caveat: data-poisoning — inject malicious edits right before a dump so they're captured before being reverted (even high-quality sources can be attacked).
- GitHub
- Code (helps reasoning, not just coding). Train only on permissively-licensed public repos (MIT/Apache). Two data types: repos (via git) and metadata (issues/PRs via the GitHub Archive event stream). Software Heritage aggregates repos across GitHub/GitLab/Bitbucket.
- arXiv
- ~3M papers since 1991; each has metadata (CC0) + PDF + optional LaTeX source. Authors choose all-rights-reserved or Creative Commons. Bulk download from S3.
BERT to Common Pile
The chronological tour
Read across these and you see the same moves recur — crawl, then filter by rules or by a model/classifier, then deduplicate — with sizes ballooning and the rules-vs-classifiers divide running throughout.
| Dataset (year) | Idea |
|---|---|
| BERT (2018) | Wikipedia + BooksCorpus (free Smashwords books, later taken down); trained on documents, not sentences |
| GPT-2 WebText (2019) | pages linked from Reddit posts with ≥3 karma (quality surrogate); 40GB |
| CCNet (2019) | filter Common Crawl: dedup + language ID + keep docs that look like Wikipedia (KenLM) |
| C4 / T5 (2019) | filter by manual rules (punctuation, ≥5 words, no bad words, drop "{" → no code); 156B tokens |
| GPT-3 (2020) | Common Crawl + WebText2 + books + Wiki; quality classifier (vs WebText/Wiki/Books) + fuzzy dedup |
| The Pile (2021) | grassroots, 22 curated domains (PubMed, arXiv, GitHub, Enron emails, Gutenberg, StackExchange, Books3) |
| Gopher MassiveText (2021) | rules-based filtering, SafeSearch toxicity; 10.5TB (trained on only ~12%) |
| Llama (2022) | CCNet but classify "is this a reference of Wikipedia"; + Books3 (→ lawsuit trouble). Reproduced as RedPajama |
| RefinedWeb (2023) | "web is all you need"; Gopher rules, avoid ML filtering (bias), MinHash dedup |
| FineWeb (2024) | RefinedWeb done better, all CC dumps, rules + dedup + PII removal; 15T tokens |
| Dolma (2024) | AI2 open dataset: Reddit, papers, C4…; rules-based filtering, Bloom-filter dedup; 3T |
| DCLM (2024) | model-based filtering gold standard: 240T pool → fastText classifier (OpenHermes+ELI5 vs RefinedWeb) → 3.8T |
| Nemotron-CC (2024) | "DCLM filters too hard"; classifier ensemble + synthetic rephrasing; 6.3T |
| The Stack / v2 | code: permissive repos, dedup, PII; pair low-resource languages with shared LLVM IR; linearize PRs |
| Common Pile (2025) | only permissively-licensed data (8TB) — can you train a good model legally clean? |
The rules → classifiers shift, and the filtering funnel
Early datasets filtered with hand-written rules (C4, Gopher, RefinedWeb explicitly avoided ML filtering to dodge bias). DCLM marked the turn to model-based quality filtering as the norm — and it works strangely well: train a cheap fastText classifier on "good" (GPT-4 instruction data + ELI5) vs "bad" (raw RefinedWeb), then run it over a massive pool.
The funnel: DCLM's 240T-token raw pool → English + rules + dedup + model-based filtering → ~3.8T tokens (~1.4%). Source: CS336 Lecture 13.
You can keep 240T low-quality tokens or aggressively filter down to ~1–3T high-quality tokens — and the sweet spot is in between. Filtering is one of the highest-leverage steps: going from 200T to <3T tokens is where much of a model's quality is decided. Nemotron-CC pushes back ("DCLM filters too hard, we need more tokens") with classifier ensembles + synthetic rephrasing.
And legally-clean training is possible but hard: Common Pile (8TB permissive-only) trains a decent model but can't yet match Qwen-class models — and even "permissive" is subtle (license laundering, collection licenses not extending to individual works, synthetic data from models trained on unlicensed data).
Golden rules & takeaways
Next: more on data — post-training data and a deeper look at filtering/deduplication/mixing.
References
Primary source is the lecture (executable lecture_13.py). Key works:
- Longpre et al. (2024) — Consent in Crisis
- Wenzek et al. (2019) — CCNet · Raffel et al. (2019) — T5 / C4
- Gao et al. (2021) — The Pile · Rae et al. (2021) — Gopher / MassiveText
- Touvron et al. (2023) — LLaMA · Penedo et al. (2023) — RefinedWeb
- Soldaini et al. (2024) — Dolma · Li et al. (2024) — DataComp-LM (DCLM)
- Kocetkov et al. (2022) — The Stack · Lozhkov et al. (2024) — The Stack v2
- Kandpal et al. (2025) — The Common Pile
- Carlini et al. (2023) — Poisoning Web-Scale Datasets