LSHBloom, Audited: The Bloom Filters Are Fine, but Summing MinHash Values Into Band Keys Flags 15% of Unrelated Documents at 1M Docs
The standard near-duplicate filter for pretraining data is MinHashLSH. You shingle each document, compute P MinHash values, split the signature into b bands of r rows, and flag a document as a duplicate if any band exactly matches a band already in the index. That index is the problem at scale. For each band, it stores every band tuple ever inserted.
LSHBloom (Khan, Underwood et al., v4 January 2026) keeps the banding but swaps each band's hash table for a Bloom filter. The index shrinks to a fixed number of bits per document. The paper reports 11 GB vs 200+ GB of disk and 3 h vs 37 h wall clock on peS2o (39M documents). It also projects 590 GB vs 46 TB at 10B documents.
I checked the Bloom sizing, the error accounting, and how a band becomes a Bloom key. The first holds up, the second is very conservative, and the third breaks at a scale where the paper never measures dedup quality.
Part 1: the sizing is right, and the 1e-10 budget is mostly free
The paper's worked example uses threshold T = 0.8 and 128 permutations. Running the standard datasketch optimiser, which minimises the equally weighted false-positive and false-negative areas under the S-curve 1 − (1 − s^r)^b, gives (b, r) = (9, 13). That matches the paper's "nine bands" and uses 117 of the 128 permutations.
To hold a whole-document false-hit budget p_eff, each of the 9 filters gets p = 1 − (1 − p_eff)^(1/9), and each filter needs −n·ln p / (ln 2)² bits:
| p_eff | per-filter p | index at 10B docs | bits/doc |
|---|---|---|---|
| 1e-10 | 1.11e-11 | 591 GB | 472 |
| 1e-6 | 1.11e-7 | 375 GB | 300 |
| 1e-3 | 1.11e-4 | 213 GB | 171 |
The paper's 590 GB reproduces. Every factor of 10 in p_eff costs 9 · ln 10 / (ln 2)² ≈ 43 bits per document, so moving from a one-in-a-thousand budget to one-in-ten-billion costs only 2.8× more space.
The budget is also looser than it looks. A Bloom filter only reaches its design false-positive rate when it is full. If documents arrive uniformly, the rate seen by the average query is the integral over the fill level. With the optimal k = 36 hash functions, that average is 4.2e-13, 26× below the end-of-stream 1.1e-11. Over the whole stream, the expected number of documents lost to Bloom false positives is about 0.04, not 1.
Compare that to MinHashLSH's own error. At (9, 13) the false-positive and false-negative areas are 0.025 and 0.033. The Bloom term sits roughly eight orders of magnitude below the error it rides on. Part 1 passes.
Part 2: the band key is not a universal hash
A Bloom filter needs one key per band. Section 4.1 makes the key by summing the band's r MinHash values mod N, citing the universal vector-hashing construction: each MinHash value "is computed using a universal hash function... with the property that the probability of a hash collision is 1/N". The error bound in Eq. 3 then charges b/N for key collisions, with N = 2^32.
The released code does exactly that. The authors' datasketch fork calls a Rust helper for BloomTable.hash:
let total = arr.iter().fold(0u128, |acc, x| acc + *x as u128);
let hashed = total % ((1 << 61) - 1);The arr values are datasketch MinHash values, which are capped at 2^32 − 1.
The flaw is that a MinHash value is not h(x) for one fresh input. It is the minimum of h over the document's k shingles. For large k, that minimum is close to an exponential with mean N/k. The sum of r of them is Gamma(r, N/k), and for k = 1000 and r = 13 it is centred near 5.6e7. The mod 2^61 − 1 never triggers. In my emulation, the largest band sum seen across 200k documents was 1.7e8, a 27-bit number. The "61-bit" key has roughly 26 bits of usable entropy.
For two unrelated documents with k shingles each, the probability that their band sums match is the integral of the squared Gamma density:
P(collision) ≈ C(2r−2, r−1) / 2^(2r−1) · k / N
= 0.0806 · k / N (r = 13)
= 0.137 · k / N (r = 5)That is 0.08·k times the paper's 1/N, so 81× at k = 1000 and 403× at k = 5000 (r = 13). Long documents are hit hardest, because their minima sit closest to zero.
Checking it against real MinHash
To test this I didn't use the Beta approximation. I emulated datasketch's permutation exactly: ((a·hv + b) mod (2^61−1)) & (2^32−1), with uint64 wraparound, then the minimum over k = 1000 distinct shingle hashes, across 200,000 unrelated documents and one 14-row band (model constant 0.0775):
| band key | colliding pairs among 200k docs |
|---|---|
| plain sum (LSHBloom) | 340 |
| Gamma model above | 361 |
| paper's 1/N claim | 4.7 |
| exact tuple bytes (MinHashLSH) | 0 |
The model fits. The paper's bound is off by 72×.
What it does at index scale
Pair collisions only matter at index scale. A new document is checked against all n stored keys in each of b bands. For each band, the expected number of matching stored keys is λ = n · 0.08k/N, so the share of unrelated documents wrongly flagged is about 1 − e^(−bλ). I simulated insert-then-query directly: build per-band key sets for n documents, then query 20,000 fresh unrelated documents (9 bands, 14 rows):
| index size n | k = 1,000 shingles | k = 5,000 shingles |
|---|---|---|
| 50,000 | 0.74% | 3.99% |
| 1,000,000 | 15.2% | 55.1% |
| 5,000,000 | 54.7% | 98.0% |
The Poisson formula tracks every cell to within 0.9 percentage points. Extending it to the paper's (9, 13) configuration at peS2o's 39M documents gives 99.86% at k = 1000. In other words, nearly every document would be flagged as a duplicate. The paper's best fidelity setting, T = 0.5 with unigram shingles, is worse still. At 128 permutations the optimiser picks (25, 5), and the summed key flags 3.9% of unrelated documents against a 50k index at k = 1000.
That 50k figure is why the paper's evaluation wouldn't catch this. Fidelity was tuned on 24,000 documents and tested on 50,000. At that size the extra false positives are a few percent at most, consistent with the reported "F1 within 1% of MinHashLSH". The peS2o and 10B-document results measure only time and disk, not which documents were removed.
I emulated the released code path rather than running it, so the peS2o row is a projection. The mechanism holds for any setting: a sum of order statistics is not uniform.
The fix is one multiplier per row
The universal vector-hashing construction the paper cites gives each coordinate its own random multiplier. That breaks the concentration:
P61 = (1 << 61) - 1
A = [rng.randrange(1, P61) for _ in range(r)] # drawn once per band, stored with the index
def band_key(vals): # vals: r MinHash values of one band
return sum(a * v for a, v in zip(A, vals)) % P61On 200k documents drawn from the Beta model (13-row band), colliding pairs fall from 396 (model: 375) to 0. Any good 64-bit hash of the band's bytes, such as xxh3 or the tuple-bytes key MinHashLSH already uses, works too. (My first attempt reseeded the RNG per element, so every multiplier was equal, and it reproduced all 396 collisions. Equal multipliers are just the plain sum, scaled.)
Even a uniform key needs an honest bound. Eq. 3's b/N term is a per-pair probability, but each query is compared with n stored keys. The correct term is about b·n/2^w. With a uniform 64-bit key at 10B documents and 9 bands, that is 4.9e-9 per query, 49× the 1e-10 budget the Bloom filters were sized for. To keep key collisions under p_eff, the key needs w ≥ log2(b·n/p_eff) ≈ 70 bits. A 128-bit key costs nothing in index size, because Bloom filter size doesn't depend on key width.
Takeaways
- The Bloom-filter idea is sound. About 472 bits per document at 1e-10, 26× more conservative than it looks once you average over fill. If you're sizing one,
p_eff = 1e-6saves 37% of the space and still loses about one document per million. - Never sum MinHash values unweighted. They are order statistics concentrated near zero. A sum of
rof them has aboutlog2(rN/k)useful bits, notlog2 N. - Count collisions per query, not per pair. Any term written as
1/Nin an index error bound should be checked for a missing factor ofn. - Measure fidelity at the scale you report throughput. A bug costing 0.7% at 50k documents and 99.9% at 39M passes every small benchmark.