Chapter 1 · Pretraining Data¶
1.1 Where does pretraining data come from, and what do common data sources and mixtures look like? ★★¶
One-sentence answer
The bulk of pretraining data is public web crawls (with Common Crawl as the main example), which usually make up more than half; in addition there are code, books, academic papers, encyclopedias, math and multilingual data, and more and more synthetic data. In the mixture, web data provides scale and diversity, while high-value data such as code and math, though small in volume, is upsampled to strengthen reasoning. For example, Llama 3's final mixture is roughly 50% general knowledge, 25% math and reasoning, 17% code and 8% multilingual.
I will address this in three parts: what the data sources are, what principles govern the mixture, and how things have changed in recent years.
(1) Data sources: the web provides scale, and the other sources provide quality and specific capabilities.
- Web pages: the main source is Common Crawl, a non-profit project that crawls public web pages periodically; each crawl is called a snapshot. Its volume is enormous; for example, the raw text pool that DCLM extracted from Common Crawl alone contains 240T tokens (Li et al. 2024). Its quality, however, is very uneven, so it must go through extensive cleaning and filtering (see 1.2–1.4).
- Code: public code on platforms such as GitHub, as well as technical Q&A such as StackOverflow. Code improves not only programming ability but also natural-language reasoning (see Follow-up 1 of this question).
- Books, papers and encyclopedias: for example books, arXiv papers and Wikipedia. Their language is well edited, their knowledge density is high and they are long, but their total volume is limited and they raise copyright issues.
- Math: math content, textbooks and worked solutions specifically filtered from the web. The volume is small, but it helps reasoning a great deal.
- Multilingual data: non-English web pages and documents, which determine the model's multilingual ability. For example, Qwen3's pretraining data covers 119 languages and dialects (Yang et al. 2025).
- Synthetic data: text generated or rewritten by strong models, used to supplement scarce types of data (see 1.6).
(2) Mixture principle: sampling weights are assigned by the "value" of the data rather than its "volume".
If sampling followed the natural volume of each source, web data would dominate overwhelmingly and small high-value sources would have almost no effect. In practice, therefore, sampling weights are deliberately decoupled from data volume: high-value data such as code, math and encyclopedias is upsampled and repeated several times during training, while low-quality web data is downsampled. GPT-3 is a typical example: Wikipedia has only 3B tokens yet receives a 3% sampling weight and is repeated about 3.4 times during training, while filtered Common Crawl has 410B tokens and a 60% weight yet is used for only about 0.44 epochs (Brown et al. 2020). Modern models also first subdivide web content by category and then set the share of each category. For example, Llama 3 first used a classifier to determine what type of knowledge web content contains and downsampled categories over-represented on the web, such as arts and entertainment, then compared mixtures with small-model scaling-law experiments, arriving at roughly 50% general knowledge, 25% math and reasoning, 17% code and 8% multilingual (Dubey et al. 2024).
(3) Trends: ever larger scale, and ever greater reliance on filtering and synthesis.
The amount of pretraining data grew by two orders of magnitude in a few years: GPT-3 was trained on 300B tokens, Llama 2 on about 2T tokens, Llama 3 on about 15.6T tokens and Qwen3 on about 36T tokens. At the same time, the role of web data has grown: RefinedWeb (Penedo et al. 2023) showed that, with sufficiently good filtering and deduplication, a model trained on web data alone can outperform models trained on carefully curated mixtures such as The Pile. In addition, new data sources and synthetic data are becoming increasingly important. For example, Qwen3 used the vision-language model Qwen2.5-VL to recognize text in a large volume of PDF-like documents, and used Qwen2.5-series models to generate trillions of tokens of synthetic data.
In summary: pretraining data is built on the web as its bulk and high-value data as its focus, and the core of the mixture is to let limited high-value data play a larger role in training.
Comparing the main data sources:
| Data source | Characteristics | Main role | Typical processing |
|---|---|---|---|
| Web pages (Common Crawl) | Largest volume, very uneven quality | Scale, diversity, long-tail knowledge | Text extraction, rule-based filtering, deduplication, quality filtering |
| Code | Structured and logically rigorous | Programming ability; also helps reasoning | License filtering, deduplication, quality filtering |
| Books, papers, encyclopedias | Well edited, high knowledge density | Knowledge, long-form writing, academic reasoning | Upsampling, attention to copyright |
| Math | Small volume, high value | Mathematical reasoning | Dedicated filtering from the web, upsampling |
| Multilingual | Data volume varies greatly across languages | Multilingual ability | Adjusting sampling proportions by language |
| Synthetic data | Controllable content and format | Supplementing scarce types of data | Mixing with real data, strict filtering |
Going deeper: GPT-3's mixture, and common open pretraining datasets
(1) GPT-3's mixture: sampling weights deliberately decoupled from data volume (Brown et al. 2020).
| Dataset | Tokens | Sampling weight | Epochs elapsed when training for 300B tokens |
|---|---|---|---|
| Common Crawl (filtered) | 410B | 60% | 0.44 |
| WebText2 | 19B | 22% | 2.9 |
| Books1 | 12B | 8% | 1.9 |
| Books2 | 55B | 8% | 0.43 |
| Wikipedia | 3B | 3% | 3.4 |
The higher-quality WebText2 and Wikipedia were repeated about 3 times, whereas the largest source, Common Crawl, was not used even once in full.
(2) Common open pretraining datasets: a shift from carefully curated mixtures to strictly filtered web corpora.
| Dataset | Size | Characteristics |
|---|---|---|
| The Pile (Gao et al. 2020) | 825 GiB | A mixture of 22 high-quality subsets, including academic papers, code and books |
| RefinedWeb (Penedo et al. 2023) | About 5T tokens, 600B released | Web only, strictly filtered and deduplicated, removing nearly 90% of documents |
| Dolma (Soldaini et al. 2024) | About 3T tokens | An open multi-source corpus used to train OLMo |
| FineWeb (Penedo et al. 2024) | 15T tokens | From 96 Common Crawl snapshots, with every processing step validated by ablation experiments |
| FineWeb-Edu (Penedo et al. 2024) | 1.3T tokens | A subset of FineWeb selected by "educational value" |
| DCLM-Baseline (Li et al. 2024) | About 3.8T tokens | Selected from a 240T-token raw pool with a fastText quality classifier |
| Nemotron-CC (Su et al. 2024) | 6.3T tokens | 4.4T real tokens plus 1.9T synthetic tokens, emphasizing keeping enough data for long training runs |
(3) Data composition in recent technical reports. DeepSeek-V3 was pretrained on 14.8T tokens, with a higher share of math and programming data than its predecessor and multilingual coverage expanded beyond English and Chinese (DeepSeek-AI 2024). Qwen3 labeled over 30T tokens along several dimensions such as educational value, domain and safety, and optimized the mixture at the instance level through ablations on small proxy models (Yang et al. 2025).
Follow-up questions
Follow-up 1: Why does code data also help non-code tasks?
Experiments show that adding code improves both reasoning and knowledge tasks. Aryabumi et al. (2024) compared pretraining with and without code and found that adding code improved natural-language reasoning by up to 8.2% relative and world knowledge by 4.2% relative, while code performance improved about 12-fold. Muennighoff et al. (2023) also found that, when data is limited, replacing up to half of the data with code did not degrade natural-language tasks. A common explanation is that code is clearly structured, logically rigorous and full of long-range dependencies, which helps the model learn multi-step reasoning, but this mechanism remains a hypothesis for now.
Follow-up 2: How is the share of multilingual data decided?
Temperature sampling is commonly used to compromise between "by data volume" and "uniform across languages". Let language \(i\) have \(n_i\) tokens and take the sampling probability \(p_i \propto n_i^{\alpha}\): with \(\alpha=1\) sampling follows data volume and English dominates overwhelmingly; with \(\alpha=0\) all languages are sampled uniformly and low-resource languages are repeated too many times. mT5 uses \(\alpha=0.3\) (Xue et al. 2020). However, when the total training volume is large, temperature sampling makes the smallest languages repeat hundreds of times, so UniMax (Chung et al. 2023) instead sets a maximum number of epochs for each language and distributes the budget as uniformly as possible under that constraint.
Follow-up 3: What compliance issues need attention when collecting pretraining data?
Mainly privacy, copyright and licensing. For privacy, personal information such as email addresses and IP addresses must be removed or anonymized; FineWeb, for example, anonymizes email addresses and public IP addresses. For copyright and licensing, websites' crawling policies and opt-out requests must be respected, and code data usually keeps only the portion whose licenses permit use. These steps reduce the amount of usable data, but they cannot be skipped.
Common mistakes
- Do not say "just use Common Crawl directly": Most raw web content is of low quality; RefinedWeb removed nearly 90% of documents during filtering and deduplication.
- Do not say the mixture is simply the natural proportion of each source: Sampling weights are deliberately decoupled from data volume, and high-value data is upsampled and repeated several times.
- Do not interpret Llama 3's "50/25/17/8" as a split by data source: It is a token proportion by content category; for example, "math and reasoning" includes web content classified into that category, not just one dedicated math dataset.
1.2 How is web data cleaned? (text extraction, language identification, rule-based filtering) ★★¶
One-sentence answer
Web cleaning is a coarse-to-fine pipeline: first extract the main text from the HTML, removing boilerplate such as navigation bars and ads; then keep the target languages with a language identification model; then apply a series of cheap heuristic rules based on document length, symbol ratios, degree of repetition, URL blocklists and so on to remove obviously low-quality content, while removing personal information. Only after that does the data enter deduplication and model-based quality filtering.
I will follow the order of the pipeline: text extraction, language identification and rule-based filtering, and finally explain why this order is used.
(1) Text extraction: the main text is pulled from raw HTML, and extraction quality directly affects model performance.
Common Crawl provides two formats: WARC files store the raw HTML, while WET files contain plain text pre-extracted by Common Crawl. WET files are convenient but retain a lot of menu, navigation and boilerplate text. FineWeb's ablations showed that re-extracting text from WARC files with a main-content extractor such as trafilatura yields clearly better models than using the WET files directly (Penedo et al. 2024). Extraction tools trade off quality against speed; for example, DCLM chose resiliparse, which is about 8 times faster than trafilatura (Li et al. 2024), while Llama 3 developed its own HTML parser (Dubey et al. 2024).
(2) Language identification: a lightweight classifier determines each document's language, so that only target languages are kept or documents are routed by language.
The common tool is the fastText language classifier, which is fast enough to process billions of documents. Each document receives a language label and a confidence score and is then filtered by a threshold; FineWeb, for example, keeps only documents whose English confidence is at least 0.65. Language identification is error-prone on short texts, mixed-language texts and low-resource languages, so the threshold involves a trade-off: too high, and valuable documents are wrongly removed; too low, and content in other languages slips in. For multilingual corpora, documents are routed to separate processing pipelines according to the identified language.
(3) Rule-based filtering: cheap statistical features remove obviously low-quality documents.
- Document-level statistics: for example, the Gopher rules (Rae et al. 2021) require a document's word count, mean word length and symbol ratios to lie within reasonable ranges, and require it to contain several common English function words, in order to remove pages that are too short, garbled, keyword-stuffed or not natural language.
- Line-level rules: for example, the C4 rules (Raffel et al. 2019) keep only lines ending in terminal punctuation such as a period, and remove lines containing "Javascript", pages containing "lorem ipsum" placeholder text and so on, in order to remove leftover navigation and boilerplate.
- Repetition rules: the fraction of repeated lines, paragraphs and n-grams within a document is computed, in order to remove template pages and spam.
- Blocklists: content such as adult websites is removed with URL blocklists, or filtered with lists of offensive words.
- Privacy and safety: personal information such as email addresses and IP addresses is removed or anonymized, and harmful content is filtered.
The pipeline is ordered "extraction → language identification → rule-based filtering → deduplication → model-based filtering" because the cost per unit of data rises at each step: rule-based filtering only counts characters and word frequencies at almost no cost; deduplication requires comparisons across documents; and model-based filtering must run a classifier on every document. By first removing most of the obvious junk with cheap steps, the later expensive steps have far less data to process, so the overall cost drops substantially.
In summary: the core idea of web cleaning is "cheap steps first, expensive steps later; remove obvious junk first, then judge the value of the content".
Going deeper: the concrete thresholds of classic rules, and how to develop new rules
(1) What the Gopher and C4 rules contain.
| Source | Rule | Typical content removed |
|---|---|---|
| Gopher (Rae et al. 2021) | Fewer than 50 or more than 100,000 words | Pages that are too short or abnormally long files |
| Gopher | Mean word length outside 3 to 10 characters | Garbled text, long identifier strings |
| Gopher | Ratio of hash symbols or ellipses to words above 0.1 | Tag stuffing, truncated summary lists |
| Gopher | More than 90% of lines starting with a bullet, or more than 30% of lines ending with an ellipsis | List pages, summary aggregation pages |
| Gopher | Fewer than 80% of words containing an alphabetic character | Numeric tables, symbol strings |
| Gopher | Fewer than 2 of "the, be, to, of, and, that, have, with" present | English pages that are not natural language |
| Gopher | Duplicate lines above 30% of lines, characters in duplicated 10-grams above 10%, etc. | Template pages, spam |
| C4 (Raffel et al. 2019) | Keep only lines that end in terminal punctuation and have at least 5 words; pages must have at least 3 sentences | Leftover navigation, button text, etc. |
| C4 | Remove lines containing "Javascript", and pages containing "lorem ipsum" or a curly bracket | Browser notices, placeholder pages, code |
| C4 | Remove pages containing any word from a list of offensive words | Adult and offensive content (with collateral damage, see Follow-up 1) |
(2) Perplexity filtering: scoring documents with a language model trained on a reference corpus. CCNet (Wenzek et al. 2019) first performs paragraph-level deduplication and fastText language identification, then computes each document's perplexity with a 5-gram KenLM language model trained on Wikipedia, and splits each language's data evenly into head, middle and tail by perplexity. A lower perplexity means the text is closer to the style of Wikipedia.
(3) How FineWeb developed new rules: find candidate rules from statistics, then validate them with ablation training.
- Finding candidate rules: over 50 document statistics were computed on two versions of the same snapshot (one deduplicated within the snapshot and one deduplicated globally, the latter training clearly worse models), and features whose distributions differed markedly between the two were taken as candidates, yielding 16 candidate rules.
- Ablation validation: 1.71B-parameter models were trained (on about 28B tokens) on the data before and after filtering, and their average scores on a set of benchmarks were compared; 3 rules were kept in the end, together removing about 22% of tokens and raising the average score by about 1 percentage point.
- Weighing data volume: C4's terminal-punctuation rule gave the largest individual improvement, but it removes about 30% of tokens, so FineWeb did not adopt it in the end.
Follow-up questions
Follow-up 1: Can rule-based filtering wrongly remove valuable content?
Yes, and the collateral damage is often systematically biased. Dodge et al. (2021) analyzed the text filtered out of C4 and found that the offensive-word blocklist disproportionately removes text from and about minority individuals. In addition, rules designed for English prose wrongly remove content such as code, mathematical formulas, poetry and lists, whose format is unusual but which is valuable. In practice, therefore, dedicated pipelines are often built for code and math; Llama 3, for example, designed separate extraction and filtering pipelines for code and reasoning data.
Follow-up 2: Given model-based quality filtering, why is rule-based filtering still needed?
Because rule-based filtering is extremely cheap and interpretable, and it handles problems that classifiers are not good at. On the one hand, removing most of the obvious junk with rules first greatly reduces the amount of data the later expensive steps must process; on the other hand, rules judge problems such as repeated lines, garbled text and overly short pages very directly, whereas classifiers are better at judging the value of content. The two are complementary.
Follow-up 3: How do you tell whether a new rule is useful?
Validate it with ablation training and manually inspect the removed samples. The standard practice is to train small models with identical settings on the data before and after filtering and compare their performance on a set of high signal-to-noise benchmarks; at the same time, one must check how much data the rule removes and whether the removed samples contain a lot of valuable content. FineWeb's decision to drop C4's terminal-punctuation rule is the result of weighing the performance gain against the data loss.
Common mistakes
- Do not say cleaning is just stripping HTML tags: Main-text extraction must identify and remove boilerplate such as navigation, ads and footers, and extraction quality itself affects model performance.
- Do not say more rules are always better: Every rule wrongly removes some valuable data; FineWeb dropped the terminal-punctuation rule, which gave the largest individual gain but removed about 30% of tokens.
- Do not conflate rule-based filtering with quality filtering: Rule-based filtering can only remove obvious junk; judging whether content is valuable requires the model-based quality filtering that comes later.
1.3 How is model-based quality filtering done? (e.g. FineWeb-Edu, DCLM classifiers) ★★¶
One-sentence answer
A lightweight classifier is trained to give each document a "quality score", and only the high-scoring part is kept. The key is how "high quality" is defined: early on, widely accepted good text such as Wikipedia and books served as positives; now it is more common to first have a strong LLM score a small sample (as FineWeb-Edu scores "educational value"), or to use instruction-style data as positives (as DCLM does), and then to distill these labels into a cheap classifier that scores all the data.
I will address this in three parts: why model-based filtering is needed, how exactly it is done, and what its risks are.
(1) Motivation: rules can only remove obvious junk and cannot judge whether content is valuable.
After rule-based filtering and deduplication, most of the remaining web pages are grammatical and well formatted, but many of them are ads, search-engine-optimization articles or pages with little substance, which do little to help the model learn knowledge and reasoning. Judging whether a document is "valuable" requires understanding its content, which is beyond what statistical rules can do. Model-based quality filtering is designed precisely for this, and in recent years it has been the single most effective step for improving data quality: for example, models trained on FineWeb-Edu clearly outperform models trained on FineWeb on knowledge and reasoning benchmarks such as MMLU and ARC (Penedo et al. 2024).
(2) Method: define labels first, then train a cheap classifier, and finally score all the data and select.
Because the data reaches trillions of tokens, it is impossible to score every document with a large model, so labels are usually constructed for only a small sample, and a cheap classifier such as fastText or "a small embedding model plus a linear layer" is trained to score all the data, which is then kept by a threshold or sampled according to the score. The three approaches differ mainly in how the labels are constructed:
- Reference corpora as positives: widely accepted good text serves as positives and random web pages as negatives. For example, GPT-3 trained a logistic-regression classifier with WebText, Wikipedia and books as positives (Brown et al. 2020), and Llama 3 trained a fastText classifier to judge whether a text "would be referenced by Wikipedia".
- LLM scores as labels: a strong LLM scores samples against some criterion, and these scores are used to train the classifier. For example, FineWeb-Edu used Llama-3-70B-Instruct to rate the "educational value" of about 460K web pages on a 0-to-5 scale, trained a regression classifier, and kept documents scoring at least 3.
- Target-task data as positives: data close to the desired capabilities is used directly as positives. For example, DCLM trained a fastText classifier with OpenHermes 2.5 instruction data and high-scoring posts from Reddit's ELI5 ("Explain Like I'm Five") forum as positives, and kept only the top 10% by score (Li et al. 2024).
(3) Risks: over-filtering hurts diversity and may shift the data toward the style of benchmarks.
The "quality" a classifier learns is just the distribution of the positives, so it inherits the positives' preferences: a classifier that favors textbook or Q&A style makes the model improve markedly on knowledge-QA benchmarks, but may lose long-tail knowledge, dialects, creative writing and similar content. In addition, strict filtering removes the vast majority of the data. Nemotron-CC (Su et al. 2024) points out that the gains of FineWeb-Edu and DCLM come at the cost of removing about 90% of the data, so in long training runs such as 15T tokens, the remaining unique data is insufficient and must be repeated heavily. A safer approach is therefore to score with an ensemble of classifiers, to bucket by score instead of applying a single hard cutoff, to keep part of the medium-quality data, and even to rewrite low-quality documents and use them rather than discarding them outright.
In summary: the essence of quality filtering is to approximate "which data is most useful for training" with a cheap model, and the definition of "useful" is determined by the positives.
Going deeper: comparing representative methods, and how soft filtering works
(1) Comparing representative methods.
| Method | Label source | Classifier | Selection | Effect |
|---|---|---|---|---|
| GPT-3 (Brown et al. 2020) | WebText, Wikipedia and books as positives, raw Common Crawl as negatives | Logistic regression | Random retention by score (soft filtering) | Used to build GPT-3's Common Crawl subset |
| FineWeb-Edu (Penedo et al. 2024) | Llama-3-70B-Instruct rates about 460K web pages from 0 to 5 | Frozen Snowflake-arctic-embed-m plus a linear regression head | Keep documents scoring at least 3, 1.3T tokens in total | 1.71B model trained on 350B tokens: MMLU from 33% to 37%, ARC from 46% to 57% |
| DCLM (Li et al. 2024) | OpenHermes 2.5 and high-scoring ELI5 posts as positives, random web pages as negatives | fastText | Keep the top 10% | 7B model trained on 2.6T tokens reaches 64% 5-shot MMLU, 6.6 points above MAP-Neo with 40% less compute |
| Nemotron-CC (Su et al. 2024) | An ensemble of three classifiers (two based on LLM scores, one being the DCLM classifier) | Scores bucketed into 20 bins, then grouped into 5 quality levels | Keep, upsample or rewrite according to level | 8B model trained on 15T tokens scores 5 points higher on MMLU than Llama 3.1 8B |
(2) DCLM's comparison of filtering methods: a simple fastText classifier works best. Under identical settings, DCLM compared PageRank, semantic deduplication, a classifier on BGE embeddings, asking an LLM whether to keep a document (AskLLM), perplexity filtering and other methods, and found that the fastText-based classifier outperformed all of them (Li et al. 2024). This suggests that the choice of positives often matters more than the sophistication of the classifier.
(3) Soft filtering: random retention by score instead of a hard cutoff. GPT-3 computes a quality score \(s\in[0,1]\) for each document, draws a number \(X\) from a Pareto (Lomax) distribution with parameter \(\alpha=9\), and keeps the document when \(X>1-s\). Since this distribution satisfies \(P(X>x)=(1+x)^{-\alpha}\), the probability that a document is kept is
Hence a document with \(s=1\) is always kept, one with \(s=0.9\) is kept with probability about 42%, and one with \(s=0.5\) only about 2.6% of the time. This favors high-quality documents while still giving low-scoring documents a small chance, thereby preserving some diversity.
Follow-up questions
Follow-up 1: Why use a small model such as fastText instead of having an LLM score all the data directly?
Because the costs differ by orders of magnitude, and a small model is already good enough for this task. Pretraining data contains billions of documents, and scoring each one with a 70B-class LLM would cost nearly as much as, or even more than, the training itself; fastText can process massive amounts of text quickly on CPUs. The usual practice is therefore to have the LLM label only a few hundred thousand samples and then distill its judgments into a small classifier. DCLM's comparison also shows that a simple fastText classifier already outperforms more sophisticated methods.
Follow-up 2: Could a quality classifier make the model good only at "gaming benchmarks"?
This risk exists and must be controlled with diverse evaluation and decontamination. A classifier that uses instruction data or educational text as positives makes the data stylistically closer to knowledge-QA benchmarks, so part of the improvement on such benchmarks may come from stylistic matching rather than purely from improved capability. Countermeasures include validating filters on a broader evaluation suite, keeping part of the diverse non-educational data, and decontaminating rigorously (see 1.7).
Follow-up 3: How do you verify that a filter is effective?
Run ablation training with small models and inspect samples across score ranges. For example, FineWeb trained 1.71B-parameter models on the data before and after filtering and compared their average scores on a set of benchmarks; in addition, documents in each score range should be spot-checked by hand to confirm that high-scoring documents are indeed valuable and low-scoring ones are indeed of poor quality.
Common mistakes
- Do not say stricter quality filtering is always better: Strict filtering removes about 90% of the data, which in long training runs leaves too little unique data and forces heavy repetition.
- Do not say the classifier judges objective "quality": The classifier only learns the distribution of the positives; with a different set of positives, the resulting "high-quality data" changes too.
- Do not equate perplexity filtering with quality filtering: A low perplexity only means the text resembles the reference corpus and is easy to predict, and repetitive template text also has very low perplexity; in DCLM's comparison, perplexity filtering was inferior to the fastText classifier.
1.4 Why deduplicate, and how are exact deduplication and approximate deduplication (MinHash/LSH) done? ★★¶
One-sentence answer
The web contains a great deal of duplicate and near-duplicate content. Deduplication saves compute, reduces verbatim memorization of training data (and the privacy and copyright risks that come with it), and prevents the data distribution from being distorted by heavily reposted content. Exact deduplication uses hashes to find identical documents, lines or substrings; approximate deduplication uses MinHash to compress each document into a short signature that estimates Jaccard similarity, then uses LSH bucketing so that only documents falling into the same bucket are compared.
I will address this in three parts: why deduplicate, how exact deduplication is done, and how approximate deduplication is done.
(1) Motivation: duplicate data wastes compute, increases memorization, distorts the data distribution, and also makes evaluation unreliable.
Duplication on the web is extremely common: the same news article is reposted by many websites, and the same templates, disclaimers and code files appear everywhere. Lee et al. (2021) found a single 61-word English sentence repeated 61,036 times in the C4 dataset. Duplicate data does harm in four ways:
- Wasted compute: the model learns the same content again and again, so the return per unit of compute declines.
- More memorization: the model is more likely to reproduce training data verbatim, with privacy and copyright risks. Lee et al. (2021) found that after deduplication, models emit memorized text about ten times less often and reach the same or better accuracy in fewer training steps.
- Distorted distribution: heavily copied content receives a disproportionately large weight in training.
- Unreliable evaluation: about 4.6% of the C4 validation set has near-duplicates in the training set, which makes validation metrics overly optimistic.
(2) Exact deduplication: hash the content, and treat identical hashes as duplicates.
- Document level: hash each whole document (usually after normalizing case, whitespace and so on) and remove identical documents; deduplication by URL is also common.
- Line or paragraph level: remove lines or paragraphs that recur throughout the corpus, which are mostly boilerplate. For example, Llama 3 removes lines appearing more than 6 times within each group of 30M documents (Dubey et al. 2024).
- Substring level: use a suffix array to find long substrings repeated in the corpus; for example, Lee et al. (2021) remove repeated substrings of at least 50 tokens.
Exact deduplication is simple and fast, but changing a single character is enough to evade it, so approximate deduplication is also needed.
(3) Approximate deduplication: estimate similarity with MinHash, then avoid pairwise comparison with LSH.
First, each document is represented as the set of n-grams it contains (for example, all spans of 5 consecutive words), and the similarity of two documents is measured by Jaccard similarity, that is, the size of the intersection of the two sets divided by the size of their union. However, the cost of comparing billions of documents pairwise grows with the square of the number of documents, which is simply infeasible. MinHash solves the problem of estimating similarity quickly: for each hash function, take the minimum hash value over all n-grams in the document; the probability that two documents share this minimum is exactly their Jaccard similarity, so with \(k\) hash functions one obtains a signature of length \(k\), and the fraction of positions where two signatures agree estimates the Jaccard similarity. LSH (locality-sensitive hashing) further solves the problem of avoiding pairwise comparison: the signature is cut into \(b\) bands of \(r\) values each, and two documents fall into the same bucket and become a candidate pair whenever any one band is identical. In this way, only highly similar documents have a high probability of becoming candidates, and the number of document pairs requiring further comparison drops sharply. Finally, mutually duplicate documents are linked into clusters, and only one document per cluster is kept.
In summary: exact deduplication catches identical content with hashes, and approximate deduplication estimates similarity with MinHash and narrows the comparison range with LSH; only by combining the two can deduplication be done at the scale of trillions of tokens.
Going deeper: why MinHash works, how to set the LSH threshold, and semantic deduplication
(1) The MinHash property: the probability that the minimum hash values agree equals the Jaccard similarity.
Let the n-gram sets of two documents be \(A\) and \(B\). Their Jaccard similarity is
Think of a random hash function as a random ordering of all n-grams. Within \(A\cup B\), the element with the smallest hash value is equally likely to be any of its elements; the minimum hash values of \(A\) and \(B\) agree if and only if this element belongs to both \(A\) and \(B\), that is, lies in \(A\cap B\). Therefore
where \(h\) is the hash function and \(\min h(A)\) is the smallest hash value over all elements of the set \(A\).
(2) The banding design of LSH: highly similar pairs almost always become candidates, and dissimilar ones almost never do.
Let the Jaccard similarity of two documents be \(s\), with the signature split into \(b\) bands of \(r\) values each. The probability that a given band is identical is \(s^r\), and the probability that all bands differ is \((1-s^r)^b\), so the probability that the two documents become a candidate pair is
This is an S-shaped curve whose steep part lies around \(s\approx(1/b)^{1/r}\). Take FineWeb's setting as an example (112 hash functions split into \(b=14\) bands of \(r=8\), targeting documents that are at least 75% similar):
| Jaccard similarity \(s\) | 0.5 | 0.6 | 0.7 | 0.75 | 0.8 | 0.9 |
|---|---|---|---|---|---|---|
| Probability of becoming a candidate pair | 5.3% | 21% | 56% | 77% | 92% | About 99.96% |
Increasing \(r\) shifts the curve to the right and reduces false positives, while increasing \(b\) shifts it to the left and reduces false negatives; a longer signature makes the curve steeper, but also raises the cost of computation and storage.
(3) Parameter settings in different works.
| Work | n-gram | Signature setting | Additional step |
|---|---|---|---|
| GPT-3 (Brown et al. 2020) | — | Spark's MinHashLSH with 10 hashes | Deduplication reduced the dataset size by about 10% |
| Lee et al. (2021) | 5-gram | 9,000 hashes, split into 450 bands of 20 | Candidate pairs are judged duplicates only if their edit similarity exceeds 0.8 |
| MassiveText (Rae et al. 2021) | 13-gram | — | Jaccard similarity threshold of 0.8 |
| FineWeb (Penedo et al. 2024) | 5-gram | 112 hashes, split into 14 bands of 8 | Deduplication within each snapshot separately |
(4) Semantic deduplication: using embeddings to find documents with the same meaning but different wording. SemDeDup (Abbas et al. 2023) first encodes each sample into an embedding with a pretrained model, clusters them with k-means, and then removes sample pairs within each cluster whose cosine similarity exceeds a threshold. On the image–text dataset LAION it removes 50% of the data with almost no loss in performance, and on C4 it yields about a 15% gain in training efficiency. D4 (Tirumala et al. 2023) builds on semantic deduplication to further select diverse samples, yielding about a 20% efficiency gain at the 6.7B scale.
Follow-up questions
Follow-up 1: Is more thorough deduplication always better?
Not necessarily; FineWeb found that global deduplication actually did not help. FineWeb initially deduplicated globally across 96 snapshots, which removed as much as 90% of the data in some of the oldest snapshots, yet training performance barely improved. Further analysis showed that in these old snapshots, the 10% of data that was kept was actually of worse quality than the 90% that was removed, full of ads and incoherent keyword lists; switching to deduplication within each snapshot separately gave clearly better results. One explanation is that content crawled many times and duplicated across snapshots tends to be of higher quality, so global deduplication effectively downweights it and relatively amplifies low-quality data. In addition, deliberately upsampling high-quality data is itself a form of controlled repetition.
Follow-up 2: How is deduplication related to decontamination?
The two use the same techniques but act on different targets. Deduplication finds duplicate content within the training data, whereas decontamination finds overlapping content between the training data and evaluation sets and removes the overlap from the training data (see 1.7). Both rely on methods such as hashing, n-gram matching or MinHash.
Follow-up 3: How is approximate deduplication actually run at the scale of trillions of tokens?
The key is that every step can be parallelized. MinHash signatures are computed independently for each document, which is fully parallel; bucketing amounts to a distributed group-by on each band of the signature (for example, a shuffle in Spark), and only documents within the same bucket need to be compared; finally, a union-find structure links the duplicate relations into clusters, and only one document per cluster is kept. For exact deduplication, memory-efficient probabilistic data structures such as Bloom filters can also be used; DCLM-Baseline, for example, was deduplicated with a Bloom filter.
Common mistakes
- Do not say MinHash measures semantic similarity: It measures the overlap of n-gram sets and cannot recognize paraphrased text; semantic deduplication requires embeddings.
- Do not say approximate deduplication is exact: MinHash with LSH is a probabilistic method with false negatives and false positives, especially near the threshold, so candidate pairs are often checked again with an exact similarity computation.
- Do not say deduplication means removing all repetition: Deliberately upsampling high-quality data is itself a form of repetition; deduplication targets the uncontrolled repetition that occurs naturally on the web.
1.5 How is the data mixture determined? (heuristics, small-scale proxy experiments, DoReMi, data-mixing laws) ★★¶
One-sentence answer
The mainstream approach is "empirical priors + small-scale experiments + extrapolation": first set rough proportions from experience, for example upsampling code, math and encyclopedias; then run ablation or annealing experiments with small models on different mixtures; and when necessary fit a data mixing law or a regression model to predict the optimal mixture at large scale. Methods such as DoReMi instead learn the weights of each domain automatically with a small proxy model.
I will address this in three parts: why the mixture is hard to determine, which methods exist, and how these methods are combined in practice.
(1) The difficulty: the effect of a mixture can only be evaluated through training, and it depends on scale and goals.
There is no directly computable relationship between a mixture and the model's capabilities; evaluating each mixture requires actually training a model, and training large models is too expensive to try mixtures one by one. To make matters worse, the optimal mixture is not fixed. Different domains interact, for example code data helps reasoning; the optimal mixture also depends on the model size and the number of training tokens, because the larger the training volume, the more easily small high-quality sources get repeated too many times; and it further depends on which capabilities we care about most. The mixture problem is therefore essentially an expensive search problem, and all methods aim to find a good-enough mixture with as little compute as possible.
(2) Methods: from empirical rules to automatic optimization, there are four common categories.
- Empirical rules: high-value data is upsampled based on experience; for example, GPT-3 had Wikipedia repeated about 3.4 times, and multilingual data commonly uses temperature sampling (see Follow-up 2 of 1.1). These methods are the cheapest and usually serve as the starting point.
- Small-scale ablation and annealing experiments: train small models on several candidate mixtures and compare their evaluation results; or take a half-trained model, run a short learning-rate anneal on a mixture that includes the candidate data, and observe how downstream metrics change. Both Llama 3 and OLMo 2 used annealing experiments to assess the value of data (Dubey et al. 2024; OLMo et al. 2024).
- DoReMi: first train a small reference model on the default mixture, then train a proxy model of the same size that, during training, dynamically raises the weights of the domains where "the proxy model's loss exceeds the reference model's by the most", and finally use the learned average weights to train the large model (Xie et al. 2023).
- Data mixing laws and regression methods: fit a functional relationship "mixture → loss" on many small-scale experiments and use it to predict the optimal mixture. For example, Ye et al. (2024) found that each domain's validation loss can be written as an exponential function of the mixture proportions; RegMix (Liu et al. 2024) trains 512 tiny models on random mixtures and then uses a regression model to predict the best mixture.
(3) Practice: the mixture is staged and multi-granular, and the evaluation of target capabilities is the final arbiter.
Real pretraining rarely uses a single fixed mixture. The usual practice is to use a broad mixture in the main phase and to raise the share of high-quality data such as math, code and reasoning in the final annealing or mid-training phase; for example, the reasoning stage (S2) of Qwen3's pretraining is a stage of about 5T tokens dominated by reasoning data. At the same time, the mixture is also adjusted during training based on monitoring; for example, Llama 3 raised the share of non-English and math data during pretraining and added more recent web data in the later stages. In addition, the granularity of the mixture is becoming finer: Qwen3 labeled over 30T tokens along multiple dimensions and ran ablations on small proxy models to optimize the mixture at the instance level rather than only at the domain level (Yang et al. 2025). Whichever method is used, the evaluation results on target capabilities must be the final criterion.
In summary: there is no universally optimal mixture; in practice, empirical priors narrow the range, small-scale experiments provide comparisons, and extrapolation methods carry the conclusions to large scale.
Going deeper: the formulas of DoReMi and the data mixing law
(1) DoReMi: minimizing the worst-case excess loss (Xie et al. 2023).
DoReMi's proxy model solves the following minimax problem:
where \(k\) is the number of domains, \(\alpha=(\alpha_1,\dots,\alpha_k)\) are the domain weights, \(\Delta^{k}\) is the set of weight vectors whose components are non-negative and sum to 1, \(\ell_i(\theta)\) is the proxy model's loss on domain \(i\), and \(\ell_i(\theta_{\text{ref}})\) is the reference model's loss on that domain; their difference is called the excess loss (computed per token and clipped at 0). The inner maximization assigns weight to the domains with the largest excess loss, that is, the domains with the most room for improvement; after training, the weights over the whole run are averaged and used as the large model's mixture. On The Pile, training an 8B model with weights learned by a 280M proxy model improved average few-shot downstream accuracy by 6.5 percentage points and reached the baseline accuracy with about 2.6 times fewer training steps.
(2) The data mixing law: validation loss is an exponential function of the mixture (Ye et al. 2024).
where \(M\) is the number of domains, \(r_j\) is the proportion of domain \(j\) in the mixture, \(L_i\) is the model's loss on the validation set of domain \(i\), and \(c_i\), \(k_i\) and \(t_{ij}\) are constants to be fitted, with \(t_{ij}\) capturing the effect of domain \(j\)'s data on domain \(i\). Fitting this function on small models and short runs, and combining it with scaling laws over training steps and model size, makes it possible to predict performance at large scale. The paper reports that optimizing the mixture for a 1B model trained on 100B tokens of RedPajama gave results comparable to training on the default mixture for 48% more steps.
(3) Key numbers for other methods.
| Method | Approach | Result |
|---|---|---|
| RegMix (Liu et al. 2024) | Train 512 models of 1M parameters on 1B tokens each with random mixtures; predict the optimal mixture with LightGBM regression, then train a 1B model (25B tokens) | Best among 64 candidate mixtures; matches or exceeds DoReMi with about 10% of the compute |
| OLMo 2's micro-annealing (OLMo et al. 2024) | Mix the candidate data 1:1 with general data and run a short learning-rate anneal | 19 runs totaling 130B tokens, less than the cost of 3 full 50B-token anneals |
| UniMax (Chung et al. 2023) | Set a maximum number of epochs for each language and distribute as uniformly as possible under that constraint | Avoids temperature sampling repeating small languages hundreds of times |
Follow-up questions
Follow-up 1: Can the optimal mixture found on small models be applied directly to large models?
Most of the time the direction is right, but there is no guarantee, and the mixture must be adjusted when the training volume changes. DataDecide (Magnusson et al. 2025) found that comparing two datasets at only the 150M scale correctly predicts the winner at the 1B scale about 80% of the time, which shows that small-scale experiments are useful but still get about 20% of cases wrong. In addition, the optimal mixture depends on the number of training tokens: large models are usually trained longer, so small high-quality sources get repeated more often, and once repetition exceeds a certain number of epochs the returns drop quickly, so their weights must be capped. Data mixing laws handle this dependence precisely by combining with scaling laws.
Follow-up 2: What does DoReMi optimize, and what are its limitations?
It optimizes the worst-case excess loss across domains, not downstream task performance. This objective keeps the model from having obvious weaknesses in any domain, which indirectly improves downstream performance; but it depends on how the domains are partitioned and on the reference model, and a lower loss in some domain does not necessarily correspond to an improvement in the capabilities we care about. Later methods have therefore more often used validation sets related to downstream tasks as the optimization target.
Follow-up 3: Should the mixture change during training?
Usually yes; modern pretraining commonly uses staged mixtures. Early on, broad data helps the model build wide-ranging knowledge; later, the share of high-quality data is raised while the learning rate decays, so that the model absorbs the best content as it "settles". However, large changes in the mixture can make the model forget capabilities learned earlier, so each adjustment is best validated first with an annealing experiment.
Common mistakes
- Do not say sampling by the natural proportion of each source is good enough: Web data would then dominate overwhelmingly, and small high-value sources would have almost no effect.
- Do not say DoReMi directly optimizes downstream tasks: It optimizes the worst-case excess loss across domains, which is only indirectly related to downstream performance.
- Do not decide the mixture with a single benchmark: Data from different domains helps different capabilities, so a broad, high signal-to-noise set of evaluations should be used.
1.6 How is synthetic data used in pretraining, and what are its risks? ★¶
One-sentence answer
There are two main uses: having a strong model generate textbooks, exercises and similar content from scratch, as in the phi series; and rephrasing existing web pages into clearer, more diverse forms, as in WRAP, Nemotron-CC and Kimi K2. The latter preserves the knowledge in real data and is therefore more common. The risks include reduced diversity, amplification of the generating model's errors and biases, model collapse from repeatedly training on generated data, and indirect evaluation contamination through the generating model.
I will address this in three parts: why synthetic data is used, how it is used, and what its risks are.
(1) Motivation: high-quality human text grows only slowly, and some types of data are especially scarce.
The total amount of public high-quality text is limited (see 1.8), and the data most helpful for reasoning, such as math solutions with detailed derivations and textbook-style explanations, is even scarcer. Synthetic data can generate these types of content on demand and control their format and style; it can also rewrite low-quality documents that would otherwise be filtered out into a usable form, thereby raising the utilization of the data.
(2) Uses: generating from scratch and rewriting existing data, mixed with real data.
- Generating from scratch: a strong model generates entirely new text along dimensions such as topic, difficulty and audience. For example, phi-1 (Gunasekar et al. 2023) has only 1.3B parameters and was trained on about 6B tokens of filtered code data plus less than 1B tokens of textbooks generated by GPT-3.5, reaching 50.6% on HumanEval. This approach effectively distills the generating model's knowledge, but the diversity of the content depends heavily on how the prompts are designed.
- Rewriting existing data: the knowledge of the original text is kept and only its form of expression changes. For example, WRAP (Maini et al. 2024) used Mistral-7B-Instruct to rewrite web pages in a Wikipedia-like style or as question–answer pairs, speeding up pretraining by about 3 times; Nemotron-CC rewrote low-quality documents in a Wikipedia-like style and generated Q&A, summaries and knowledge lists from high-quality documents, so that 1.9T of its 6.3T tokens are synthetic (Su et al. 2024); and Kimi K2 also rewrote knowledge and math data (Kimi Team 2025).
- Mixing with real data: synthetic data used alone often works poorly. Kang et al. (2025) found that training on rephrased data alone is no faster than training on natural web text, whereas mixing about 1/3 rephrased data with 2/3 natural web text, at larger data budgets, reaches the same validation loss 5 to 10 times faster; purely textbook-style synthetic data performs markedly worse.
(3) Risks: diversity, correctness, recursive training and contamination.
- Reduced diversity: generated content concentrates in the high-probability regions of the generating model, weakening long-tail knowledge and modes of expression.
- Amplified errors and biases: the generating model's hallucinations, factual errors and stylistic preferences are learned by the downstream model.
- Model collapse: Shumailov et al. (2023) found that if each generation of models is trained only on data generated by the previous generation, the tails of the real distribution disappear first and the distribution eventually degrades severely; but Gerstgrasser et al. (2024) pointed out that if synthetic data is accumulated alongside real data rather than replacing it, the error can remain bounded.
- Indirect contamination: the generating model may have seen benchmarks, so the data it generates can carry test questions into the training set in rephrased form, and this form of contamination is hard to detect with n-gram matching (see 1.7).
In summary: the most effective use of synthetic data is "rewrite real data and mix it with real data"; its value lies in raising the utilization of limited data, not in fully replacing real data.
Going deeper: why rephrasing works, and an intuitive explanation of model collapse
(1) Comparing representative works.
| Work | Approach | Key results |
|---|---|---|
| phi-1 (Gunasekar et al. 2023) | Generated textbooks plus filtered code data | 1.3B model, 50.6% on HumanEval and 55.5% on MBPP |
| WRAP (Maini et al. 2024) | Rewrites C4 in four styles (easy, Wikipedia-like, hard, Q&A) and mixes it 1:1 with real data | About 3 times faster pretraining; perplexity improved by more than 10% on average across subsets of The Pile; zero-shot accuracy on 13 QA tasks improved by more than 2% |
| Nemotron-CC (Su et al. 2024) | Rewrites low-quality documents and generates Q&A and other forms from high-quality documents | 1.9T of 6.3T tokens are synthetic |
| Kimi K2 (Kimi Team 2025) | Rewrites knowledge text with diverse styles and perspectives plus fidelity checks; rewrites math documents in a "learning-note" style | See the SimpleQA experiment below |
| Kang et al. (2025) | Systematically compares types and proportions of synthetic data | Best results with rephrased data at about 30%; generators larger than about 8B are not better |
(2) Rephrasing is a "better form of repetition". On an early checkpoint, Kimi K2 compared three ways of using the same batch of Wikipedia text, with the following SimpleQA accuracy:
| Usage | SimpleQA accuracy |
|---|---|
| Raw text repeated for 10 epochs | 23.76 |
| Rephrased once, repeated for 10 epochs | 27.39 |
| Rephrased 10 times, each version used for 1 epoch | 28.94 |
This shows that when data is insufficient, presenting the same knowledge in different forms of expression is more effective than repeating it verbatim. In the production run, however, each corpus was rephrased at most twice, to control cost and risk.
(3) Why the tails disappear first in model collapse. Let a rare event have probability \(p\) under the real distribution. When \(M\) samples are drawn from the model, the probability that the event never appears is
For example, with \(p=0.001\) and \(M=100\), this probability is about 0.905. Once an event fails to appear in the generated data, the next-generation model estimates its probability as 0 and never generates it again. Therefore, if models are trained generation after generation only on generated data, rare content disappears first and the distribution gradually narrows.
Follow-up questions
Follow-up 1: Rephrasing introduces no new knowledge, so why is it useful?
Because it makes the same knowledge more learnable. When the same fact appears several times in different styles and from different angles, the model learns it more easily and can access the learned knowledge in more ways; rephrasing into a Q&A form also brings the data closer to how the model is actually used. Kimi K2's experiment shows that rephrasing the same text 10 times and using each version once works better on SimpleQA than repeating the original 10 times.
Follow-up 2: What proportion of synthetic data is appropriate?
Current evidence suggests that moderate mixing works best and purely synthetic data works poorly. Kang et al. (2025) found the best results with rephrased data at about 30%; WRAP mixed real and synthetic data 1:1 and found that synthetic data alone was markedly worse in some domains. The exact proportion still needs to be determined by ablation experiments according to the type of data and the target capabilities.
Follow-up 3: How can the risk of model collapse be reduced?
The core is to keep real data in the training set at all times, and to verify and monitor synthetic data. Concretely: accumulate synthetic data alongside real data rather than replacing it; check generated content for fidelity and correctness; monitor the diversity of the generated data; and evaluate the model on fixed real data rather than only on data the model generated itself.
Common mistakes
- Do not say synthetic data inevitably causes model collapse: Collapse mainly arises when generated data replaces real data over multiple generations of recursive training; when accumulated and mixed with real data, the error can remain bounded.
- Do not say more synthetic data is always better: Training on synthetic data alone is no faster than natural data, and purely textbook-style synthetic data performs markedly worse.
- Do not ignore contamination introduced by the generating model: The generating model may have seen benchmarks, and its outputs can carry test questions into the training data in rephrased form.
1.7 What is data contamination, and how can it be detected and avoided? ★¶
One-sentence answer
Data contamination means that the questions or answers of an evaluation set have leaked into the training data, so that evaluation scores reflect memorization rather than true capability. With access to the training data, it can be detected through n-gram overlap and the overlapping parts removed before training; without access, it can be detected through the model's behavior, for example with Min-K% Prob, completion tests, or by comparing performance on new questions of comparable difficulty. Ways to avoid contamination include pre-training decontamination, canary strings, private test sets and continually updated dynamic evaluations.
I will address this in three parts: what contamination is, how to detect it, and how to avoid it.
(1) Definition and forms: test questions enter the training data in many forms.
The questions and answers of many benchmarks have long appeared on GitHub, forums, blogs and in paper appendices, and web crawls sweep them into the training data. Contamination takes the form not only of verbatim questions but also of rephrased or translated versions, and of synthetic data generated by a model that has seen the test set. Moreover, contamination is not limited to pretraining: SFT and RL data can also contain test questions. Its consequence is inflated scores and, more seriously, misleading research conclusions, for example making a data recipe or training method appear more effective than it is.
(2) Detection: depending on whether the training data is accessible, there are three categories of methods.
- Overlap detection based on the training data: look for documents in the training corpus that share long n-grams with test questions; for example, GPT-3 uses 13-grams (Brown et al. 2020), while Llama 3 measures, for each question, the proportion of tokens that belong to an 8-gram appearing in the pretraining corpus (Dubey et al. 2024). This presupposes access to the training data and cannot catch rephrased versions.
- Detection based on model behavior: no training data is needed. For example, Min-K% Prob (Shi et al. 2023) computes the average log-probability of the \(K\%\) lowest-probability tokens in a text, and a high score suggests the model may have seen the text; completion tests give the dataset name, the split and the first half of a question in the prompt, and check whether the model's completion of the second half closely matches the original (Golchin & Surdeanu 2023).
- Comparison on equivalent new data: construct entirely new questions of comparable difficulty and compare the model's performance on the new and old questions. For example, GSM1k (Zhang et al. 2024) wrote 1,205 new questions in the style of GSM8K and found accuracy drops of up to 8% for some models; one can also evaluate only on questions released after the model's knowledge cutoff.
(3) Avoidance: pre-training decontamination, marking, secrecy and dynamic updates.
- Pre-training decontamination: before training, remove documents that overlap with known evaluation sets from the training data; for rephrased questions, detection methods based on embeddings or LLM judgments are also needed.
- Canary strings: a special random string (such as the GUID in BIG-bench) is placed in benchmark files, so that trainers can filter out documents containing it (Srivastava et al. 2022).
- Private and dynamic test sets: keep test sets unpublished, or use benchmarks whose questions are continually updated, so that the questions do not yet exist when the model is trained.
- Publishing contamination analyses: report the contamination check for each benchmark in the technical report, so that others can judge how trustworthy the scores are.
In summary: dealing with contamination requires a three-pronged approach of "filtering beforehand, detecting afterwards, and designing evaluations carefully", and the most reliable evidence is the model's performance on new questions of comparable difficulty.
Going deeper: different approaches to n-gram detection, and how rephrasing evades detection
(1) Several approaches to n-gram overlap detection.
| Source | Granularity | Rule |
|---|---|---|
| GPT-3 (Brown et al. 2020) | Example level | Test examples with any 13-gram overlap with the pretraining data are treated as possibly contaminated; the overlapping 13-gram plus a 200-character window around it is also removed from the training data |
| Llama 2 (Touvron et al. 2023) | Token level | A token is treated as contaminated if it belongs to an n-gram longer than 10 tokens that appears in both the test example and the training set |
| Llama 3 (Dubey et al. 2024) | Example level | A question is treated as contaminated if a sufficient proportion of its tokens belong to 8-grams that appear in the pretraining corpus, with the proportion threshold set separately for each dataset |
The n-gram length involves a trade-off: too short, and common phrases are misjudged as contamination; too long, and partial overlaps are missed.
(2) Min-K% Prob: exploiting the fact that seen text rarely contains extremely low-probability tokens.
where \(x\) is the text being tested, \(p(x_i\mid x_{<i})\) is the probability the model assigns to the \(i\)-th token, and \(S_K\) is the set of the \(K\%\) lowest-probability tokens in the text. Unseen text always contains some surprising tokens with very low probability, whereas seen text rarely contains such extremely low-probability tokens, so a high score suggests the model may have seen the text (Shi et al. 2023). Min-K%++ builds on this by normalizing each token's log-probability with the mean and standard deviation of the log-probabilities over the whole vocabulary at that position, further improving detection (Zhang et al. 2024).
(3) Rephrasing easily evades n-gram detection. Yang et al. (2023) rephrased or translated the test questions of benchmarks such as MMLU and used them to fine-tune Llama-2-13B, which then reached 85.9 on MMLU, while the rephrased data passed n-gram decontamination checks. They therefore proposed an "LLM decontaminator": first use embeddings to find the training samples most similar to each test question, then have GPT-4 judge whether they are rephrasings of the same question. With this method they also found an 8% to 18% overlap with HumanEval questions in RedPajama-Data-1T and StarCoder-Data.
Follow-up questions
Follow-up 1: What are the limitations of n-gram decontamination?
There are two main ones: it cannot catch rephrasing and translation, and its thresholds are hard to set. Rephrased or translated questions share almost no long n-grams with the originals and therefore pass the check outright; and the n-gram length and overlap-proportion threshold must balance false positives against false negatives; Llama 3 notes that the 8-gram method is inadequate for datasets such as MBPP, HumanEval, MMLU and MMLU-Pro.
Follow-up 2: Besides pretraining data, which other parts of the pipeline can introduce contamination?
SFT data, RL data, synthetic data and annealing data can all introduce contamination. Post-training data is often collected from public Q&A sites and problem banks and may contain test questions directly; synthetic data is generated by models that have seen benchmarks and may contain rephrasings of test questions; and the high-quality data used in the annealing phase also needs separate checking, because it has a large influence on the final model. Decontamination should therefore cover the training data of all stages, not just the pretraining corpus.
Follow-up 3: How would you design an evaluation that is hard to contaminate?
The core idea is to make sure the questions are not yet available when the model is trained. Common practices include keeping test sets private, updating questions regularly, using only questions released after the model's knowledge cutoff, and adding canary strings to public files; in addition, one can evaluate the model on perturbed versions of the questions to check whether it truly understands them (for more discussion, see the "Inference, Evaluation and Deployment" direction).
Common mistakes
- Do not assume that passing n-gram decontamination means there is no contamination: Rephrased and translated questions can easily evade n-gram detection.
- Do not decontaminate only the pretraining data: SFT, RL and synthetic data can also contain test questions.
- Do not treat the results of behavior-based detection as conclusive evidence: Methods such as Min-K% Prob give statistical signals with false positives; more reliable evidence is the performance gap on new questions of comparable difficulty.
1.8 What can be done when high-quality data is running out? (multi-epoch repetition, synthetic data, the "data wall") ★¶
One-sentence answer
The so-called "data wall" refers to the fact that the total amount of public high-quality human text is limited and, at current growth trends, may be used up between 2026 and 2032. There are four main categories of responses: reusing high-quality data (up to about 4 epochs, the returns are close to those of new data), raising data efficiency with synthetic methods such as rephrasing, opening up new data sources such as PDFs and multilingual data, and improving training methods so that the model learns more from the same data. At the same time, the focus of scaling is also shifting toward RL and inference-time compute, which do not depend on additional human text.
I will address this in three parts: how close the data wall is, what responses exist, and how the focus of scaling is shifting.
(1) The data wall: the growth of high-quality text cannot keep up with the growth of training data.
Villalobos et al. (2022) estimate that the public human text usable for training amounts to hundreds of trillions of tokens (with a median estimate of about 320T tokens after accounting for reuse), and that at current growth trends in training data, this stock will be used up between 2026 and 2032, even earlier if models are heavily over-trained. For comparison, training data grew in five years from GPT-3's 300B tokens to Qwen3's about 36T tokens. More pressingly, after strict quality filtering the usable high-quality data shrinks by roughly another order of magnitude, because filtering often removes about 90% of the data (see 1.3).
(2) Responses: there are four main categories.
- Multi-epoch repetition: Muennighoff et al. (2023) found that when data is limited, repeating the same data for up to about 4 epochs works almost as well as fresh data; beyond that, the returns drop quickly, and by about 40 epochs additional compute is nearly worthless. The highest-quality data can therefore be prioritized for repetition.
- Synthesis and rephrasing: rephrasing presents the same knowledge in multiple forms, or rewrites low-quality documents into a usable form, raising data efficiency (see 1.6). For example, Nemotron-CC used ensemble classifiers and rephrasing to keep more unique tokens while maintaining quality, in order to support a long training run of 15T tokens.
- Opening up new data sources: for example, using vision-language models to recognize text in PDFs (Qwen3 used Qwen2.5-VL to process a large volume of PDF-like documents), and expanding the coverage of multilingual and code data.
- More efficient training methods: when data is limited but compute is plentiful, stronger regularization and ensembling can extract more information. For example, Kim et al. (2025) found that setting weight decay to about 30 times its usual value and ensembling several models reaches the same performance with about 1/5 of the data (diffusion language models also handle repeated data better than autoregressive models; see "Going deeper" for this question).
(3) The focus of scaling is shifting from "more pretraining tokens" to "more RL and inference-time compute".
RL's training data comes from the model's own samples, scored by a verifier or reward model, so its bottleneck is no longer human-written text but the supply of problems, verifiers and interactive environments; inference-time compute improves performance by letting the model think longer, without adding any training data. This is one reason the share of RL compute is rising quickly (see 0.2 in Chapter 0). However, the ceiling of RL is still bounded by the capability of the base model, so the quality of pretraining data remains the foundation of the whole system.
In summary: the data wall does not mean the end of scaling; rather, it forces data use to shift from "the more the better" to "using it better", while pushing the focus of scaling toward directions that do not depend on additional human text.
Going deeper: how the value of repeated data decays, and training methods when data is limited
(1) The effective data amount of repeated data (Muennighoff et al. 2023).
where \(U_D\) is the number of unique tokens, \(R_D\) is the number of repetitions (the number of epochs minus 1), \(D'\) is the "equivalent amount of new data", and \(R_D^{*}\approx15.4\) is a fitted constant that can be understood as the "half-life" of the value of repeated data. When \(R_D\) is much smaller than \(R_D^{*}\), \(D'\approx U_D(1+R_D)\), meaning repeated data is almost as valuable as new data; when \(R_D\) is large, \(D'\) approaches the upper bound \(U_D(1+R_D^{*})\approx16.4\,U_D\), which no amount of repetition can exceed. Computing with this formula:
| Number of epochs | 2 | 4 | 8 | 16 | 40 |
|---|---|---|---|---|---|
| Equivalent new data \(D'/U_D\) | 1.97 | 3.73 | 6.63 | 10.6 | 15.2 |
| Fraction equivalent to new data \(D'/D\) | 98% | 93% | 83% | 66% | 38% |
The paper also found that, when data is limited, replacing up to half of the data with code does not hurt natural-language tasks, and that for noisy datasets, data filtering such as perplexity filtering remains effective.
(2) Estimates of the data wall (Villalobos et al. 2022).
| Measure | Estimate |
|---|---|
| Stock of public human text, accounting for reuse | About 320T tokens (95% confidence interval 65T to 1700T) |
| Expected time of exhaustion | Between 2026 and 2032, with a median estimate of 2028 |
| If models are over-trained by a factor of 5 | The bottleneck arrives about one year earlier |
(3) Training methods when data is limited but compute is plentiful.
- Stronger regularization and ensembling: in a setting with a fixed 200M tokens of data, Kim et al. (2025) found that the optimal weight decay is about 30 times the usual value; ensembling several independently trained models further reduces the data needed for the same performance by a factor of about 5.17; and distilling the ensemble into a student 8 times smaller still retains about 83% of the gain.
- Diffusion language models: Prabhudesai et al. (2025) found that when data is scarce and compute is plentiful, masked diffusion language models outperform autoregressive models; for them, data repeated for as many as 100 epochs remains almost as valuable as new data, with a fitted \(R_D^{*}\) of about 500 compared with about 15 for autoregressive models.
Follow-up questions
Follow-up 1: What are the risks of multi-epoch training?
Diminishing returns and increased memorization. Beyond about 4 epochs, the value of each repetition drops quickly and compute is used less and less efficiently; the more repetitions, the more likely the model is to memorize training data verbatim, with privacy and copyright risks, and the validation loss may eventually start to rise. Repetition should therefore be prioritized for the highest-quality data, with the number of repetitions kept under control.
Follow-up 2: Why not simply relax the quality-filtering threshold to get more data?
This is a trade-off between quality and quantity, and the optimum depends on the total number of training tokens. When the training volume is small, the small amount of high-quality data from strict filtering is sufficient and works better; when the training volume is very large, strictly filtered data would have to be repeated too many times, and relaxing the threshold to keep more unique data works better. Nemotron-CC takes a middle path: it scores with an ensemble of classifiers and buckets by quality, keeps more medium-quality data, and rewrites low-quality data before using it.
Follow-up 3: Does the data wall mean that scaling has come to an end?
No; the focus of scaling is shifting. On the one hand, synthesis and rephrasing, new data sources and more efficient training methods can keep increasing the scale and utilization of usable data; on the other hand, RL and inference-time compute offer directions for scaling that do not depend on additional human text, and the compute that labs invest in RL is growing quickly. These directions, however, all build on a strong base model, so pretraining data remains the foundation of the whole system.
Common mistakes
- Do not say repeated data has no value at all: Up to about 4 epochs, repeated data is almost equivalent to new data.
- Do not treat "4 epochs" as a universal law: It is an empirical conclusion fitted at a particular scale and on particular data, and data quality, model size and regularization can all change it.
- Do not say the data wall means the end of scaling: The focus of scaling is shifting toward synthetic data, RL and inference-time compute.