Duplicate detection needs a representation, a similarity rule, and a retention policy
Separate exact identity from shingle resemblance, derive MinHash candidate behavior, and preserve cluster lineage without claiming perfect semantic deduplication.
On this page
The question for today
What you’ll understand
- Define exact duplicates relative to a versioned representation.
- Calculate Jaccard resemblance and a stated banding candidate probability.
- Explain candidate verification, cluster policy, and forgotten seen-identity failures.
Repeated training text can waste token budget and increase memorization, but two documents can resemble each other without being interchangeable. A deduplication system must define what counts as the same material, how candidates are found, and which representative or portions remain. Exact hashes and approximate sketches solve different tasks. Preserve the removed-to-kept mapping so a smaller corpus remains auditable rather than becoming a list of unexplained deletions.
Exactness is relative to the chosen bytes or tokens
An exact duplicate can mean identical raw bytes, identical normalized text, or an identical token sequence under a pinned tokenizer. These criteria differ. Use a digest to group candidates efficiently and verify the required equality where the contract calls for exactness, accounting for hash-collision assumptions. Keep length and representation metadata. A table of short boilerplate fragments can be useful to remove repeated spans without deleting an entire otherwise distinct document; conversely, whole-document hashing misses a copied article embedded inside a different wrapper.
The original training-data deduplication research studies repeated documents and substrings and their effect on memorization and evaluation. Its findings motivate a measurable pipeline, not a universal claim that all similar text should disappear. Repeated definitions, code templates, or legally required notices can be meaningful in some contexts. Define whether the goal is reducing redundant exposure, preventing train/evaluation leakage, or clustering source copies. The same threshold need not serve every purpose, and a quality-based representative choice should not discard source provenance or evade the documented use policy.
Sketches propose candidates under assumptions
MinHash estimates Jaccard resemblance by comparing minima under suitable random permutations or their practical hash approximations. With an ideal minwise permutation, equal minima occur with probability J. A banded sketch can raise the chance of proposing sufficiently similar pairs while limiting all-pairs comparisons. The familiar candidate formula assumes independent rows grouped into bands. Practical hashes, collisions, finite sketches, and data distribution affect behavior, so a candidate match is not an exact similarity measurement and a noncandidate is not proof of dissimilarity.
Verify candidate pairs with the intended similarity or containment rule before applying the removal policy. Approximate pairwise similarity is not transitive: A can match B and B match C while A does not match C. A connected-component cluster can therefore merge a broad chain, and keeping just one representative may remove more diversity than the pair threshold suggests. Test threshold behavior and cluster sizes on trusted pairs, including templated but meaningfully distinct documents. Record cluster identifiers, similarity evidence, and representative selection rules for later audit and source retirement.
A seen-item store must cover the promised scope
A bounded cache of recently seen hashes provides only a bounded-memory duplicate check. Once a digest is evicted, an old duplicate can appear new unless another index retains it. Global corpus deduplication needs a method whose retained or partitioned index covers that declared scope, such as sorted hashes or an appropriately designed external structure. Distributed work partitioning must route equivalent candidates consistently and coordinate representative decisions. Count removed documents and tokens separately, and inspect whether one source or language loses disproportionate useful material.
The cache lab isolates forgotten exact identities. Reset, explicitly set BOTH C=4 and s=4, predict twelve hits among N=16 requests at t=0, then Play or Step. Reset and re-set BOTH C=3 and s=4; predict zero hits because each repeated identity follows eviction. N=min(4096,16+floor(2t)); edits retain t and recompute from empty. This LRU toy has no text, hashing, MinHash, pair verification, or global corpus index. A hit represents remembered identity only; it cannot decide which similar documents are interchangeable.
Work it through
Compute resemblance before interpreting a candidate
Two fictional documents have shingle-set sizes ten each and intersection size eight. A separate ideal banding design uses five bands of four rows. Evaluate its candidate probability for a pair with resemblance s=0.8.
The first pair's union has 10+10−8=12 shingles, so its Jaccard resemblance is 8/12=2/3, not 0.8. Intersection divided by one document's size asks a different question.
For the separate s=0.8 pair, one four-row band matches with probability 0.8⁴=0.4096 under the ideal assumptions.
At least one of five bands matches with probability 1−(1−0.4096)⁵≈0.9283. This proposes a candidate; the corpus policy still needs final verification and representative handling.
Similarity definition and candidate probability are distinct quantities. Neither number by itself establishes that deleting one document preserves all useful content.
The living notebook
Explore the model
Interactive lab · cache
Evicted identities are no longer a global duplicate index
For EACH run Reset, set BOTH C and s, predict, then Play or Step. At N=16/t=0, (4,4) gives twelve hits and (3,4) gives zero. N=min(4096,16+floor(2t)); edits retain t/recompute from empty. No document hashes, approximate sketches, cluster decisions, or global deduplication guarantees are simulated.
- Hits / requests
- 0 / 16
- Hit rate
- 0%
- Address-stream period
- 16 addresses
A fully associative LRU cache starts empty and requests address (i·s) mod 16. Hits move an address to the newest position; misses evict the oldest when full. Playback starts with 16 requests and adds two per second, capped at 4096 explicitly simulated requests. This toy stream is not a processor-cache benchmark. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA recent-item cache can forget exact repeats; the duplicate-detection scope needs an index and policy that actually cover it.
Pause & reason
Check your understanding
Your turn
Try it yourself
Shingle sets have sizes twelve and eight with six shared shingles. Calculate Jaccard resemblance and containment of the eight-shingle set in the other. Why are the two values different?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Jaccard uses union size; directional containment uses the chosen smaller set's size here.
Compare with the solution
Union size is 12+8−6=14, so Jaccard is 6/14≈0.4286. Containment of the eight-shingle set is 6/8=0.75. The first compares total set resemblance, while the second asks how much of that particular document's shingle set is present in the other.
Keep the idea
Take it with you
- Exact duplicate identity depends on a pinned representation and equality criterion.
- Approximate sketches find candidates whose verification and clustering need separate policies.
- Global deduplication must not silently degrade into a forgetful recent-item cache.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.