Deduplicating Training Data Makes Language Models Better

Katherine Lee, Daphne Ippolito, Andrew Nystrom, Chiyuan Zhang, Douglas Eck, Chris Callison-Burch, Nicholas Carlini

Introduction

As natural language processing (NLP) has shifted toward massive datasets—often spanning hundreds of gigabytes to terabytes—manual curation has become impossible. These datasets, largely scraped from the open web, contain a surprising amount of repetitive content. This research demonstrates that large-scale language model datasets are riddled with duplicate and "near-duplicate" documents, leading models to memorize training data rather than generalize. By applying scalable deduplication techniques, researchers can reduce model memorization by 10x, improve training efficiency by up to 19%, and eliminate significant "train-test leakage" that artificially inflates performance metrics.

The Triple Threat of Duplication

The authors identify three major issues caused by data duplication:

  1. Memorization and Privacy: Models learn to regurgitate training sequences verbatim. If those sequences contain sensitive information, it creates a significant privacy risk.
  2. Evaluation Bias (Leakage): If a sentence appears in both the training set and the validation set, the model isn't "generalizing"—it's just remembering the answer. This leads researchers to overestimate model performance.
  3. Inefficiency: Training on the same data multiple times is a waste of compute, money, and carbon.

Scalable Deduplication Methods

The study proposes two complementary, linear-time tools for deduplication designed to handle terabyte-scale datasets like C4 on standard cloud hardware:

  • EXACTSUBSTR (Exact Substring Matching): Using a Suffix Array data structure, the authors identify any verbatim string of $k$ tokens (where $k=50$) that appears more than once across the entire dataset. When a duplicate is found, it is deleted from all but one occurrence. This surgical approach catches boilerplate text or copy-pasted paragraphs within otherwise unique articles.
  • NEARDUP (Approximate Full Document Matching): This uses MinHash, a locality-sensitive hashing (LSH) technique, to find pairs of documents with high n-gram overlap. Documents that are nearly identical (e.g., the same news story with a different timestamp) are clustered, and only one representative is kept.

Impact on Memorization

One of the most striking findings is the reduction in verbatim memorization. In standard models, over 1% of unprompted output is copied verbatim from training data. Deduplication cuts this by an order of magnitude. When prompted with the first half of a duplicated training sequence, baseline models completed it correctly 40% of the time; deduplicated models did so much less often.

Comparison of verbatim memorization across training data types.

Evaluation Bias and Dataset Leakage

The study reveals that "leakage" is a pervasive issue in modern benchmarks. In the RealNews dataset, a staggering 14.4% of the validation set was found to have near-duplicates in the training set. This means a significant portion of reported accuracy on these benchmarks is actually just the model's ability to memorize.

Percentage of duplicate examples across major NLP datasets.

Performance and Efficiency

Contrary to fears that removing data might hurt performance, deduplication often improves it. On the Wiki-40B dataset, deduplication improved perplexity by nearly 3 points—a significant jump in language modeling quality. Furthermore, deduplicating C4 made the dataset 3% to 7% smaller, while RealNews shrunk by nearly 19%. Training on this leaner, higher-quality data reached the same or better perplexity in fewer steps, reducing the financial and environmental costs of model development.

Conclusion and Limitations

While deduplication significantly improves model quality and privacy, it is not a silver bullet. Some tasks, like closed-book question answering, might require some level of memorization. Additionally, while deduplication reduces the likelihood of emitting sensitive data, it doesn't guarantee privacy for information that appears only once. Nevertheless, the study concludes that deduplication should be a standard step in the pipeline for any large-scale language model training.

Summary updated

BibTeX
@inproceedings{lee2022deduplicating,
  author = {Katherine Lee and Daphne Ippolito and Andrew Nystrom and Chiyuan Zhang and Douglas Eck and Chris Callison-Burch and Nicholas Carlini},
  title = {{Deduplicating Training Data Makes Language Models Better}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=FrojVoqlez-},
}
Figure