- Introduced by
- Andrei Z. Broder (MinHash / Resemblance theory, 1997)
- Year
- 1997
- Type
- Text preprocessing / corpus quality pipeline
What does it do?
Text deduplication is a corpus-preparation step that finds exact and near-duplicate documents in a text collection and reduces each group to a retained representative.
The near-duplicate approach described here is based on Andrei Broder's 1997 work on document resemblance, which uses MinHash to estimate Jaccard similarity between documents. It is typically applied before model training, search indexing, or any analysis that assumes documents are independent.
The intuition behind the method
Consider a web crawl in which many pages are slight rewrites of one another, differing in dates, small edits, or mirrored boilerplate. If these near-copies are treated as independent examples, a model can spend capacity on repeated text rather than on the rarer content that is the actual signal. Deduplication locates these lookalike documents and keeps one representative per group, so that later steps see a corpus in which each piece of content is counted once. The method does not judge which content is correct; it only measures how much two documents overlap.
History
Andrei Broder's 1997 paper, On the Resemblance and Containment of Documents, is the reference for the MinHash approach to estimating document resemblance used here. Lee et al. (2022), published at ACL 2022, reports that deduplicating training data makes language models better.
When to use it
Use text deduplication when a collection is likely to contain many near-identical documents, such as crawled web pages, scraped corpora, archives with mirrored content, or user-generated posts, and when that redundancy would affect the analysis. It is a sensible preprocessing step before training language models, building search indices, or running analyses that assume independent documents. Before running it, you need to choose a similarity threshold. A Jaccard value such as 0.5 is an illustrative starting point only, and the right value should be checked on sample document pairs from your corpus. For large collections, comparing every pair is generally infeasible, which is the reason for using MinHash with LSH rather than exact pairwise comparison. The benefit of LSH indexing grows with collection size. For small collections, exact pairwise comparison is feasible and may be simpler, and manual review may suffice. Do not use this approach if document order or meaning, rather than shared wording, is the property you need to preserve or compare.
Limitations and considerations
- The similarity threshold is user-defined. A threshold that is too low merges distinct documents, and one that is too high leaves near-duplicates in the corpus, so the chosen value needs to be checked against the downstream task.
- Shingle-based MinHash captures overlap in short runs of consecutive tokens, not meaning. Two documents that express the same content in different words will generally not be flagged, and documents that share boilerplate text may be flagged even when their main content differs.
- Because candidate pairs are found through LSH bands, a near-duplicate pair whose signatures never collide in any band is not compared and is not reported. The banding parameters therefore determine which duplicates can be found at all.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Scales to large collections: the LSH index avoids most all-pairs comparisons, so the number of compared pairs is usually far below the full quadratic count. The actual cost depends on the data and the band settings.
- Detects near-duplicates as well as exact copies, so documents with minor edits, reformatting, or small changes can be grouped where a byte-level hash would not match them.
- Lee et al. (2022) report that deduplicating training data makes language models better, as the title of their ACL 2022 paper states.
Applications
- Cleaning pretraining corpora for language models, where the goal is to reduce repeated content in the training data.
- Deduplicating web crawls and scraped datasets before indexing, so that search results are not dominated by mirrored pages.
- Removing redundant entries from literature archives or citation databases.
- Preprocessing user-generated text such as forum posts, reviews, or social media before sentiment analysis or topic modelling.
How it works
How it works
Each document is tokenised and split into shingles, which are short overlapping runs of consecutive tokens. The shingle length k sets what counts as shared text, so longer shingles make matches stricter. For two documents with shingle sets A and B, the Jaccard similarity is J(A,B) = |A ∩ B| / |A ∪ B|. MinHash applies n hash functions to the shingle set and keeps the minimum value for each function. The resulting length-n signature is a compact summary of the document. The fraction of hash functions for which two documents share the same minimum estimates J(A,B). More hash functions give a less noisy estimate, at higher computational cost.
The MinHash signature of length n is split into b bands of r rows each, so that n = b × r. Two documents become candidates when they agree on all r rows of at least one band. For a pair with Jaccard similarity s, the probability of becoming a candidate is 1 − (1 − s^r)^b. A larger r makes this curve steeper and reduces false candidates at lower similarity. A larger b raises the chance that a pair of a given similarity is caught. Choose b and r so that the rise of this curve falls near the similarity level you want to detect. This indexing avoids comparing every pair of documents, which is what makes the approach practical for large collections.
For each document, the LSH index returns only its candidate pairs. For each candidate pair, Jaccard similarity is estimated from the signatures, and pairs at or above the user-defined threshold are flagged as near-duplicates. Pairs that never share a band are not compared at all, so a true near-duplicate pair can be missed if its signatures happen not to collide in any band.
Flagged pairs are grouped into clusters, and one representative is kept from each cluster. Common retention policies are keeping the first copy encountered, keeping the longest copy, or keeping the copy with the highest quality score. The choice depends on the downstream task and is made by the user. Pairs with scores close to the threshold are borderline cases, so review a sample of these clusters before applying the policy to the full corpus. The output is a corpus with the redundant members removed or tagged.
Common pitfalls
- Fixing the similarity threshold without inspecting sample pairs first. The right value depends on the corpus; a threshold suited to one collection, such as web crawls, may be unsuitable for another, such as academic papers.
- Using too few hash functions in MinHash. The Jaccard estimate then becomes noisier, so pairs near the threshold are more likely to be misclassified in either direction.
- Choosing band and row settings without checking the similarity level at which candidates are likely to be found. With collision probability 1 − (1 − s^r)^b, settings that suit high-similarity duplicates can miss pairs just above the threshold.
- Running deduplication without a written resolution policy. The retain-or-discard decision for each cluster should be defined in advance, because the pipeline flags groups but does not decide which copy is correct for the downstream use.
Frequently asked questions
What is Jaccard similarity and why does it matter for deduplication?
Jaccard similarity measures the overlap between two sets; in this context, the sets are the shingles of two documents. It is defined as J(A,B) = |A ∩ B| / |A ∪ B|, the size of the intersection divided by the size of the union. Documents whose Jaccard similarity is at or above the chosen threshold are treated as near-duplicates. MinHash estimates this quantity from short signatures without comparing the full shingle sets, which is what makes large-scale comparison feasible.
How do I choose the similarity threshold?
There is no single correct value. A threshold of 0.5, meaning half of the shingles overlap, is an illustrative starting point and not a recommendation for every corpus. Inspect sample pairs at several candidate thresholds: pairs that a human reviewer considers duplicates should fall above the threshold, and distinct documents should fall below it. Adjust the value until the error rates are acceptable for your use case.
Does deduplication remove all copies or keep one?
Deduplication groups near-duplicate documents and keeps one representative per group, while the others are removed or tagged. Which copy is kept, such as the longest, the earliest, or the highest quality, is set by the resolution policy you define. The method identifies the duplicates; the retention decision depends on your task.
Is deduplication only relevant for language model training?
No. Deduplication affects any downstream analysis that assumes documents are independent, including sentiment analysis, topic modelling, information retrieval, and corpus statistics. Lee et al. (2022) reports benefits for language model training. The near-duplicate problem itself was addressed in Broder's 1997 work on resemblance, which predates that paper.
Related methods
Sources
Broder, A.Z. (1997). On the Resemblance and Containment of Documents. Compression and Complexity of SEQUENCES.
Open publication referenceLee, K. et al. (2022). Deduplicating Training Data Makes Language Models Better. ACL 2022.
Open publication reference