Lesson 9 of 13

Where training data comes from

Web crawls, books, code, synthetic text, and human feedback, and the filtering and deduplication that turn a raw crawl into training tokens. Run a miniature pipeline yourself.

Advanced25 min

Builds on How LLMs are trained and Tokens (Language as vectors)

In this lesson you will

  • Name the main sources of pretraining text and roughly how many tokens today's models train on
  • Run the stages of a data pipeline (quality rules, blocklists, exact and near-duplicate removal) and say what each one costs
  • Explain why duplicated text matters for memorization, and how MinHash finds near copies
  • Describe the consent and copyright questions around training data, and where they stood in October 2026

GPT-3 was trained on 300 billion tokens in 2020. Llama 3’s largest model read 15.6 trillion in 2024, and Qwen3 was trained on about 36 trillion in 2025. The lesson on training showed why models read so much. This lesson is about what they read: where that text comes from, and the work that happens before a model sees a single TokenThe unit of text a language model reads and writes. A token can be a whole word, part of a word, a single character, or punctuation, often including a leading space.Taught in TokensOpen in glossary of it.

Where the text comes from

Web crawls. Most of it is web pages. Common CrawlA nonprofit that crawls the web and publishes free snapshots of billions of pages. Most open training datasets for language models start from its crawls.Open in glossary, a nonprofit founded in 2007, crawls the web and publishes free snapshots: more than 300 billion pages so far, with 3 to 5 billion new pages a month, according to its homepage in October 2026. Many open datasets start there, including C4 (Raffel and colleagues, 2020), RefinedWeb (Penedo and colleagues, 2023), and FineWeb, which turned 96 snapshots into 15 trillion tokens (Penedo and colleagues, 2024). Some companies also run their own crawlers.

Curated text. Wikipedia, books, and research papers are smaller than the web but cleaner and denser, so developers often show them to the model more often than their size alone would.

Code. Public software repositories. The Stack (Kocetkov and colleagues, 2022) collected 3.1 TB of permissively licensed code in 30 programming languages and offered a tool for developers to check whether their code was included and ask to be removed.

Synthetic text. Text written by other models. Phi-1, a 1.3-billion-parameter code model, was trained on 6 billion tokens of filtered web text plus about 1 billion tokens of textbooks and exercises generated with GPT-3.5 (Gunasekar and colleagues, 2023). Training each new model only on the previous model’s output, generation after generation, makes models lose the rare parts of the original data, an effect called model collapse (Shumailov and colleagues, Nature, 2024). When each generation’s synthetic data was added to the real data instead of replacing it, Gerstgrasser and colleagues (2024) saw no collapse in their experiments. How much Synthetic dataTraining data generated by a model or a program instead of collected from people, such as textbook-style exercises written by a language model.Open in glossary helps, and when it hurts, is still being worked out.

Human feedback. Example conversations and comparisons written or rated by people, used after pretraining to turn a base model into an assistant. They are a tiny fraction of the tokens; the lesson on rewarding LLMs shows how they are used.

Developers decide how much of each source the model reads, its Data mixtureThe share of training that comes from each source, such as web pages, books, code, and mathematics. Developers tune it, often showing high-quality sources more than once.Open in glossary. GPT-3’s paper published its mixture:

SourceTokensShare of trainingTimes each token was seen
Common Crawl, filtered410 billion60%0.44
WebText2 (pages linked from Reddit)19 billion22%2.9
Books112 billion8%1.9
Books255 billion8%0.43
Wikipedia3 billion3%3.4

Wikipedia was read 3.4 times over, while the filtered crawl was sampled at 0.44 passes, so most of it was never read at all: quality was bought with repetition (Brown and colleagues, 2020). Llama 3’s final mixture was roughly 50% general knowledge, 25% mathematics and reasoning, 17% code, and 8% text in languages other than English, chosen by training small models on candidate mixtures and fitting Scaling lawsFitted curves that predict how a model's loss falls as parameters, training data, or compute grow. They are empirical, and their constants depend on the architecture, data, and training recipe.Taught in How LLMs are trainedOpen in glossary to predict which would work best at full size (Llama team, 2024).

How much text is there? Researchers at Epoch AI estimated that the indexed web holds an effective stock of around 400 trillion tokens of public human-written text, allowing for training on some of it more than once, and projected that, if trends continued, training sets would reach that size between 2026 and 2032 (Villalobos and colleagues, ICML 2024). This site’s own SmolLM2-135M read 2 trillion tokens; its 1.7-billion-parameter sibling read 11 trillion (Allal and colleagues, 2025).

From a raw crawl to training data

A raw crawl is mostly not worth learning from: cookie notices, error pages, login forms, menus, spam written for search engines, and the same article copied across dozens of sites. The pipeline behind RefinedWeb removed nearly 90% of the documents it started with, about half for not being English, then about a quarter of the rest for quality, then more as duplicates (Penedo and colleagues, 2023).

Below is a miniature version. The crawl is 113 pages written for this lab, because real crawled pages belong to their authors; they imitate what the papers describe. Every square is a page. Switch the stages on and watch what survives.

Clean a web crawl

A sample crawl of 113 pages written for this lab. Switch on each stage of the pipeline and see what survives.

Pipeline

  1. Remove pages that break simple quality rules from Gopher and C4.

    Off

  2. Remove any page containing a blocked word, as C4 did. This lab blocks four words from C4's list.

    Off

  3. Remove pages whose text is identical to an earlier page.

    Off

  4. Remove pages that share most of their 5-word phrases with an earlier page, estimated with MinHash.

    Off

  5. Keep only the first copy of every line, so repeated menus and notices appear once.

    Off

Words left after each stage

  • Raw crawl10,795 words, 113 pages

The crawl, one square per page

Page 1: harbordaily.example/storm-record-rain

A person would call it: Article

Kept.

Skip to main content

Harbor Daily | News | Sports | Weather | Opinion

Storm brings record rain to Harbor City

Harbor City recorded 112 millimeters of rain on Saturday, the wettest single day since the city's weather station opened in 1952, according to the regional weather office.

Water covered parts of Front Street and the river path by mid-afternoon. Firefighters helped residents of twelve homes near the old mill move to a shelter at the community center.

City engineer Dana Ortiz said the storm drains were working but could not keep up with the water running down from the hills. Crews will inspect every drain on the east side on Monday.

No injuries were reported. The library and the public pool will stay closed on Sunday while staff check for damage. Residents can report flooded basements by calling the city hotline.

Subscribe to our newsletter for the latest local news.

We use cookies to improve your experience. By continuing to browse, you agree to our cookie policy.

© 2026 Harbor Daily. All rights reserved.

Pages kept113 of 113
Words kept100% (10,795)
Articles kept28 of 28
Cookie notice appears on48 pages

Challenges

0 of 4 complete

  1. The storm report was reposted on four other sites. Remove every repost and copy, but keep the different story about the cleanup after the storm. (not yet)
  2. Find an article worth learning from that a filter throws away, and open it. (not yet)
  3. With the page rules on, find a page of spam or boilerplate that every rule let through, and open it. (not yet)
  4. The same cookie notice appears on most pages. Get it down to one copy in what remains. (not yet)

Try this

  • Turn the stages on one at a time, from the top, and watch the words left after each. Predict before each step: will it remove more pages or fewer than the last?
  • With the page rules on, open the squares marked R. Most deserve it. One is a coding lesson removed for a single curly bracket.
  • Turn on the word blocklist and open what it removed. How many of those pages would you have thrown away?
  • Turn on near duplicates and lower the threshold from 0.75 in steps. The reposted storm story disappears first; below 0.20 the different story about the cleanup goes too.
Exact and estimated similarity with MinHashPython with the standard library
import hashlib

def words(text):
    # Lowercase and drop punctuation, so formatting changes do not count.
    return "".join(c.lower() if c.isalnum() else " " for c in text).split()

def shingles(text, n=5):
    w = words(text)
    return {" ".join(w[i:i + n]) for i in range(len(w) - n + 1)}

def minhash(shingle_set, k=112):
    # Hash function i scores each shingle by the MD5 of "i:shingle".
    # The signature keeps the smallest score for each of the k functions.
    return [min(int(hashlib.md5(f"{i}:{s}".encode()).hexdigest()[:8], 16)
                for s in shingle_set) for i in range(k)]

original = ("Harbor City recorded 112 millimeters of rain on Saturday, the wettest "
            "single day since the city's weather station opened in 1952. Water "
            "covered parts of Front Street and the river path by mid-afternoon.")
repost = ("Storm brings record rain. Harbor City recorded 112 millimeters of rain "
          "this Saturday, the wettest single day since the city's weather station "
          "opened in 1952. Water covered parts of Front Street and the river path "
          "by mid-afternoon. Originally published by Harbor Daily.")
other = ("Volunteers cleared mud from Front Street on Sunday after the rain, the "
         "heaviest the city has measured in a single day since 1952.")

a = shingles(original)
sig_a = minhash(a)
for name, text in [("repost", repost), ("other story", other)]:
    b = shingles(text)
    exact = len(a & b) / len(a | b)
    sig_b = minhash(b)
    estimate = sum(x == y for x, y in zip(sig_a, sig_b)) / len(sig_a)
    print(f"{name:11}  exact {exact:.2f}  MinHash estimate {estimate:.2f}")
repost       exact 0.58  MinHash estimate 0.51
other story  exact 0.00  MinHash estimate 0.00

What each stage did

Page rules. The rules come from Gopher’s MassiveWeb (Rae and colleagues, 2021) and C4: keep pages of 50 to 100,000 words, with ordinary word lengths, few hashtags or ellipses, mostly not bullet points, mostly words with letters, at least two of eight common English words (the, be, to, of, and, that, have, with), and no single word pair repeated to fill the page; C4 also dropped any page containing “lorem ipsum” or a curly bracket. In the lab they remove 56 of 113 pages, nearly all of them junk. They also remove the coding lesson, because C4’s authors used the curly bracket to spot code. Rules have costs that are easy to miss: C4 kept only lines ending in punctuation, and FineWeb’s authors found that this one rule removed about 30% of all tokens, so they dropped it.

Word blocklist. C4 removed every page containing any word on a public list of offensive words, which has about 400 English entries today. The lab blocks four words from that list, each with an everyday meaning, and the blocklist removes five pages: one piece of gossip spam, a page about heart attack symptoms, a rugby guide, a history of wartime convoys, and an art history article. Real filters fail in the same way: Dodge and colleagues (2021) found that C4’s blocklist removed text from and about some minority groups disproportionately, including text discussing LGBTQ+ identities. Gopher’s authors cited that finding and used Google’s SafeSearch instead; FineWeb blocks known adult websites by address.

What rules miss. Smooth filler that says nothing passes every rule in the lab, and so do cookie walls and legal templates long enough to look like articles. So pipelines add a trained quality classifier. GPT-3’s was a logistic regression trained to tell curated text from raw crawl. For FineWeb-Edu, Llama 3 70B rated 460,000 pages for educational value from 0 to 5, a small model learned to predict those ratings, and keeping pages scored 3 or more left 1.3 trillion of FineWeb’s 15 trillion tokens. Llama 3’s own pipeline used classifiers trained on Llama 2’s judgments.

Exact and near duplicates. Removing copies is called DeduplicationRemoving copies from a dataset, both exact copies and near copies such as a reposted article with a new headline. In training data it reduces wasted compute and memorization.Open in glossary. The same page reached through a tracking link is an exact copy, easy to catch. A story reposted with a new headline and footer is not. To find those, pipelines compare the sets of short phrases two pages share, using MinHashA way to estimate how similar two sets are from short signatures: for each of many random hash functions, keep each set's smallest hash. The share of matching minimums estimates their Jaccard similarity.Open in glossary to estimate their Jaccard similarityThe similarity of two sets, from 0 to 1, measured as the number of items they share divided by the number of items in either one.Open in glossary without comparing every phrase. FineWeb treats pages as copies when they are about 75% similar or more. By MinHash’s estimate, the lab’s storm reposts share 31% to 71% of their phrases with the original, so at 0.75 they all survive; you have to go down to 0.30, and below 0.20 two different stories from the same site start to merge through their shared menus. FineWeb’s authors also found that deduplicating across all 96 snapshots at once barely helped, while deduplicating each snapshot on its own worked better: in the oldest snapshots, the pages with no copies anywhere else were mostly ads, keyword lists, and badly formatted text.

Page A Harbor City recorded 112 millimeters of rain on Saturday

Page B Harbor City recorded 112 millimeters of rain this Saturday

Only in A

  • 112 millimeters of rain on
  • millimeters of rain on saturday

In both

  • harbor city recorded 112 millimeters
  • city recorded 112 millimeters of
  • recorded 112 millimeters of rain

Only in B

  • 112 millimeters of rain this
  • millimeters of rain this saturday

Jaccard similarity = phrases in both ÷ phrases in either = 3 ÷ 7 = 0.43

Each page becomes its set of 5-word phrases, lowercased and without punctuation. One changed word breaks every phrase that contains it, here 2 of 5 on each side. At FineWeb's threshold of about 0.75 these two would count as different pages; longer pages with the same one-word change would share far more.

Repeated lines. Removing whole pages leaves menus and notices repeated inside pages that are otherwise unique: the lab’s cookie notice is still on 29 pages after every page-level stage. Llama 3’s pipeline removed any line appearing more than 6 times in each bucket of 30 million documents; its authors noted this also removed some frequent high-quality text, and measured that it still helped.

With every stage on, the lab keeps 34 of 113 pages and 28% of the words, and loses 5 of its 28 articles on the way.

How MinHash estimates similarityOptional

Turn each page into its set of ShingleA short run of consecutive words, for example every 5-word sequence in a page. Comparing the sets of shingles two pages share is how near copies are found.Open in glossary: every run of 5 consecutive words, lowercased, without punctuation. The Jaccard similarity of two pages is the number of shingles they share divided by the number in either:

J(A,B)=∣A∩B∣∣A∪B∣J(A, B) = \frac{|A \cap B|}{|A \cup B|}

Now pick a random hash function hh, which scores every possible shingle with a random number, and take the shingle with the lowest score in each set. The lowest-scoring shingle of A∪BA \cup B is equally likely to be any of its members, and the two sets have the same minimum exactly when that shingle is in both. So

P(min⁡a∈Ah(a)=min⁡b∈Bh(b))=J(A,B).P\big(\min_{a \in A} h(a) = \min_{b \in B} h(b)\big) = J(A, B).

Repeat with kk independent hash functions and the fraction of matching minimums estimates JJ, with standard error J(1−J)/k\sqrt{J(1-J)/k}: about 0.047 at most for FineWeb’s k=112k = 112. Each page is reduced to kk numbers, its signature, however long it is (Broder, 1997).

Comparing every pair of signatures is still too slow for billions of pages. Locality-sensitive hashing splits each signature into bb bands of rr values and compares only pages that match exactly on at least one band, which happens with probability 1−(1−Jr)b1 - (1 - J^r)^b. FineWeb’s 14 bands of 8 catch pairs at J=0.75J = 0.75 77% of the time and at J=0.85J = 0.85 98.8% of the time. The lab, with only 113 pages, simply compares every pair of signatures.

Why duplicates matter: memorization

A model that sees the same text many times can learn to reproduce it word for word, which is called MemorizationWhen a model can reproduce passages of its training data word for word. It is much more likely for text the model saw many times, which is one reason training data is deduplicated.Open in glossary. Lee and colleagues (2022) found a 61-word sentence repeated 61,036 times in C4, and that over 1% of what models trained on such data wrote unprompted was copied from their training data; deduplicating cut that rate about tenfold. Kandpal and colleagues (2022) found that a sequence present 10 times in training data was generated about 1,000 times more often than one present once. Carlini and colleagues extracted hundreds of verbatim training sequences from GPT-2 in 2021, including names, phone numbers, and email addresses that had been public on the web, and later measured that memorization grows with model size, with the number of copies, and with how much of the text a prompt supplies (2023).

That is a privacy problem when the text is personal, a legal problem when it is copyrighted, and a waste of training when it is a cookie notice.

Contamination

If a benchmark’s questions are in the training data, a high score may measure memory instead of skill. That is Data contaminationWhen test questions, or their answers, end up in a model's training data, so a benchmark score partly measures memory instead of skill.Taught in Evaluation: what a score meansOpen in glossary, covered in the lesson on evaluation. The same tools that find copies fight it: Gopher’s authors removed any training document whose 13-word phrases overlapped a test document’s with a Jaccard similarity above 0.8, and Lee and colleagues found that more than 4% of the validation examples in the standard datasets they studied also appeared in the training data.

Nobody asked most authors of web pages whether their text could train a model, and the rules are still being settled.

Opting out. Crawlers name themselves, and a site’s robots.txt file can ask any of them to stay away. Common Crawl’s crawler is called CCBot; OpenAI says that disallowing its crawler, GPTBot, “indicates a site’s content should not be used in training generative AI foundation models.” In one year, 2023 to 2024, so many sites added such restrictions that about 5% of all tokens in C4, and over 28% of tokens from its most actively maintained sources, became fully restricted under robots.txtA file on a website that tells named crawlers which pages they may visit. Site owners use it to opt out of crawlers that collect AI training data; it is a request, not a technical barrier.Open in glossary (Longpre and colleagues, 2024).

Courts. Lawsuits ask whether copying works to train a model is lawful. Under United States law, the question is usually Fair useA rule in United States copyright law that allows some uses of copyrighted work without permission, decided case by case on four factors, including the purpose of the use and its effect on the market for the work.Open in glossary. Decisions so far, as of October 2026:

CaseWhat the court decided
Bartz v. Anthropic (federal court, California, June 2025; summary, settlement)Training on books was fair use, and so was scanning print books Anthropic had bought. Downloading and keeping pirated copies in a central library was not. The case then settled for $1.5 billion, about $3,000 per book, covering past claims about books downloaded from two pirate libraries; the court gave final approval on July 20, 2026.
Kadrey v. Meta (federal court, California, June 2025; summary)Meta won on fair use against the 13 authors who sued, because they had not shown that Llama harmed the market for their books. The judge wrote that such harm, through floods of competing text, could matter in other cases.
Thomson Reuters v. Ross Intelligence (federal appeals court, September 29, 2026; opinion)Copying a legal publisher’s case summaries to train a competing legal search tool was not fair use. The court noted that Ross’s tool did not generate new text and set generative models aside.
The New York Times v. OpenAI and Microsoft (filed December 2023)Still pending in federal court in New York, where it was combined in 2025 with other copyright suits against OpenAI.
Getty Images v. Stability AI (High Court, England, November 4, 2025; judgment)A model that does not store or reproduce the training images is not an “infringing copy” under UK law. Getty had dropped its claim about training, because the training took place outside the UK.
GEMA v. OpenAI (regional court, Munich, November 11, 2025; court’s press release)Song lyrics memorized in a model’s parameters and reproduced in its answers infringed copyright. The judgment was not final when issued.

The outcomes differ because the facts, the laws, and the questions asked differ: how the copies were obtained, whether the model reproduces the works, and whether its output competes with them. Appeals may change any of them.

Rules for developers. In the European Union, the AI Act requires providers of general-purpose models to have a policy for complying with EU copyright law, including respecting machine-readable opt-outs, and to publish a summary of their training content on a template from the European AI Office. These obligations have applied to new models since August 2, 2025, and apply to models already on the market from August 2, 2027 (Regulation (EU) 2024/1689, Articles 53 and 111).

Key ideas

  • Most pretraining text comes from web crawls such as Common Crawl, mixed with books, Wikipedia, code, synthetic text, and a small amount of human-written examples and ratings.
  • A raw crawl is mostly junk. Rules, blocklists, classifiers, and deduplication remove most of it, and every filter also removes some text worth keeping.
  • MinHash estimates how many short phrases two pages share, so near copies can be found among billions of pages; the threshold trades missed copies against lost originals.
  • Repeated text is what models memorize most, which makes deduplication a privacy and copyright measure as well as a quality one.
  • Whether training on copyrighted text is lawful is unsettled and differs by country and by facts. Courts have ruled both ways, and site owners increasingly opt out.

Check yourself

Pick an answer to see why it is right or wrong. Nothing is graded. Your first answer is saved in this browser so the question can come back for review.

1Why do pretraining pipelines remove duplicated text?
2In the lab, you lower the near-duplicate threshold far below 0.2. What goes wrong?
3The word blocklist removed a page about how heart attack symptoms differ by sex. What does that show?
4As of October 2026, what had the federal court decided in Bartz v. Anthropic?

Progress is saved in this browser only.

Up nextFine-tuning and LoRA
Next
Transformers and LLMs
  1. 1Predicting the next token
  2. 2Before transformers: recurrent networks
  3. 3Attention, step by step
  4. 4Many heads and the causal mask
  5. 5Where words are
  6. 6The transformer block
  7. 7Inside a real language model
  8. 8How LLMs are trained
  9. 9Where training data comes from
  10. 10Fine-tuning and LoRA
  11. 11Generating fast: the KV cache
  12. 12Quantization: smaller numbers
  13. 13How a chat assistant works

Try "embedding", "softmax", "overfitting", or "backpropagation".