Exercise ex-minhash — MinHash: estimate Jaccard similarity without ever computing it

In Java, "is this test set contaminated?" sounds like a database problem: hash every document, look for exact matches. It is not — a near-duplicate that changed one word hashes to a completely different value and slips straight through. What you actually want is Jaccard similarity between the two documents' shingle sets, but computing it exactly means comparing every pair of full shingle sets, which does not scale past a toy dataset. MinHash is the trick: compress each document into a short signature such that the fraction of matching signature positions is an unbiased estimate of the true Jaccard similarity — no pairwise set intersection required. f4-lora, next, fine-tunes on a scraped dataset and needs to prove none of it leaked into the eval set before trusting a single number the eval reports; this is the tool that proves it.

~75 minruns in the browser 7 checksex-minhash

What you're building

Check 3 quotes a real pair of near-duplicate sentences and their exact true Jaccard similarity (55 shared 5-grams over 75 total, computed directly from the sets, no hashing involved) so you have a ground truth to hold the estimate to. Check 4 averages the estimate's error over 20 seeds, because a single seed can get lucky with 8 hashes: the claim "more hashes → less error" is about the mean, and it holds for any correct hash scheme, not just the one the hint suggests. Check 7 signs a shingle set 50 different ways and demands the 50 outputs are not all the same number — the single most common wrong minhash draws one hash function and copies it into every slot.

If you get stuck