Inferensys

Glossary

MinHash Deduplication

A locality-sensitive hashing algorithm used to efficiently identify and remove near-duplicate documents in massive web-scale datasets to prevent memorization and overfitting.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
NEAR-DUPLICATE DETECTION

What is MinHash Deduplication?

MinHash deduplication is a locality-sensitive hashing technique used to efficiently identify and remove near-duplicate documents in massive web-scale datasets, preventing memorization and overfitting in large language models.

MinHash deduplication is a probabilistic algorithm that compresses document shingles into compact signature matrices to estimate Jaccard similarity without pairwise comparison. By partitioning signatures into multiple bands, it identifies candidate pairs with high similarity in sub-linear time, making it the standard for sanitizing multi-terabyte training corpora like Common Crawl.

The technique mitigates data contamination by removing syntactically near-identical documents that cause memorization and artificially inflate benchmark scores. Unlike exact hash matching, MinHash's locality-sensitive properties catch paraphrased or slightly altered duplicates, preserving the statistical diversity of the training distribution while preventing self-consuming loops.

LOCALITY-SENSITIVE HASHING

Key Features of MinHash Deduplication

MinHash is a foundational algorithm for estimating set similarity, enabling the efficient identification and removal of near-duplicate documents in web-scale training corpora to prevent memorization and model collapse.

01

Jaccard Similarity Estimation

MinHash provides a unbiased estimator of the Jaccard similarity coefficient between two sets. By comparing the minimum hash values of shingled documents, the algorithm approximates the ratio of the intersection to the union of their n-gram sets without requiring an expensive pairwise comparison of all elements. This statistical property allows for sub-linear deduplication in massive corpora like Common Crawl.

02

Shingling and Tokenization

Before hashing, documents are decomposed into k-shingles—contiguous subsequences of tokens of a fixed length k. For text, k is typically 5 to 9 words. This process converts a document into a set of features that is robust to minor edits, reordering, and paraphrasing. The choice of k directly impacts the granularity of duplicate detection:

  • Low k (3-4): Catches small phrase overlaps, higher false positives
  • High k (8-10): Identifies larger structural copies, higher precision
03

LSH Banding for Scalability

To avoid O(n²) comparisons, MinHash signatures are split into b bands of r rows each. Documents that hash to the same bucket in any band are considered candidate pairs. This Locality-Sensitive Hashing (LSH) technique probabilistically guarantees that similar documents collide with high probability while dissimilar ones are pruned. The parameters b and r are tuned to control the similarity threshold, creating an adjustable precision-recall curve for deduplication sensitivity.

04

Preventing Model Collapse

MinHash deduplication is a critical pre-processing defense against synthetic data contamination and model autophagy. By removing near-duplicate documents from training corpora, it prevents models from memorizing and regurgitating verbatim passages, which accelerates tail erosion and reduces output diversity. Research has shown that deduplicating web-scale datasets with MinHash significantly improves perplexity and reduces the frequency of exact training data extraction attacks.

05

MinHash vs. SimHash

While both are LSH techniques, they serve distinct purposes:

  • MinHash: Estimates Jaccard similarity; ideal for near-duplicate document detection and corpus deduplication.
  • SimHash: Estimates cosine similarity via randomized rounding; optimized for identifying exact or near-exact duplicates in web crawling. MinHash is preferred for training corpus sanitization because it is more robust to paraphrasing and document restructuring, catching semantic duplicates that SimHash would miss.
06

Implementation in Data Pipelines

Production deduplication pipelines typically execute MinHash in a MapReduce or Spark job across distributed clusters. The workflow involves:

  1. Shingling: Convert each document to a set of n-grams
  2. MinHashing: Apply multiple hash functions to generate a compact signature
  3. LSH Bucketing: Group signatures into candidate pairs
  4. Thresholding: Filter pairs above a Jaccard similarity cutoff (commonly 0.8) This process can deduplicate petabytes of text, such as the Colossal Clean Crawled Corpus (C4), reducing storage and preventing memorization.
MINHASH DEDUPLICATION

Frequently Asked Questions

Explore the core mechanisms behind MinHash, the locality-sensitive hashing algorithm that powers near-duplicate detection in web-scale training datasets.

MinHash deduplication is a locality-sensitive hashing (LSH) technique used to efficiently estimate the Jaccard similarity between two documents to identify near-duplicates. Instead of comparing raw text byte-by-byte, the algorithm compresses a document into a compact signature by applying multiple hash functions to its set of n-grams (typically word shingles). The core insight is that the probability of a collision between two MinHash signatures directly equals the Jaccard similarity of their original sets. By splitting these signatures into bands, the system can rapidly cluster similar documents without performing an O(n²) pairwise comparison, making it feasible to deduplicate massive corpora like Common Crawl or The Pile.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.