Skip to main content

Module algo

Module algo 

Source
Expand description

§The Algorithm Arsenal

Categorized similarity algorithms, each returning a normalized f64 score where 1.0 = identical and 0.0 = completely dissimilar.

Short Strings & Typos

AlgorithmBest forTime
levenshteinEdit distance (typos)O(n·m)
jaro_winklerName matchingO(n·m)
hammingEqual-length stringsO(n)

Sets & Documents

AlgorithmBest forTime
jaccardN-gram set similarityO(n+m)
minhashLarge-document fingerprintsO(k·n)
simhashDeduplication fingerprintsO(n)

Statistical Meaning

AlgorithmBest forTime
bm25Search relevance rankingO(n·m)
tfidfTerm-weighted cosine similarityO(n·m)

Each function in this module takes pre-processed inputs (strings) and returns an f64 in [0.0, 1.0].

Modules§

bm25
BM25 (Best Matching 25) — a probabilistic retrieval function for ranking documents against a query. An improvement over TF-IDF for contextual similarity without the overhead of an LLM.
hamming
Hamming Distance — counts positions where corresponding symbols differ for strings of equal length. Normalized to [0.0, 1.0].
jaccard
Jaccard Similarity — measures similarity between two sets of words or n-grams. Normalized to [0.0, 1.0].
jaro_winkler
Jaro-Winkler Distance — exceptionally good for name matching as it heavily weights matching prefixes. Normalized to [0.0, 1.0].
levenshtein
Levenshtein Distance — minimum single-character edits to change one string into another. Normalized to [0.0, 1.0] where 1.0 = identical.
minhash
MinHash — probabilistic data structure for estimating Jaccard similarity between large documents. Uses k hash functions to create compact fingerprints.
simhash
SimHash — locality-sensitive hash for deduplication of large documents.
tfidf
TF-IDF + Cosine — counts word frequencies, weights them by rarity, and calculates the cosine angle between document vectors.