Expand description
§dedup - High-performance dataset deduplication for ML training data
A MinHash + LSH implementation for finding near-duplicate documents
in massive datasets. Designed for streaming operation to handle
billions of documents without loading all into memory.
§Quick Start
use dedup::{Config, DedupTransformer};
let config = Config::default()
.with_similarity_threshold(0.85)
.with_num_bands(16);
let dedup = DedupTransformer::new(config).unwrap();§Architecture
┌─────────────┐ ┌──────────────┐ ┌─────────────┐ ┌─────────────┐
│ Shingle │────▶│ MinHash │────▶│ LSH Bands │────▶│ Deduplicate│
│ (k-grams) │ │ (fast hash) │ │ (buckets) │ │ (filter) │
└─────────────┘ └──────────────┘ └─────────────┘ └─────────────┘§MinHash + LSH Theory
- Shingling: Convert documents to sets of k-grams (overlapping subsequences)
- MinHash: Compress document to a small signature while preserving Jaccard similarity
- LSH: Band signatures such that similar documents collide in at least one bucket
- Threshold: Documents with estimated Jaccard ≥ threshold are considered duplicates
Re-exports§
pub use shingle::ShingleIterator;
Modules§
- shingle
- Shingling (k-gram generation) for text documents.
- tenshift
- Re-export tenshift types for convenience.
Structs§
- Config
- Dedup
Transformer - A transform that deduplicates samples using MinHash + LSH.
- Duplicate
Cluster - A cluster of duplicate documents.
- Fast
Hasher - A fast hasher for computing multiple hash values efficiently.
- LshIndex
- LSH index for finding candidate similar document pairs.
- MinHash
Signature - A MinHash signature for a document.
- MinHasher
- MinHasher computes MinHash signatures from documents.
- Stateful
Dedup Transform - A stateful deduplication transform that buffers samples.
Enums§
- Error
- All errors that can occur during deduplication.
Constants§
- DEFAULT_
NUM_ BANDS - Default number of LSH bands.
- DEFAULT_
SHINGLE_ SIZE - Default shingle size in bytes/characters.
- DEFAULT_
SIGNATURE_ SIZE - Default number of hash functions (signature size).
- DEFAULT_
SIMILARITY_ THRESHOLD - Default similarity threshold for considering documents as duplicates.
Functions§
- candidate_
probability - Estimate the false positive rate given LSH parameters.
- compute_
rows_ per_ band - Compute the number of rows per band given signature size and num bands.
- hash_
bytes - Compute a fast, non-cryptographic hash of a byte slice.
- optimize_
lsh_ params - Find the optimal LSH parameters for a given similarity threshold.
Type Aliases§
- Result
- Convenience result type.