GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
ACL 2022

Deduplicating Training Data Makes Language Models Better

One 61-word sentence appears 61,036 times in C4. Removing near-duplicates and repeated spans cut copied text in a model's output about tenfold, with no loss in perplexity.

Breakdown by FDE Interviews · 10 min read · Updated

About the original · 2021
AUTHORS
Lee, Ippolito, Nystrom, Zhang, Eck, Callison-Burch, Carlini
FROM
Google Research, University of Pennsylvania
PUBLISHED
Jul 2021 · ACL 2022
CITED BY
1,065Semantic Scholar · Nov 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 24% of this breakdown.

01

The paper in one minute

Large language model datasets are scraped from the web, and the web repeats itself. Product pages differ only in place names and dates, the same news story is syndicated across sites with different headers, and boilerplate appears on thousands of pages. Datasets like C4 had removed exact duplicates of paragraphs or document prefixes, which misses most of this.

The paper introduces two tools. ExactSubstr concatenates the whole dataset and builds a suffix array, a sorted list of every suffix's starting position, in which repeated strings end up next to each other. Scanning adjacent entries finds every span of at least 50 tokens that occurs more than once, and all but one copy is removed. NearDup represents each document by its set of 5-grams, uses MinHash to find pairs likely to have high Jaccard similarity, confirms them with token edit similarity above 0.8, and groups matches into connected components, keeping one document per cluster.

Applied to C4, RealNews, LM1B and Wiki-40B, NearDup found near-duplicates in 3.04% of C4 training examples and 13.63% of RealNews, and ExactSubstr removed 7.18% of C4's tokens. Validation sets overlapped training: 4.6% of C4's validation examples and 14.35% of RealNews's had a near-duplicate in training. One C4 cluster held 250,933 documents.

The authors trained 1.5B-parameter models on original, NearDup and ExactSubstr versions of C4 for about two epochs. Deduplicated models matched or beat the original on held-out perplexity, scored worse on validation examples that had duplicates in training (evidence the original model had memorized them), and in 100,000 unprompted samples emitted about a tenth as much text copied verbatim from training.

THE IDEA, VISUALLY
MINHASH: WHEN DOES A PAIR BECOME A CANDIDATE? 0 0.5 1 0 0.5 1 5-gram Jaccard similarity candidate probability, b = 20, r = 450 C4 pair in Table 1: 0.30 The printed C4 flight-advert pair (edit similarity 0.85) is not a direct candidate; it can only share a cluster through other near-identical pages, since NearDup takes connected components (our calculation). ExactSubstr catches shared boilerplate inside otherwise different documents. COPIED TEXT IN UNPROMPTED OUTPUT (TABLE 4) % of generated tokens inside a 50-token span from training original C4 1 epoch 1.926% 2 epochs 1.571% NearDup 1 epoch 0.189% 2 epochs 0.264% ExactSubstr 1 epoch 0.138% 2 epochs 0.168% About 10x less copying after one epoch (10.2x, 14.0x); after two, NearDup's rate rose and the gap is 6.0x. Also: 4.6% of C4's validation set and 14.35% of RealNews's had near-duplicates in training. arXiv 2107.06499, Google Research and UPenn
Left: the two detectors. ExactSubstr builds a suffix array over the whole corpus and removes any span of 50 or more tokens that appears more than once; NearDup estimates 5-gram Jaccard similarity with MinHash (b = 20, r = 450) and confirms candidates by edit similarity above 0.8. The candidate probability is an S-curve: 30% at Jaccard 0.70, 99.5% at 0.80. Right: share of generated tokens inside a 50-token span copied from training data (Table 4): 1.926% for a model trained on original C4 against 0.189% and 0.138% for the deduplicated versions after one epoch.
Research notes: the problem, approach and results
61,036

copies of one 61-word sentence in C4's training set, plus 61 in validation (Section 1)

4.6%

of C4 validation examples with a near-duplicate in the training set; 14.35% for RealNews (Table 2)

10x

less copied text in unprompted generations after deduplication: 1.926% to 0.189% (Table 4, one epoch)

THE PROBLEM

Web-scale training sets such as C4 and RealNews were deduplicated only naively, by exact hashes of documents or paragraphs. Templated pages, mirrored articles and boilerplate leave many near-duplicates and long repeated spans, which models memorize and which leak into validation sets.

THE IDEA

Two scalable methods. ExactSubstr finds every repeated span of 50 or more tokens with a suffix array in linear time. NearDup finds near-duplicate documents with MinHash over 5-grams plus an edit-similarity check, and clusters them. Train 1.5B models on original and deduplicated C4 and compare.

THE RESULT

Near-duplicates were 3% of C4 and 14% of RealNews; 4.6% of C4's validation set had a near-duplicate in training. Models trained on deduplicated data reached the same or better perplexity, and their unprompted output contained about ten times less text copied from training data.

02

Why it matters to an FDE

Deduplicate before fine-tuning or indexing. Customer corpora are full of repeats: email threads quoting each other, templated tickets, policy documents in several versions. Duplicates overweight some content in training and crowd retrieval results with copies of the same passage.

Decontaminate evaluation sets. If 4.6% of a public validation set overlaps training, a customer's evaluation built from the same document pool will too. Run near-duplicate detection between training data and test data before trusting a score.

Less duplication means less memorized output. Text repeated many times in training is what models reproduce verbatim. When customer data contains personal or confidential text, deduplication lowers the chance that a fine-tuned model echoes it, alongside proper PII removal.

Use both kinds of detector. Exact span matching catches repeated boilerplate inside otherwise different documents; near-duplicate matching catches documents that differ by a few words. They remove overlapping but different content: 77% of what NearDup removed from C4 also had a 50-token exact match.

Tune thresholds on your data. MinHash's candidate probability is a steep S-curve around a similarity threshold. Our calculation shows the paper's own printed C4 example pair is too dissimilar to be a direct candidate at its settings; it can only be joined through other pages in the same cluster.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 290 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    Methods and parameters, how much was found, leakage, perplexity and memorization effects

    Free account
  2. 04How it works

    Suffix arrays, MinHash parameters and clustering, training and memorization measurement

    Premium
  3. 05The numbers that matter

    Removal rates, leakage, cluster sizes, perplexity, memorization, and inflated scores

    Premium
  4. 06Try it yourself

    Score the paper's duplicate pairs, plot the MinHash S-curve, run a suffix array, check Table 4

    Premium
  5. 07Where it breaks

    Threshold choices, what each detector misses, perplexity as the main measure, and slips

    Premium
  6. 08Using it on a deployment

    Dedup for fine-tuning, retrieval and evals, with thresholds tuned on labeled pairs

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →