Cluster Near-Duplicate Documents by Shared MinHash Bands
Last updated: November 29, 2026
Quick Overview
Each document has a MinHash signature split into bands, one hash per band. Two documents are candidates if they share the same hash in the same band position; return the transitive clusters of documents as sorted lists.
OpenAI
November 29, 20260
0
0 solved
Each document has a MinHash signature split into bands, one hash per band. Two documents are candidates if they share the same hash in the same band position; return the transitive clusters of documents as sorted lists.
Removing near-duplicate web documents is an important step in building pretraining corpora, and locality-sensitive hashing with banded MinHash is the standard technique. In an OpenAI onsite the interviewer wants to see you realize transitive grouping is a union-find problem, avoid comparing all pairs, and know what band collisions mean.
What the Interviewer Expects
- Key collisions by (band index, hash), not hash alone
- Union each document with the first owner of a key instead of all pairs
- Implement union-find with path compression and union by rank
- Return deterministic cluster ordering
- Discuss false positives from transitivity and how to verify candidates
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Transitive chaining merges documents that are not similar: how would you verify with Jaccard similarity before unioning?
- How do the number of bands and rows per band shape the similarity threshold?
- Signatures are spread across 1,000 machines: how do you run this distributedly?
- Keep one representative per cluster: which would you choose for training?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
doc_id -> [h0, h1, ...], one hash per band. - Documents sharing
(i, h)for any bandiare linked; clusters are connected components. - Output: clusters as sorted lists, ordered by their...
High-Level Design
Map each (band, hash) bucket to the first document seen in it. When a later document lands in the same bucket, union it with that first owner. Linking to one representative per bucket is enough for ...