Research reportData services

Quality filtering for language model training data: heuristics and classifiers

How pretraining data filtering works, from heuristic rules and language identification to perplexity and quality classifiers, what dataset ablations measured and what each filter takes out.

Cover of the full report: Quality filtering for language model training data: heuristics and classifiers
The research behind this article, with every source listed. 20 pages.

Key points

From the Summary of the full report

  1. Most crawled text never reaches training. RefinedWeb's pipeline removed nearly 90% of the documents originally in Common Crawl [3], and DCLM-Baseline holds 1.4% of the documents in the pool it was built from [5].
  2. Heuristic filters are hand-written rules on length, symbols, punctuation and repetition. Removing C4's rules lowered scores on every task its authors tested [1], and three rules FineWeb derived from its own crawl statistics removed about 22% of tokens and raised its aggregate score by about 1% [4].
  3. Classifier filters score each document with a trained model. In DCLM's comparison at 1 billion parameters, a fastText classifier scored 30.2 on its core benchmarks, against 29.0 for perplexity filtering, which keeps text a reference language model finds predictable, and 27.5 for a heuristic baseline [5].
  4. FineWeb-Edu kept the pages that a classifier, built from 460,000 ratings by an instruction model of the Llama 3 family, scored 3 or more for educational value [4]. A 1.71-billion-parameter model trained on it rose from 33% to 37% on MMLU and from 46% to 57% on ARC against FineWeb [4].

Pretraining data filtering decides which crawled pages a language model learns from, and most pages are dropped. Nearly 90% of the documents originally in Common Crawl were removed on the way to RefinedWeb [3], and DCLM-Baseline keeps 1.4% of the documents in its source pool [5]. The filters come in two kinds: hand-written heuristics that test length, symbols, punctuation and repetition, and trained classifiers that score each document against reference text. Published ablations measured what each kind did to the benchmark scores of models trained on the result, and the conditions go with every number.

"Quality" in these papers has no ground truth. One study counts as quality or toxic any document that triggers the classifier [10], and another argues that quality filtering "necessarily implies a value judgment" [9]. The filter ablations reviewed here trained models of up to 8 billion parameters [5, 18].

Where pretraining data filtering sits in the pipeline

Dataset papers run similar stages. RefinedWeb filters URLs against a blocklist of 4.6 million domains, extracts text, identifies the language, applies repetition and quality rules, then removes duplicates [3]. DCLM-Baseline applies an English filter, page length and repetition rules and other filters, then Bloom filter deduplication and a fastText classifier [5].

Text extraction already changes results. In DCLM's tests at 1 billion parameters, the same heuristic pipeline scored 24.1 and 24.5 on its core benchmark set with the resiliparse and trafilatura extractors, against 20.7 on Common Crawl's pre-extracted WET files [5].

Deduplication follows the rule-based stages in both pipelines [3, 5], and near-duplicate detection for training data covers how it works. Gopher's pipeline also removed documents that overlapped benchmark test sets [2], a guard against the contamination discussed in what agent benchmarks measure.

Heuristic filters: C4, the Gopher rules and FineWeb

C4 kept only lines ending in terminal punctuation and lines of at least 5 words, dropped pages with fewer than 3 sentences, and removed pages containing "lorem ipsum", a curly bracket or any word from a list of obscene words [1]. An unfiltered variant, 6.1TB against C4's 745GB, scored lower on every task its authors tested, for example GLUE 81.46 against 83.28 and SuperGLUE 68.04 against 71.36 [1].

The Gopher quality filter, written for the MassiveWeb part of MassiveText, removes documents outside 50 to 100,000 words, with a mean word length outside 3 to 10 characters, with fewer than 80% of words containing a letter, or with fewer than two of eight common English stop words [2]. Its repetition rules remove documents in which duplicate lines make up more than 30% of lines, with similar limits for paragraphs and repeated n-grams [2]. In tests on 1.4-billion-parameter models, adding these filters "dramatically improves downstream performance across the board" [2].

FineWeb tested C4's larger rules one at a time. The terminal punctuation rule gave the biggest single gain but removed about 30% of tokens, so FineWeb kept the other C4 rules it tested, for curly brackets, word length, lorem ipsum, Javascript and policy notices, and dropped that one [4]. It then compared over 50 statistics between two versions of one crawl that FineWeb treated as higher and lower quality, set thresholds where the lower-quality version was denser, and kept three new rules [4]. Together they removed about 22% of tokens and raised the aggregate score by about 1% in 28-billion-token ablations [4]. Dolma combined all the Gopher rules with C4's punctuation rule, a mix that outscored C4's full rule set and the Gopher rules alone in its tests on 1.2-billion-parameter models [11].

Language identification and perplexity filtering

Language identification makes the first large cut. After URL filtering, extraction and language identification, RefinedWeb kept 48% of documents, "mostly filtered out by language identification" [3]. Several pipelines use a fastText model that recognizes 176 languages [3, 7, 33], with different thresholds: 0.5 in CCNet [7], 0.65 in RefinedWeb and FineWeb [3, 4] and 0.3 in Nemotron-CC [18]. FineWeb2 found that no single threshold suits every language. Swahili did well around 0.3, while Arabic and Russian did better above 0.8 [20].

Perplexity filtering scores a document by how predictable a reference language model finds it. CCNet split the pages of 48 languages into head, middle and tail thirds by the perplexity of models trained on Wikipedia, then kept all three, because valid text far from Wikipedia, such as blog comments and specialized forums, landed in the tail [7]. Later studies disagree on which end to keep. One kept the quarter of its data with the lowest perplexity [23], another found that the middle of the range beat the lowest-perplexity subset [16], and a third kept high-perplexity text from the Pile and medium-perplexity text from Dolma [17].

Classifier filters: from the GPT-3 paper to FineWeb-Edu and DCLM

The GPT-3 paper trained a logistic regression classifier with curated text as positives and unfiltered Common Crawl as negatives, then kept documents through a random draw weighted toward high scores, so some low-scoring documents stayed in [6]. The Pile used the same selection rule with a fastText classifier [24]. DSIR resamples documents to match a target distribution, and with Wikipedia and books as the target it improved GLUE by 2 to 2.5% over random selection and heuristic filtering [15].

Newer classifiers learn from labels that a language model writes. FineWeb-Edu had an instruction model of the Llama 3 family rate 460,000 pages for educational value on a scale of 0 to 5, trained a classifier on the ratings and kept pages scoring 3 or more [4]. DCLM compared selection methods at 1 billion parameters [5]. A fastText classifier trained on the OH-2.5 and ELI5 reference sets scored 30.2 on its core benchmarks, against 29.0 for perplexity filtering, 28.6 for prompting a model to rate documents and 27.5 for its heuristic baseline [5]. QuRating had a model of the GPT-3.5 family compare pairs of documents on four qualities [14], and Nemotron-CC takes the maximum of three classifiers' scores and sorts documents into five quality levels [18].

What the ablations measured

Dataset or study Filter Result as reported
FineWeb-Edu [4] Educational classifier, threshold 3 MMLU 33% to 37% and ARC 46% to 57% against FineWeb, 1.71B model, 350B tokens
DCLM-Baseline [5] fastText classifier, top 10% kept 64% five-shot MMLU, 7B model, 2.6T tokens
Nemotron-CC [18] Three-classifier ensemble, plus synthetic rephrasing High-quality subset (1.1T tokens, 0.5T of them synthetic) 5.6 MMLU points above DCLM, 8B model, 1T tokens
RefinedWeb [3] Gopher rules and line corrections 1.6 points zero-shot, 3.5 with deduplication added
Perplexity pruning [17] 125M reference model Up to 2.04 points average for a 3B model

Gains were not uniform. RefinedWeb's filtering lowered one OSCAR version's score by 0.4 points while deduplication helped every dataset tested [3], and a perplexity filter on C4 helped only at 4.2 billion parameters [23].

What filters remove that teams wanted to keep

C4's word blocklist removed 42% of documents in African American English and 32% in Hispanic-aligned English, against 6.2% in White-aligned English [8]. A replication of the GPT-3 filter was more likely to rate newspapers from larger schools in wealthier, more educated and urban ZIP codes as high quality [9]. Across 28 models of 1.5 billion parameters, quality filtering raised both benchmark scores and toxic generation, and toxicity filtering cut toxic generation at a cost in generalization [10]. Nemotron-CC found that heuristic filters removed 18.1% of the tokens the FineWeb-Edu classifier rated high quality, and applies them only to the splits its own classifiers rate lower quality [18].

How much to filter

FineWeb-Edu's threshold of 3 removed 92% of its source data, and a stricter threshold raised knowledge and reasoning scores while lowering HellaSwag and PIQA [28]. DCLM found that keeping its top 10% beat keeping 15% or 20% [5]. Nemotron-CC argues that removing 90% of data limits long-horizon training, which reached 15 trillion tokens for the Llama 3.1 family, and its full 6.3-trillion-token dataset matched DCLM on MMLU with four times more unique real tokens [18]. Repetition is the other lever: up to 4 epochs of repeated data changed loss negligibly against unique data [23].

Testing a filter before trusting it

FineWeb trained two 1.71-billion-parameter models per dataset version, identical apart from their data, on about 28 billion tokens, and scored them on benchmarks chosen for low variance between runs [4]. DataDecide found that rankings from 150-million-parameter models predicted which corpus produced the better 1-billion-parameter model in about 80% of comparisons [22]. Agreement with human raters was a weak guide in DCLM: a filter at about 82% ROC-AUC against human labels produced weaker training data than fastText filters at about 73% [5].

The datatrove library returns a named reason for each failed rule and counts dropped documents per reason [31, 32]. Another curation toolkit's documentation advises analyzing score distributions before applying filters, and notes that its default logs report aggregate counts without each record's rejection reason [34]. For record matching, how entity resolution matches records describes keeping each match decision on the record.

Rillor's training data cleaning and filtering filters out records outside a client's scope, by source, date, language or type, to the rules the client sets, and the results of its checks ship with every version of the cleaned data.

Read the full report

The full report adds the thresholds each paper publishes, the ablation tables with model sizes and token budgets, the bias audits and where the sources disagree.

The full report

Quality filtering for language model training data: heuristics and classifiers

The research behind this article, with every source listed. 20 pages.

  1. Summary
  2. Background
  3. Method
  4. Findings
  5. Implications
  6. Limits of this analysis
  7. Sources

Sources

  1. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. Colin Raffel, Noam Shazeer, Adam Roberts and others, Journal of Machine Learning Research 21, arXiv:1910.10683, version 4, 19 September 2023, viewed 8 November 2026. https://arxiv.org/abs/1910.10683
  2. Scaling Language Models: Methods, Analysis & Insights from Training Gopher. Jack W. Rae, Sebastian Borgeaud, Trevor Cai and others, arXiv:2112.11446, version 2, 21 January 2022, viewed 8 November 2026. https://arxiv.org/abs/2112.11446
  3. The RefinedWeb Dataset for Falcon LLM: Outperforming Curated Corpora with Web Data, and Web Data Only. Guilherme Penedo, Quentin Malartic, Daniel Hesslow and others, arXiv:2306.01116, 1 June 2023, viewed 8 November 2026. https://arxiv.org/abs/2306.01116
  4. The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale. Guilherme Penedo, Hynek Kydlíček, Loubna Ben Allal and others, NeurIPS 2024 Datasets and Benchmarks Track, arXiv:2406.17557, version 2, 31 October 2024, viewed 8 November 2026. https://arxiv.org/abs/2406.17557
  5. DataComp-LM: In search of the next generation of training sets for language models. Jeffrey Li, Alex Fang, Georgios Smyrnis and others, arXiv:2406.11794, version 4, 21 April 2025, viewed 8 November 2026. https://arxiv.org/abs/2406.11794
  6. Language Models are Few-Shot Learners. Tom B. Brown, Benjamin Mann, Nick Ryder and others, NeurIPS 2020, arXiv:2005.14165, version 4, 22 July 2020, viewed 8 November 2026. https://arxiv.org/abs/2005.14165
  7. CCNet: Extracting High Quality Monolingual Datasets from Web Crawl Data. Guillaume Wenzek, Marie-Anne Lachaux, Alexis Conneau and others, arXiv:1911.00359, version 2, 15 November 2019, viewed 8 November 2026. https://arxiv.org/abs/1911.00359
  8. Documenting Large Webtext Corpora: A Case Study on the Colossal Clean Crawled Corpus. Jesse Dodge, Maarten Sap, Ana Marasović and others, EMNLP 2021, arXiv:2104.08758, version 2, 30 September 2021, viewed 8 November 2026. https://arxiv.org/abs/2104.08758
  9. Whose Language Counts as High Quality? Measuring Language Ideologies in Text Data Selection. Suchin Gururangan, Dallas Card, Sarah K. Dreier and others, arXiv:2201.10474, version 2, 26 January 2022, viewed 8 November 2026. https://arxiv.org/abs/2201.10474
  10. A Pretrainer's Guide to Training Data: Measuring the Effects of Data Age, Domain Coverage, Quality, & Toxicity. Shayne Longpre, Gregory Yauney, Emily Reif and others, arXiv:2305.13169, version 2, 13 November 2023, viewed 8 November 2026. https://arxiv.org/abs/2305.13169
  11. Dolma: an Open Corpus of Three Trillion Tokens for Language Model Pretraining Research. Luca Soldaini, Rodney Kinney, Akshita Bhagia and others, ACL 2024, arXiv:2402.00159, version 2, 6 June 2024, viewed 8 November 2026. https://arxiv.org/abs/2402.00159
  12. QuRating: Selecting High-Quality Data for Training Language Models. Alexander Wettig, Aatmik Gupta, Saumya Malik and Danqi Chen, ICML 2024, arXiv:2402.09739, version 3, 17 July 2024, viewed 8 November 2026. https://arxiv.org/abs/2402.09739
  13. Data Selection for Language Models via Importance Resampling. Sang Michael Xie, Shibani Santurkar, Tengyu Ma and Percy Liang, NeurIPS 2023, arXiv:2302.03169, version 3, 18 November 2023, viewed 8 November 2026. https://arxiv.org/abs/2302.03169
  14. When Less is More: Investigating Data Pruning for Pretraining LLMs at Scale. Max Marion, Ahmet Üstün, Luiza Pozzobon and others, arXiv:2309.04564, 8 September 2023, viewed 8 November 2026. https://arxiv.org/abs/2309.04564
  15. Perplexed by Perplexity: Perplexity-Based Data Pruning With Small Reference Models. Zachary Ankner, Cody Blakeney, Kartik Sreenivasan and others, arXiv:2405.20541, 30 May 2024, viewed 8 November 2026. https://arxiv.org/abs/2405.20541
  16. Nemotron-CC: Transforming Common Crawl into a Refined Long-Horizon Pretraining Dataset. Dan Su, Kezhi Kong, Ying Lin and others, ACL 2025, arXiv:2412.02595, version 2, 30 May 2025, viewed 8 November 2026. https://arxiv.org/abs/2412.02595
  17. FineWeb2: One Pipeline to Scale Them All: Adapting Pre-Training Data Processing to Every Language. Guilherme Penedo, Hynek Kydlíček, Vinko Sabolčec and others, arXiv:2506.20920, 26 June 2025, viewed 8 November 2026. https://arxiv.org/abs/2506.20920
  18. DataDecide: How to Predict Best Pretraining Data with Small Experiments. Ian Magnusson, Nguyen Tai, Ben Bogin and others, ICML 2025, arXiv:2504.11393, version 2, 13 July 2025, viewed 8 November 2026. https://arxiv.org/abs/2504.11393
  19. Scaling Data-Constrained Language Models. Niklas Muennighoff, Alexander M. Rush, Boaz Barak and others, NeurIPS 2023, arXiv:2305.16264, version 5, 28 June 2025, viewed 8 November 2026. https://arxiv.org/abs/2305.16264
  20. The Pile: An 800GB Dataset of Diverse Text for Language Modeling. Leo Gao, Stella Biderman, Sid Black and others, arXiv:2101.00027, 31 December 2020, viewed 8 November 2026. https://arxiv.org/abs/2101.00027
  21. FineWeb-Edu dataset card. Hugging Face, HuggingFaceFW/fineweb-edu, last modified 11 July 2025, viewed 8 November 2026. https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu
  22. gopher_quality_filter.py. Hugging Face, datatrove source code on GitHub, file last changed 8 August 2025, viewed 8 November 2026. https://github.com/huggingface/datatrove/blob/main/src/datatrove/pipeline/filters/gopher_quality_filter.py
  23. base_filter.py. Hugging Face, datatrove source code on GitHub, file last changed 16 March 2026, viewed 8 November 2026. https://github.com/huggingface/datatrove/blob/main/src/datatrove/pipeline/filters/base_filter.py
  24. Language identification. fastText documentation, Facebook Inc., undated, viewed 8 November 2026. https://fasttext.cc/docs/en/language-identification.html
  25. Heuristic Filtering. NeMo Curator documentation, NVIDIA, version v1.4.0, viewed 8 November 2026. https://docs.nvidia.com/nemo/curator/latest/curate-text/process-data/quality-assessment/heuristic.html

Notices

NVIDIA, AMD, Ceph, Kubernetes and related product names are trademarks of their owners and are used only to identify products. No affiliation or endorsement is implied.

Tell us what your data must cover.

Send the question the data should answer, the sources you know of, the coverage you need and how often it should update.

Outline a dataset