A small library designed to compute similarity/dissimilarity metrics between embeddings using vector distance.
Current distance measures implemented:
- Cosine (handles both normalized and non-normalized vectors)
- Euclidean
- Manhattan
- Chebyshev
- Angular
- Jaccard Index
- Levenshtein
- Minkowski
- Dot product
- Parallel Computation: Utilizes rayon for parallel processing.
- Bring your own embedding: Use any embedding model to generate embeddings and compute the similarity/distance scores.
[dependencies]
semanticsimilarity_rs = "0.1.0"
cargo add semanticsimilarity_rs
use semanticsimilarity_rs::{cosine_similarity, euclidean_distance};
fn main() {
let vec1: [f64; 3] = [1.0, 2.0, 3.0];
let vec2: [f64; 3] = [4.0, 5.0, 6.0];
let similarity = cosine_similarity(&vec1, &vec2, false);
println!("Cosine similarity between vec1 and vec2: {}", similarity);
}