Crates.io | semanticsimilarity_rs |
lib.rs | semanticsimilarity_rs |
version | 0.1.1 |
source | src |
created_at | 2024-02-24 02:36:32.439238 |
updated_at | 2024-05-05 18:07:03.586807 |
description | A library designed to compute similarity/distance metrics between embeddings |
homepage | |
repository | |
max_upload_size | |
id | 1151195 |
size | 4,842 |
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);
}