Every dedup method turns "is this a copy?" into a key that copies share (a hash, a band of MinHash minimums, neighbouring entries of a sorted suffix list, a nearby embedding), groups items by that key so nothing is compared pair by pair, and keeps one item per group. The key decides which copies a method can see; the scope it runs over (one file, one crawl, every crawl) decides how many it finds.
You need: the root's running example (Topic: data-curation-and-datasets): one WARC file (Common Crawl's raw archive of HTTP responses) from the July 2024 crawl CC-MAIN-2024-30, 20,991 responses, taken through a FineWeb-style datatrove pipeline (run0): 19,241 extracted documents, 2,692 filtered documents (English, passed the quality rules; this is what reaches dedup), 2,617 final. Embeddings for section 8 (Topic: rag-and-retrieval). Labels: measured on an Apple M1 Pro, CPU only, October 2026; published by the authors, with the table; derived with its formula; vendor claims by the tool's maker.
measured one WARC: the running example's 2,692 filtered documents through the four steps in this order (the Method comparer runs every combination). published web scale: Dolma 3 (allenai/dolma3 pool README), which runs exact, MinHash and suffix arrays over a whole multi-crawl pool; the semantic number is our run on 50,000 already deduplicated FineWeb-Edu rows (section 8). The gap between the two rows is the point: one file has 2.8% near-duplicate documents; the web has most of its text in copies.
New terms
| Method | Unit and test | Catches | Misses | Cost at web scale | Used by (dated) |
|---|---|---|---|---|---|
| Exact hash | a 64-bit or larger hash of each URL, document, paragraph or line; equal hash = duplicate | byte-identical copies, recrawls, menu lines | a copy with one changed date or footer | one pass, 8 to 16 bytes per item, or a Bloom filter | everyone first: Dolma 3 exact removed 67% of its pool (2025) |
| MinHash + LSH | sets of word n-grams; estimated Jaccard similarity above about 0.7 to 0.85 | near copies: templates, syndicated text, boilerplate-dominated pages | paraphrases; long shared spans inside different pages | signature of 100 to 9,000 hashes per document, a shuffle by band, union-find | GPT-3 (2020), RefinedWeb (2023), FineWeb (2024), Llama 3 (2024), Dolma 3 (2025) |
| SimHash | a 64-bit fingerprint; Hamming distance ≤ k | near-identical pages (crawler use) | most of what MinHash catches at 0.8 (section 5) | 8 bytes per document, permuted tables | Google's crawler (2007); some Chinese web corpora |
| Suffix array | every repeated substring of at least L tokens or bytes | a disclaimer or banner inside otherwise unique pages | near copies with small edits every few words | RAM about 8 to 16 bytes per text byte while building; disk 5 to 8 times the text | Lee et al. (2021), RefinedWeb (2023), Dolma 3 (2025) |
| Bloom filter | exact membership of hashed items (paragraphs, n-grams) in fixed memory | repeated paragraphs, documents mostly made of seen n-grams (DCLM) | anything not byte-identical at the item level | about 10 bits per distinct item at 1% false positives | Dolma (2024), DCLM-baseline (2024) |
| Semantic | cosine similarity of document embeddings inside k-means clusters | paraphrases, the same message in other words | nothing exact; it also removes different-but-similar pages | an encoder pass over every document (GPU), k-means | SemDeDup (2023), D4 (2023), NeMo Curator (2024 on); more in synthetic and SFT data |
"Dedup makes models better" merges three claims. The evidence is strong for the first, clear for the second and mixed for the third.
published DCLM Table 17 (1B parameters, 1x Chinchilla tokens, a 76B-token pool processed like RefinedWeb). Removal is the share of tokens removed; none is 24.7, Bloom filter 26.8 and Exact+MinHash+SA 26.8 best, Exact+MinHash 25.0. Row values checked against the pool sizes in the same table (for example 45B of 76B left = 41% removed).
| Study (scale) | What was compared | Result, from the table |
|---|---|---|
| Lee et al. 2021 (1.5B, C4) | perplexity of original vs deduplicated | only plotted (Figure 2): dedup "does not harm, and sometimes improves"; lower perplexity on LM1B and Wiki-40B; higher perplexity on validation examples that had copies in training (it no longer memorised them) |
| Pythia (2023), 12 sizes, the Pile vs a MinHash-deduplicated Pile (threshold 0.87, 207B tokens vs 300B) | zero-shot tasks, Tables 7 and 8 | "no clear benefit"; at 12B: LAMBADA 0.705 vs 0.710, WinoGrande 0.639 vs 0.660, SciQ 0.902 vs 0.929, WSC 0.548 vs 0.394, mostly within one or two standard errors; the deduplicated models ran about 1.5 epochs, so they saw repeats anyway (arXiv 2304.01373) |
| Muennighoff et al. 2023 (2.8B and 4.2B, 84B-token budget) | unfiltered vs deduplicated (any 100-character overlap removed), Table 14 average | C4: 20.9 vs 19.1 (2.8B), 22.2 vs 20.5 (4.2B), dedup worse; OSCAR (noisier): 19.4 vs 21.2, 21.4 vs 22.8, dedup better. Their text: "deduplication does not help" (Section 7) |
| FineWeb 2024 (1.71B, 350B tokens) | MinHash over all 96 crawls vs each crawl on its own | global dedup gave "little improvement"; per-crawl was better (below) |
| DCLM 2024 (1B, 76B-token pool) | 9 dedup recipes, Core score (Table 17) | the chart above |
FineWeb first deduplicated all 96 crawls together, newest crawl first, so a page that appeared in a later crawl was removed from every earlier one. That removed "as much as 90%" of the oldest crawls, and models trained on the 4T tokens left improved little over no dedup. On the oldest crawl, 2013-48:
Per-crawl MinHash gave 20T tokens and matched RefinedWeb; lighter global passes on top (URL dedup, which would remove 71.5% of tokens; line dedup 77.8%; 3-line dedup 80.9%) were all worse (Appendix E.3). FineWeb still deduplicates inside each crawl: what the experiment shows is that at this scale what survives global dedup is a biased sample, not that duplicates are good.
Nemotron-CC took the other side: it deduplicated globally and still matched DCLM, so the FineWeb finding is an interaction with the rest of a pipeline, not a law. The working rule: dedup tells you the counts; mixing decides how often each document is seen (section 10, rehydration).
Bars to scale. The about 31B tokens that survived scored worse than the about 460B tokens removed, deduplicated on their own to 171B. FineWeb's hypothesis: pages that never reappear in later crawls are disproportionately low quality, so global dedup "upsamples lower-quality data"; the gain of dedup comes from removing the huge clusters, and deduplicating clusters smaller than about 100 "can harm performance" (published FineWeb Section 3.4).
measured Inside one FineWeb shard, and what crawl-wide dedup did to our file. The root lab ran FineWeb's own MinHash (14 × 8) over FineWeb's first CC-MAIN-2024-30 shard: 969,556 rows from 353 other WARC files, plus our 2,692 filtered documents. Inside FineWeb's output, already deduplicated across the whole crawl, it still finds 370 candidate pairs, 14 of them with true Jaccard ≥ 0.8: a MinHash setting misses some pairs by chance, and FineWeb filtered and edited text after dedup. Between our file and the shard it finds 424 candidate pairs, most between 0.5 and 0.8. Of the 214 documents our pipeline kept but FineWeb dropped, 15 have a partner at ≥ 0.8 in those 353 files alone (0.4% of the crawl's 90,000), and none of the documents FineWeb kept has one: consistent with FineWeb's crawl-wide MinHash removing them, partner by partner (root lab, src/dedup/dd_fwshard.py, about 2.5 hours on 4 processes).
Measure at the scope you will deduplicate. Duplicates are pairs: a random 1% sample keeps only 0.01% of the pairs. The running example's one WARC has 2.8% near-duplicate documents; DeepSeek LLM found 22.2% inside one dump and 89.8% across 91.
The cheapest duplicates are byte-identical: the same page fetched twice, a mirrored file, the same "Home | About | Contact" line on every page of a site. Hash every unit to 64 or 128 bits, keep the first unit with each hash value, drop the rest. On one machine the "seen" set is a hash table; on many, items are routed by their hash (a shuffle: all items whose hash starts with the same bits go to the same worker), so no worker needs the whole set.
measured On run0's 19,241 extracted documents: 258 exact copies, 284 after normalising (lowercase, no punctuation, digits as 0); of 743,644 non-blank lines, 256,024 (34.4%) repeat an earlier line; the most repeated are "|", "-", "Home" and "Search". After the quality filters, exact document copies fall to 50 of 2,692, all inside MinHash's clusters (root lab).
The unit decides what you catch. Common Crawl already removes repeated URLs inside one crawl, so URL dedup only matters across crawls (Llama 3 keeps the most recent version of each URL across its whole dataset, Section 3.1.1). Document hashes catch mirrors and empty or error pages. Line and paragraph hashes catch boilerplate, and also strip structure (table separators, list markers, repeated headings).
Two different items with the same hash are a collision: the second is wrongly dropped. With n items and a b-bit hash there are n2/2 pairs, each colliding with probability 2−b (the birthday problem). Predict before you change the selects: is 64 bits enough for 1012 lines?
When it matters: always, first: it is a single pass and removes the bulk at web scale. How to check it: count items per hash and read the 50 most frequent; for a line rule, sample removed lines from pages you consider good (Llama 3's own warning, below).
derived expected colliding pairs = n(n−1)/2 · 2−b, and memory for a plain set = n × b/8 bytes (a hash table needs 1.5 to 2 times more). A 32-bit hash is unusable past a few tens of thousands of items; 64 bits is fine for documents and marginal for 1012 lines.
import hashlib, re
def h(s): # 8 bytes of SHA-1 is plenty below ~10^9 items (see the calculator)
return hashlib.sha1(s.encode("utf-8")).digest()[:8]
def norm(s): # light normalisation: case, punctuation, digits, spaces
s = re.sub(r"\d", "0", s.lower())
return " ".join(re.sub(r"[^\w\s]", " ", s).split())
seen_doc, seen_norm, seen_line = set(), set(), set()
dup_doc = dup_norm = lines = dup_lines = 0
for t in docs: # run0's 19,241 extracted documents
k = h(t); dup_doc += k in seen_doc; seen_doc.add(k)
k = h(norm(t)); dup_norm += k in seen_norm; seen_norm.add(k)
for line in t.split("\n"):
if line.strip():
lines += 1; k = h(line); dup_lines += k in seen_line; seen_line.add(k)
documents 19,241: exact copies 258, after normalising 284 non-blank lines 743,644: repeats of an earlier line 256,024 (34.4%)
measured src/scripts/snippet_exact.py (the code above plus the running example's loader). The root lab's normalisation (datatrove's simplify_text) finds 288 instead of 284.
SentenceDedup implements it (the root lab measured it: 70 of 2,692 documents dropped, 24 shortened).The problem. Most web duplicates are not byte-identical: a syndicated article with a different header, a product page that differs by one name, a forum page with a different visitor count. We want pairs whose text is mostly the same among 109 documents, without comparing 5×1017 pairs.
A concrete pair. Normalise two forum pages from the running example (lowercase, no punctuation, numbers normalised), split them into words, and take every run of 5 consecutive words, each kept once: their shingle sets share 43 of 73 distinct shingles, a Jaccard similarity of 43/73 = 0.589. "Near duplicate" means J above a threshold such as 0.75 or 0.8. (FineWeb uses 5-word shingles; Gopher 13; NeMo Curator 24 characters. Short shingles make unrelated documents look alike; long ones let one changed word break many shingles.) The figure follows what MinHash does with this pair, step by step:
measured shingles, hash values and signatures computed with datatrove 0.10.1's own MinhashDedupSignature (seed 1, the FineWeb default), checked equal to the signature it writes; hash values are shown as fractions of their range (261−1), the signature's as bar depth; text passed through the running example's PII formatter. Both pages of each pair are site chrome (forum software, a shop template, a network sign-up banner), not anyone's writing.
Pick a random hash function h over shingles and keep each document's smallest value, minh(A). Then
Proof (Broder 1997, Theorem 1): look at the smallest value over the union A ∪ B. Every shingle of the union is equally likely to own it. The two minimums are equal exactly when that shingle is in both sets, which happens for |A ∩ B| of the |A ∪ B| shingles.
With k hash functions each document becomes a signature of k minimums, and the share of positions where two signatures agree estimates J without bias. The count of agreements is binomial, so the estimate's standard deviation is √(J(1−J)/k): at J = 0.75 and FineWeb's k = 112, 0.041. Halving the noise costs four times the hashes.
measured dots: the standard deviation of the estimate for 24 real pairs, each hashed with 2,000 independent families; derived lines: √(J(1−J)/k). The binomial model holds to within a few thousandths at every k.
Signatures make each comparison cheap, but there are still too many pairs. Locality-sensitive hashing (LSH) avoids comparing pairs at all: cut the k = b×r values into b bands of r rows, and per band group documents by the band's r values (a sort or a hash table). Two documents equal on all r values of at least one band become a candidate pair.
A band matches with probability sr; all b bands fail with (1−sr)b. The curve is an S whose steep part sits near s ≈ (1/b)1/r. FineWeb's 14 × 8 gives 56%, 77%, 92%, 98.8% at 0.70, 0.75, 0.80, 0.85, the numbers its Appendix E.1 states (recomputed here).
Rows sharpen, bands widen. More rows per band make the S steeper and push it right (fewer false candidates, more misses); more bands push it left (higher recall, more candidates, more hashes). Predict, then move the target from 0.75 to 0.9 with 112 hashes: does the rule pick more bands or fewer?
Cost: signatures are documents × shingles × k multiply-adds, embarrassingly parallel; the grouping is one sort per band (a shuffle across machines); memory is k × 8 bytes per document (112 hashes: 112 GB per 109 documents of 64-bit values). How to check it: sample candidate pairs in several similarity bins and read them; compute the true Jaccard of each candidate (cheap: candidates are few); recompute the S-curve and confirm it reproduces any probabilities a paper states before copying its setting (RefinedWeb's "20 buckets of 450" does not; section 10).
The rule is datasketch's: with 128 hashes and equal weights it picks 11 × 11 for a 0.75 target and 9 × 13 for 0.8 (derived with its own code); FineWeb's 14 × 8 is not the rule's optimum for 0.75 (it sits lower, catching more). measured dots: real pairs with Jaccard ≥ 0.01 ( identical shingle sets plus with 1,024-bit equality masks from a hash family drawn with seed 2, independent of the one used to find the pairs), candidate rate per 0.05-wide bin, bands as consecutive slices; derived line and expected counts: 1−(1−sr)b summed over every pair's true Jaccard.
datasketch's MinHashLSH (v2.0.0, lsh.py:21-48) tries every b and r with b × r ≤ the number of hashes and keeps the pair that minimises wfp · (area under the S-curve left of t) + wfn · (area above it right of t), weights 0.5 and 0.5 by default. The areas treat every similarity as equally likely, which real data is not: on the web almost all pairs sit near 0, so a false-positive area that looks small still multiplies by billions of pairs. That is why the designer reports both the measured pairs and the expected candidates over all 3,622,086 pairs of the running example, and why production pipelines add a true-Jaccard check on candidates (Dolma 3) or accept a low r because candidates are cheap to verify.
Presets: published FineWeb paper Appendix E.1 and datatrove minhash.py:51-54; Dolma 3 pool README (allenai/dolma3 @ 1a9daced); NeMo Curator 1.4.0 fuzzy/workflow.py:75-83 (character 24-grams, so not directly comparable with word 5-grams); datasketch defaults lsh.py:149-151; text-dedup's Spark script defaults (tag 2023.09.20, minhash_spark.py:365-370); RefinedWeb Appendix G.3.1 read as 450 bands of 20 (the only reading that reproduces its own probabilities).
MinHash is a random estimate: a different set of hash functions gives a different signature. We took 24 real pairs from the running example, from Jaccard 0.30 to 0.96, and hashed each with 2,000 independent families of 1,024 functions (datatrove's arithmetic, seeds 1,000 to 2,999). Each family gives one estimate (the share of equal minimums) and one yes/no for "becomes a candidate".
measured dots: share of the 2,000 hash families in which the pair became a candidate (bands are consecutive slices of the signature, as datatrove's np.split); derived line: 1−(1−sr)b. 26 × 11 is Dolma 3's web setting; 20 × 5 and 9 × 13 are two other shapes for comparison.
In practice the "random functions" are a cheap family: datatrove hashes each shingle once to 64 bits (xxhash), then computes (a·x + b) mod (261−1) for 112 random pairs (a, b) in one vectorised line (minhash.py:182). Because the product is computed in unsigned 64-bit arithmetic it wraps around before the modulus, so the family is not exactly the textbook one; the measurements above (and the root lab's estimate-vs-truth chart) show it does not matter.
from datatrove.pipeline.dedup.minhash import MinhashConfig, MinhashDedupSignature
from datatrove.utils.hashing import HashConfig
import numpy as np
cfg = MinhashConfig(hash_config=HashConfig(precision=64)) # FineWeb: 5-grams, 14 bands x 8 rows, seed 1
sig = MinhashDedupSignature(output_folder="/dev/null", config=cfg)
sa, sb = sig.get_shingles(a), sig.get_shingles(b) # a, b: the two forum pages
A, B = set(sa.ravel().tolist()), set(sb.ravel().tolist())
print(f"shingles {len(A)} and {len(B)}, shared {len(A & B)}, Jaccard {len(A & B) / len(A | B):.3f}")
eq = np.concatenate(sig.get_signature(sa)) == np.concatenate(sig.get_signature(sb))
print(f"equal minimums {eq.sum()} of 112, estimate {eq.mean():.3f}")
bands = eq.reshape(14, 8).all(axis=1)
print("bands where all 8 agree:", (np.nonzero(bands)[0] + 1).tolist(), "-> candidate:", bool(bands.any()))
s = len(A & B) / len(A | B); print(f"P(candidate) at this similarity: {1 - (1 - s**8)**14:.3f}")
shingles 68 and 48, shared 43, Jaccard 0.589 equal minimums 77 of 112, estimate 0.688 bands where all 8 agree: [8] -> candidate: True P(candidate) at this similarity: 0.185
measured src/scripts/snippet_minhash.py, datatrove 0.10.1. The estimate came out 0.10 above the truth (2.1 standard deviations), one band matched, and a pair below the 0.75 target became a candidate: an 18.5% event that happened. run0 removed one of these two pages.
The problem. LSH outputs pairs, and "remove one document of every pair" is ill-defined when pairs overlap (A~B and B~C). Pipelines treat candidates as edges of a graph and keep one document per connected component (documents linked by any chain of edges).
Union-find (disjoint-set) keeps a forest: every document points to a parent, and a tree's root represents its set. find(x) follows parents to the root; union(x, y) points one root at the other. Path compression (after a find, point every node on the path straight at the root) and union by size (the smaller tree joins the larger) make each operation nearly constant time. datatrove's MinhashDedupCluster does exactly this in a Python dict (minhash.py:537-556), then removes every node that is not a root (579-583). Per band it sorts the signatures and emits only neighbouring equal pairs (minhash.py:471-480), so m identical band values give m−1 edges, not m(m−1)/2: on the running example the 14 bands wrote 810 pair records for only 94 distinct pairs; union-find gives 31 clusters and removes 75 documents. The figure replays run0's real operations on the largest cluster:
measured candidate pairs regenerated from run0's 14-band signatures the way MinhashDedupBuckets writes them, then datatrove's union-find (recursive path compression, union by size, ties to the first root) replayed operation by operation. The removed set equals run0's remove file exactly (). Only hostnames are shown. The other two large clusters behave differently: in an 8-page consent notice every member has Jaccard 0.83 with the kept page, so the check removes all 7; in the 8-page flower-shop template every member is identical, so nothing changes.
Chaining. A component can join two documents that are not similar at all, through intermediates. In the largest cluster (25 pages from 25 sites whose extracted text is one cookie-consent notice), the least similar member has Jaccard 0.60 with the kept page and the least similar two members are 0.49 apart; they joined through other banner pages and were removed. The fix: Dolma 3 computes the true Jaccard inside each cluster and removes only documents at 0.8 or more (allenai/dolma3 pool README). On the running example that check removes 65 instead of 75: the 10 that come back joined through chains. Lee et al. confirmed candidates with Jaccard and edit similarity > 0.8; RefinedWeb skipped verification to favour recall ("our main concern is improving recall", Appendix G.3.1).
Which copy survives is a choice. datatrove keeps the union-find root, whichever set won the size comparisons: on the running example the kept page is the longest member in 23 of 31 clusters and the lowest document index in 30. FineWeb describes it as "one randomly chosen document" per cluster. Llama 3 keeps the most recent version of each URL; Dolma 3 keeps the most recent copy; Zyda-2 kept the copy from the source it ranked highest (FineWeb-Edu-2, then DCLM, then Zyda-1, then Dolma-CC). A good default for web text: the most recent crawl (fresher content, working links), then the longest extraction. Keep the count: FineWeb-2 stores each kept document's cluster size, so a later step can repeat documents the web repeated (rehydration, section 10).
For each cluster: size, the spread of true Jaccard similarity between any two members (over all 31, the lowest is 0.49), and how many members a 0.8 check against the kept document would still remove.
assert world_size == 1, minhash.py:533); its example gives that task 2 CPUs with 70 GB each, 140 GB in total, and 90 hours (examples/minhash_deduplication.py:66-84). measured the same dict structure costs about 140 bytes per document that appears in any pair (tracemalloc, 106 nodes in clusters of 4), so 140 GB holds about 109 duplicated documents. A numpy parent array costs 4 to 8 bytes per document instead: scipy's connected_components labelled 107 nodes with 5×106 random edges in about 2.5 s (rough: one core, shared machine).minhash_spark.py:38-134 at tag 2023.09.20). NeMo Curator 1.4.0 runs cuGraph's multi-GPU weakly connected components (fuzzy/connected_components.py:20-21, 146).The idea (Charikar 2002; scaled by Manku, Jain and Das Sarma at Google, 2007). Give every shingle a 64-bit hash. For each bit position, count +1 for every shingle whose hash has that bit set and −1 otherwise; the fingerprint's bit is 1 where the count is positive. Similar documents share most shingles, so most counts keep their sign, and similarity is read as the Hamming distance (differing bits). Each bit is the sign of a random ±1 projection, so two documents disagree on a bit with probability close to θ/π, where cos θ = |A ∩ B| / √(|A| |B|): expected distance 64θ/π, 32 for unrelated documents, 0 for identical ones. Eight bytes per document against 896 for a 112-value MinHash signature.
measured On the running example's 2,692 filtered documents, with the same shingles MinHash uses: at Manku's k = 3, SimHash finds 147 of the 308 pairs with Jaccard ≥ 0.8 (48%), all near-identical; the 308 spread up to 16 bits, and it needs k = 8 to reach 91% (280), and makes its first candidate below Jaccard 0.5 at k = 13. Use it for near-identical detection with a tiny index (crawlers, recrawl detection) or as a cheap first pass; not for catching documents 75% to 90% the same, where MinHash's banding gives a sharp, tunable threshold. text-dedup's benchmark on the CORE dataset agrees (MinHash duplicate recall 0.94 against 0.73 for SimHash, README at commit 7538f3e), and in the Method comparer SimHash at k = 3 removes a single document that exact hashing had not already removed.
"For a repository of 8 billion pages, 64-bit simhash fingerprints and k = 3 are reasonable", with precision and recall both "near 0.75" at k = 3 on their hand-tagged sample (Manku et al., Sections 3 and 4.1). Finding all fingerprints within 3 bits without comparing pairs uses permuted tables: split the 64 bits into blocks; any two fingerprints within 3 bits agree exactly on some choice of blocks, so each table sorts the fingerprints by one choice and only fingerprints sharing it are compared (their Example 3.1: 20 tables, at most 8 fingerprints per probe; or 4 tables, up to 256K per probe). The θ/π law is exact for Gaussian projections (Charikar, Section 3).
measured The 3,602,411 pairs with no shared shingle have mean Hamming distance 31.99 and standard deviation 4.00, exactly the 32 and 4 of a coin-flip model; the closest of them is 13 bits apart. Measured Hamming distance tracks 64θ/π well at the extremes and runs above it for cosine 0.6 to 0.9 (for example 13.7 measured vs 10.7 expected at cosine 0.8 to 0.9): SimHash uses ±1 hash bits on sets of 50 to 200 shingles, where the sign of a short sum ties and flips more often (a likely reason; not tested further here). ROOTS used SimHash and saw false positives on long documents.
The problem. MinHash judges whole documents. A 600-byte disclaimer pasted into a million otherwise different pages leaves each page unique by Jaccard, yet the model reads the disclaimer a million times.
How it works. Concatenate the corpus into one string, with a unique separator after each document so no match can cross a boundary. A suffix array lists every starting position of that string, sorted by the text that follows it. Identical spans then sit next to each other in the sorted order, so one pass comparing each entry with its neighbour finds every span of length L or more that occurs at least twice anywhere, without comparing documents. The figure builds one for two tiny pages:
illustrative two invented pages; the stage computes this suffix array in the page (Sorting the suffixes puts every copy of a span next to its twin). Suffixes start at every word to keep the stack short, and suffixes that start at a separator are left out.
Lee et al. remove every repeated span of 50 or more tokens: their plot of matches against length bends at about 10 tokens, and reading matches of 25 tokens found no false positives, so they doubled it (Appendix B). On raw text that is about 50 × 4.68 = 234 bytes on the running example (4.68 bytes per GPT-2 token, measured); RefinedWeb used 50 tokens after MinHash, Dolma 3 used 500 bytes. measured on the 2,692 filtered documents: bytes at 230 mark 2.50% of the text (146 documents touched); tokens at 50 mark 2.36% (144 documents, all among the 146).
self-similar output lists every occurrence of a repeated span, the first included (main.rs:900-922), so deleting the ranges deletes the text everywhere. Keeping one copy (Dolma 3: "we ensure we keep at least one copy") removes 1.08% instead of 2.50% here. Keep one if the span is content (a quote, a licence you want once); remove all if it is boilerplate. Lee et al. also ran the whole process twice, because cutting spans creates new repeats across the cut points (README line 246).FineWeb's output, already deduplicated per crawl, still has 0.30% of its text in repeated spans of 230 bytes within its first 4,000 rows, 0.46% within 16,000 and 0.55% within 48,000 (more WARC files, more chances for a shared disclaimer). The curated corpora sit low at equal sample size (16,000 documents): FineWeb-Edu 0.21%, DCLM-baseline 0.18%, Nemotron-CC high 0.08%, against 2.50% in the running example before MinHash. A sample this small says little about a whole corpus (DCLM-baseline is 85% duplicates by a global MinHash); it says that a random slice of these corpora carries little boilerplate.
When it matters: after MinHash, for boilerplate inside unique pages (cookie text, legal footers, shop policies); RefinedWeb, Nemotron-CC and Dolma 3 use it, FineWeb and DCLM do not. DCLM's Table 17 found suffix arrays alone the strongest single step at 1B scale (26.6 Core, 33% removed). Cost: RAM 7 to 15 bytes per text byte while building, so it runs per shard at web scale (Nemotron-CC "over eighths of snapshots", Dolma 3 on 56 shards). How to check it: read the 50 longest and the 50 most repeated spans, and count documents left with almost nothing (the tool can empty a page that was all boilerplate).
Sorting n suffixes naively costs O(n log n) comparisons of long strings. SA-IS (Nong, Zhang and Chan, 2009) builds the array in linear time: it classifies each position as S-type or L-type (is its suffix smaller or larger than the next one), sorts only a subset of "LMS" substrings (at most half the positions), recursively solves the smaller problem, and induces the order of every other suffix from those in two linear scans. Google's deduplicate-text-datasets (Lee et al.'s tool) vendors an SA-IS implementation with 64-bit indices (src/table.rs:52-62, 115, 391-511 at 4e9888ac). For files larger than memory allows, scripts/make_suffix_array.py builds arrays of chunks in parallel and merges them with a heap; chunks overlap by HACK = 100000 bytes (line 23), so the merge is only correct when no repeated span is longer than that, which holds for documents of normal length. The root's Dedup lab builds a small suffix array live in the browser.
Tokens or bytes. With --tokenize the tool stores GPT-2 token ids as 2 bytes each, so 50 tokens is a threshold of 100 bytes. On the running example the share cut per document by the two forms correlates at 0.997. One quirk: the tool compares bytes, so in token mode a match can start in the middle of a 2-byte token id; 18 of 216 ranges did. Use an even threshold and align ranges to token boundaries when you cut.
make, low priority): building the array for 13 MB, 54 MB and 162 MB of FineWeb text took about 7 s, 47 s and 310 s, with peak memory 15, 11 and 7 bytes per text byte, and an array file of 3 to 4 bytes per text byte (the tool stores the smallest pointer width that addresses the file: 5 bytes at about a terabyte, 6 at hundreds of terabytes).The problem. Exact dedup of paragraphs or n-grams across a corpus needs a "seen" set of 1011 to 1013 items: at 8 bytes each, terabytes.
How it works. A Bloom filter is an array of m bits and k hash functions. Adding an item sets its k bits; testing checks whether all k are set. It never misses an item it has seen, but can say "seen" for a new item whose bits were all set by others, a false positive. The figure adds two lines and tests a third:
illustrative 16 bits and 3 hash functions with made-up hash values (two lines fill the bits a third line needs: a false positive); a real filter fills to about half its bits set at the best k.
After n items the false-positive rate is about (1−e−kn/m)k. The best k is (m/n) ln 2, which gives m/n = −ln p / (ln 2)2 bits per item for a target rate p: 9.6 bits at 1%, 14.4 at 0.1%, 57.5 at 10−12 (derived). In dedup a false positive drops one unique item, which is acceptable at 1%. The root lab checked the Dolma toolkit's filter against this formula (closed block below). How to check it: run the filter on a sample where a plain Python set gives the true answer and count the difference; log the fill ratio at the end of each shard.
DCLM-baseline was deduplicated with a modified "Big Friendly Filter": cut each paragraph into 13-grams and test every 13-gram against one filter holding all 13-grams seen so far. A paragraph is removed when more than 80% of its 13-grams were seen; a document when more than 80% of all its 13-grams were (published DCLM Appendix L; false-positive rate 0.01). Unlike MinHash it compares a document with the whole corpus seen so far, in one streaming pass. Memory decides the scope: the DCLM pool was about 70 TB, so they ran 100 shards of about 700 GB each, deduplicating within each shard only, and the shard size changes the answer:
Quality was not hurt: at 7B parameters and 2x tokens, the Bloom filter and MinHash plus suffix array scored within 0.2 Core points of each other (45.3 vs 45.5, Table 19), and the Bloom filter is "vastly more efficient" than a MinHash and suffix-array pipeline.
published DCLM Table 22: share of tokens the BFF removes against shard size (bar length = share removed, axis to 50%). Consistent with a global MinHash still removing 85% of DCLM-baseline (Table 23).
--dedupe.min_words above 0 silently turns paragraph dedup off in dolma 1.2.1 (deduper.rs:339-353).The problem. Two pages can say the same thing in different words and share no 5-word phrase: Jaccard near 0. Paraphrase-level redundancy is common in synthetic data, instruction sets and spam.
How it works. An encoder (a model that maps a text to a vector so that texts with similar meaning land close together) embeds every document. Comparing all pairs is again quadratic, so SemDeDup (Abbas et al. 2023) first clusters the vectors with k-means, then inside each cluster removes a document whose cosine similarity to a kept one is at least 1−ε. NeMo Curator 1.4.0 runs this on GPUs with embeddinggemma-300m, 100 clusters and ε = 0.01 by default, keeping the members farthest from the centroid first ("hard"; stages/text/deduplication/semantic.py:80-92). D4 (Tirumala et al. 2023) adds a second step: k-means again and drop the documents closest to their centroid, the most typical ones, until a target size.
measured Does the encoder matter? The 2,692 filtered documents embedded with three encoders on CPU (4 threads, low priority): arctic-embed-m (the FineWeb-Edu classifier's backbone, root lab), bge-small-en-v1.5 (440 s) and all-MiniLM-L6-v2 (100 s), then SemDeDup with 20 k-means clusters.
Published results are modest (closed block below): no loss on LAION at 37% removed, a perplexity match for C4 with less data, small downstream gains for D4 at 6.7B, and no gain as DCLM's selection step. When it matters: synthetic and instruction data, after exact and MinHash dedup. Cost: an encoder pass over every document plus k-means. How to check it: read the removed pairs at the chosen ε, especially pairs with low Jaccard: on this file they are cookie notices from different plugins and casino spam (root lab), but at looser ε real pages start to go.
measured After SemDeDup (ε 0.05, 2,630 left), keeping 80% by D4's rule prunes the 476 most typical documents: median length 1,057 characters against 2,156 for those kept, median FineWeb-Edu score 0.62 against 1.10, and only 19 of the 159 documents scoring ≥ 2.5 (FineWeb-Edu's keep line).
measured At 50,000 documents (FineWeb-Edu, CC-MAIN-2024-30, random row groups), on the GPU. With arctic-embed-m and 100 clusters, SemDeDup removes 3 documents at ε 0.01 (NeMo Curator's default), 96 at 0.05, 302 at 0.1 and 866 at 0.15: an already deduplicated, quality-filtered set has little paraphrase redundancy until ε gets loose. Keeping 80%, the pruned documents have a slightly higher median FineWeb-Edu score than the kept ones (3.02 vs 2.91), and keeping 40% prunes 14,560 of the 21,939 documents scoring ≥ 3. Run with sh src/scripts/run_pending.sh d4-fwedu50k.
At 109 to 1010 documents every method is a distributed job, and its design is decided by which state must sit in one machine's memory. A distributed MinHash job has four stages:
minhash.py:391-399).Predict which state outgrows a machine first at 1010 documents, then set the corpus:
The rough numbers measured here (seconds on a laptop core for megabytes) do not extrapolate linearly: at scale the cost is dominated by I/O and the shuffle, which a single machine never shows. No FineWeb, RefinedWeb or DCLM paper gives a CPU-hour figure for its MinHash step.
derived from the formulas in each row; per-item sizes measured here where marked. Compute is not shown: MinHash signatures are documents × shingles × hashes multiply-adds and parallelise perfectly; an encoder pass is the dominant cost of semantic dedup.
| Job | Hardware and time | Source |
|---|---|---|
| Suffix array of C4 (350 GB) | 1 VM, 96 cores, 768 GB RAM: under 12 h (about 1,000 CPU-hours); dedup under 1 h more | Lee et al. 2021, App. B published |
| NearDup MinHash on C4 | Google's production system, about 41.5 kWh | Lee et al. 2021, App. A published |
| CCNet paragraph dedup (one crawl) | hashes of 50 shards (3% of a crawl): 1.5B hashes in 40 GB RAM; the whole CCNet pipeline 8.5 h per crawl on 5,000 cores | Wenzek et al. 2019 published |
| SlimPajama: global MinHash over RedPajama (1.2T tokens) | 64 CPU cores, 1.4 TB peak memory; 49.6% of bytes removed | Shen et al. 2023 published |
| text-dedup Spark MinHash, 42M rows | 160 cores, 640 GB: under 40 min (the Python version: about 10 h on 80 cores, 1.8 TB) | README, tag 2023.09.20 published |
| TxT360: 48.83B documents, 99 crawls | exact (Bloom, capacity 109, 0.1%) removed 17%; MinHash 9 × 13 on 13-grams: 20 TB of hashes, 9.2 TB of pairs, pair dedup about 5 days in parallel (25 days serial) | TxT360 blog (Oct 2024) published |
| DCLM-baseline BFF (about 70 TB) | 100 shards of about 700 GB, single-node Rust tool; AWS i4i instances recommended | DCLM App. L; dclm dedup README published |
| NeMo Curator fuzzy dedup, RedPajama v2 subset | 3 H100 nodes 0.65 h vs a CPU alternative 10.7 h (about 16x); 1, 2, 4 H100 nodes: 2.05, 1.01, 0.50 h on "8 TB (1.78 trillion tokens)"; another page: "1.96 trillion tokens in 0.5 hours using 32 NVIDIA H100 GPUs" | NeMo Curator 1.4.0 README and docs vendor, figures disagree with each other |
| NeMo Curator, RedPajama (4.5 TB), 2023 | 37 h on 20 CPU nodes (48 cores) vs 3 h on 4 DGX A100 | NVIDIA blog, Aug 2023 vendor |
| Zyda-2 (12B documents, 11.5T tokens; filtering and dedup together) | about 2 days on 8 GPU nodes vs about 3 weeks on 8 CPU nodes | Zyphra blog, Oct 2024 vendor-adjacent (co-published with NVIDIA) |
What production corpora do. Almost every recipe runs exact dedup first and MinHash second; they differ in scope, in whether candidates are verified, and in which copy survives. FineWeb runs MinHash 14 × 8 inside each crawl with no verification; Dolma 3 runs MinHash 26 × 11 over 32 shards, checks true Jaccard 0.8 inside clusters, keeps the newest copy, then a keep-one suffix array; DCLM-baseline uses only a Bloom-filter BFF within 100 shards; TxT360 and Llama 3 deduplicate globally. The full table, with sources, is below.
| Corpus (date) | Exact | Fuzzy | Substring / other | Scope, kept copy, removed |
|---|---|---|---|---|
| C4 (2019) | every repeated 3-sentence span | one crawl | ||
| GPT-3 (2020) | Spark MinHashLSH, 10 hashes | within each dataset; about 10% smaller | ||
| The Pile (2020) | datasketch MinHashLSH, 10 hashes, Jaccard 0.5 | within Pile-CC (26% duplicates) and OpenWebText2 (28%) only, "due to memory constraints" | ||
| Gopher / MassiveText (2021) | documents | MinHash, 13-grams, Jaccard > 0.8, one removed at random | plus within-document repetition rules (Table A1) | all subsets except Wikipedia and GitHub |
| Llama 1 (2023) | CCNet lines; GitHub files | books with > 90% overlap | per crawl | |
| RefinedWeb (2023) | URL across 100 parts | MinHash 5-grams, 9,000 hashes, 450 bands of 20, no verification | suffix array, spans > 50 tokens | each 1/100 of every crawl; 12% of documents removed as duplicates |
| SlimPajama (2023) | MinHashLSH, 13-grams, Jaccard 0.8 | global over RedPajama; 49.6% of bytes removed | ||
| RedPajama v2 (2023) | Bloom filter, 1% error | signatures shipped for 0.7 to 1.0 (128 hashes: 14 × 9, 9 × 13, 5 × 25, 1 × 128) | newest crawl first; fuzzy left to the user | |
| DeepSeek LLM (2024) | method not named; 91 dumps together removed 89.8% of documents vs 22.2% within one dump (Table 1) | global | ||
| Dolma v1 (2024) | URL 53.2%, document 14.9%, paragraph 18.7% (Bloom) | CCNet paragraphs first | per crawl, then whole corpus | |
| DCLM-baseline (2024) | BFF: 13-grams, 0.8 of a paragraph or document seen | 100 shards of about 700 GB | ||
| FineWeb (2024) | MinHash 5-grams, 14 × 8, no verification | each crawl alone; one document per cluster | ||
| Llama 3 (2024) | URL, newest kept | global MinHash (parameters not given) | lines seen > 6 times per 30M documents | global |
| Nemotron-CC (2024) | global fuzzy, NeMo Curator (parameters not given) | suffix array over eighths of crawls | 99 crawls, global | |
| TxT360 (2024) | Bloom, 17% | MinHash 13-grams, 9 × 13, Jaccard 0.8 | 99 crawls global; duplicate counts kept for upsampling | |
| Zyda-2 (2024) | NeMo Curator, character 25-grams, 128 hashes, 8 bands | across its 4 sources only; best-ranked source kept | ||
| FineWeb-2 (2025) | MinHash as FineWeb (14 × 8), per language | global per language, before filtering; cluster size kept | ||
| Dolma 3 (2025) | 67% of the pool | MinHash 5-grams, 26 × 11, true Jaccard 0.8 inside clusters, newest kept; 23% | suffix array, spans ≥ 500 bytes, keep one; 14% of text | 32 shards for MinHash, 56 for suffix arrays |
published sources: C4 (Raffel et al. 2020), GPT-3 App. A, the Pile App. D.2, Gopher App. A.1.1, Llama 1 Section 2.1, RefinedWeb Section 3.3 and App. G, SlimPajama-DC Section 2.3, RedPajama v2 (Weber et al. 2024, Section 4.1, and the RedPajama-Data README), DeepSeek LLM Section 2.1, Dolma Sections 5.1 and 5.4, DCLM App. L, FineWeb Section 3.4, Llama 3 Section 3.1.1, Nemotron-CC Section 2, TxT360 blog, Zyda-2 blog, FineWeb-2 Sections 4.3 and 4.5, allenai/dolma3 pool README (1a9daced). Empty cells: not stated by the source. Qwen2, 2.5 and 3 reports do not describe their dedup. The Pretraining corpora page has each corpus's lineage, size and licence.
TxT360 deduplicated 99 crawls globally and kept each document's duplicate count, then upsampled heuristically: weight 3 for 2 to 5 copies, 5 for 5 to 100, 8 for 101 to 1,000, 10 above 1,000. FineWeb-2 made it data-driven: per language, measure the filtering rate of documents by cluster size (as a quality proxy), give weight 10 to the cluster size the filters remove least, weight 1 to sizes removed more often than average, and interpolate; for French the curve is U-shaped, with both unique documents and the most repeated 0.1% filtered more than average (FineWeb-2 Section 4.5). Its card warns: "If you do not upsample based on these weights, dataset performance may be lower." The data mixing page covers repetition budgets.
Contamination means benchmark items in the training data; the decontamination page owns detection and removal. Within-corpus dedup keeps one copy of every test item it finds, by design; removing benchmark text needs a dedup across two sets, the training corpus against the evaluation sets, with the same machinery (datatrove's MinHash against a prebuilt index, index_folder; Google's tool's across-similar; Dolma seeds its Bloom filter with test items). What dedup does buy: fewer copies, less memorisation of whatever leaked (Kandpal et al.: generation rate grows super-linearly with copies).
Lee et al. found near-duplicates in the training set for 4.6% of C4's validation examples, 14.35% of RealNews', 4.92% of LM1B's and 0.72% of Wiki-40B's (Table 2). A published Transformer-XL trained on LM1B has perplexity 10.11 on LM1B validation examples that have training copies against 23.58 on the rest; GROVER-XL on RealNews, 7.68 against 9.45 (Table 5). Their policy: keep the test copy, drop the training copy. No source measures a percentage reduction in benchmark contamination from dedup alone (searched; not confirmed). The decontamination page measured the running example and whole FineWeb shards directly against seven benchmarks.
Scripts and outputs: src/scripts/ and src/data/out/ of this page, plus the root lab's src/dedup/.
The same 2,692 documents (run0 after language ID and quality filters, the input of its MinHash step) through any combination of four dedup steps, in the order production pipelines run them: exact hashes, then a fuzzy method, then semantic dedup, then exact substrings. Every step runs on the survivors of the previous ones; every number is a real run on this Mac.
measured each square is one document, in WARC order. Exact: SHA-1 of the UTF-8 text, first copy kept. MinHash: datatrove's 14 × 8 signatures, candidate pairs and union-find exactly as run0 (root kept). The check removes a member only if its true Jaccard with the root is at least 0.8 (Dolma 3's README). SimHash: 64-bit fingerprints of the same 5-word shingles, Hamming distance ≤ 3, lowest index kept. SemDeDup: arctic-embed-m [CLS] vectors (512 tokens), 20 k-means clusters fitted on the survivors, NeMo Curator's "hard" ranking. Suffix array: Google's deduplicate-text-datasets (4e9888ac) on the survivors at 230 bytes (about 50 GPT-2 tokens at the 4.68 bytes per token measured on these documents); "remove every copy" is what the tool's ranges mean, "keep one" leaves the first occurrence.
Documents and bytes left after all steps, for each exact and fuzzy choice (columns: semantic off, ε 0.05, ε 0.1) with the suffix-array setting chosen above.
The root: the whole pipeline at overview depth. Its Dedup lab tab runs every method once on the running example (32 min); its Pipeline lab shows the stages before dedup. Reading: 35 min, plus 6.
Detecting benchmark items in training data, measured on the same samples (38 min, plus 21).
Lineage of the corpora in section 10, their sizes and licences (31 min, plus 15).
Extraction decides how much boilerplate dedup sees (32 min, plus 25).
Selection by quality, the other half of D4's argument (42 min, plus 13).
Repetition budgets and epochs: where rehydration weights go (45 min, plus 23).
Where semantic dedup matters most (42 min, plus 13).
Shards and formats the dedup jobs read and write (34 min, plus 5).
Embedding models and nearest-neighbour search, the machinery of semantic dedup (21 min).
NearDup and ExactSubstr, the memorisation tables; Appendix B for suffix-array costs (60 min).
Memorisation grows super-linearly with copies (30 min).
Three log-linear laws; Section 5.2 on deduplicated models (40 min).
Why a few heavily repeated items hurt (40 min).
Section 3.4 and Appendix E: per-crawl vs global dedup (30 min for those parts).
Appendix L: BFF, Tables 17 to 23 on dedup methods and shards (40 min).
Semantic dedup on LAION and C4 (40 min).
SemDeDup plus prototype pruning, and repeating selected data (45 min).
Where min-hashing comes from; 9 pages (30 min).
SimHash at 8 billion pages and the permuted-table index (40 min).
Section 4.5: rehydration weights from cluster sizes (20 min).
The four MinHash stages FineWeb ran; 700 lines (40 min).
The suffix-array tool; the README walks through a full run (30 min).
MinHashLSH and the (b, r) rule the Band designer reimplements (15 min).
Reference implementations of MinHash, SimHash, suffix arrays and Bloom filters, with benchmarks (20 min).
GPU fuzzy and semantic dedup on Ray (20 min for the dedup docs).
A global dedup of 99 crawls described step by step, with sizes and days (25 min).
The textbook treatment of shingling, MinHash and LSH (60 min).