Abstract
Document deduplication is a critical preprocessing step for training Large Language Models (LLMs), yet traditional MinHash Locality-Sensitive Hashing (LSH) implementations struggle with the memory and computational demands of billion-scale datasets. We present LSHBloom, an architectural extension that replaces traditional indexing structures with probabilistic Bloom filters and leverages hardware-aware Rust optimizations. LSHBloom achieves a 12x increase in throughput and an 18x reduction in disk footprint compared to standard implementations while maintaining high accuracy.
Introduction
As Large Language Models (LLMs) grow hungrier for data, researchers are scraping the entire internet to feed them. However, the web is incredibly redundant; studies show that 14% to 52% of web-scraped records are near-duplicates. This redundancy inflates training costs, degrades model quality, and slows down retrieval systems.
The current gold standard for finding these "near-miss" duplicates is MinHash Locality-Sensitive Hashing (LSH). While effective, traditional MinHashLSH implementations rely on index structures like trees or hashmaps. At "internet scale" (billions of documents), these indices become massive bottlenecks. For example, deduplicating 5 billion documents using standard methods would require roughly 277 TB of disk space—a prohibitive cost for most researchers. Furthermore, these indices suffer from "pointer chasing," where non-contiguous memory accesses slow down processing significantly.
Methods
LSHBloom fundamentally changes how MinHash signatures are stored and queried through several key innovations:
- Probabilistic Indexing: Instead of storing full MinHash signatures in a hashmap or tree, LSHBloom uses an array of independent Bloom filters. Each "band" of the MinHash signature is hashed into a single integer and inserted into a corresponding Bloom filter.
- Hardware-Software Co-design: Over 90% of execution time in Python-based deduplication is typically spent on inefficient integer math. LSHBloom's core hashing logic is written in Rust, utilizing 128-bit arithmetic (the
adcinstruction) to prevent overflows and maximize throughput. - Spatial Locality: By mapping LSH bands directly to contiguous bit vectors (the Bloom filters), the system avoids the cache misses associated with traditional pointer-heavy data structures.
- Analytical Error Bounds: Because Bloom filters are probabilistic, they introduce a small chance of false positives. The authors provide a formal mathematical framework to bound these error rates, allowing users to tune the system for a specific "budget" of false positives.
Key Results
Evaluation on the 39M-document peS2o dataset demonstrated that LSHBloom reduced processing time from 37 hours to just 3 hours. Storage requirements dropped from 200 GB to 11 GB—an 18x reduction.
In head-to-head accuracy tests, LSHBloom achieved F1 scores nearly identical to standard MinHashLSH, significantly outperforming paragraph-level and n-gram-based methods like CCNet and Dolma. Through extrapolation, the authors show that LSHBloom could deduplicate 5 billion documents using only 15.5 TB of space and 15 days of compute on commodity hardware, whereas traditional methods would require 277 TB and 200 days.
Key Insights
- The "Good Enough" Approximation: The core realization is that storing actual MinHash signatures is unnecessary to find duplicates. A probabilistic "yes/no" from a Bloom filter is sufficient, provided the false positive rate is analytically controlled.
- Index Invariance: Unlike traditional indices that grow linearly with the size of the hash values, the size of an LSHBloom index depends only on the number of documents and the desired error rate. This allows for higher-precision hashing without a storage penalty.
- Throughput is Hashing-Bound: Moving from Python's arbitrary-precision integers to optimized Rust assembly resulted in an 11x end-to-end speedup for the hashing routine alone.
Conclusion and Future Work
LSHBloom makes billion-scale deduplication feasible on commodity hardware by trading absolute certainty for probabilistic efficiency. While the current implementation primarily addresses duplications found in web scraping (parsing errors, truncations), future work will explore parallelizing the index insertion process and extending the framework to capture more "semantic" forms of duplication.
Summary updated