How it works
- Shingling — the document is split into overlapping n-grams
(
shingleSizecharacters, or words ifshingleUnit: 'word'). - MinHashing —
numberOfHashFunctionsindependent hash functions each record the minimum hash over the shingle set, producing a fixed-length signature whose position-wise agreement rate approximates the Jaccard similarity between documents. - LSH banding — the signature is split into bands of
bucketSizeconsecutive positions. Two documents are candidates if they agree on every position within at least one band (an OR-of-ANDs), which is what makes lookups sub-linear instead of comparing every pair of documents. - Optional re-ranking —
rerank: truecomputes exact Jaccard similarity on the (typically small) LSH candidate set, trading a little speed for precision.
Benchmark
Section titled “Benchmark”The repo ships a benchmark script:
npm run benchSee benchmarks/
in the repo for the harness itself.