Skip to main content

VectorDistance

Trait VectorDistance 

Source
pub trait VectorDistance {
    // Required methods
    fn dot_product(&self, other: &Self) -> f64;
    fn cosine_similarity(&self, other: &Self, normalized: bool) -> f64;
    fn angular_distance(&self, other: &Self, normalized: bool) -> f64;
    fn euclidean_distance(&self, other: &Self) -> f64;
    fn manhattan_distance(&self, other: &Self) -> f64;
    fn chebyshev_distance(&self, other: &Self) -> f64;
}
Expand description

Distance and similarity metrics for embedding vectors. Supply equal-length vectors; the embedding implementation pairs only their shared prefix. Unnormalized cosine requires nonzero magnitudes.

Required Methods§

Source

fn dot_product(&self, other: &Self) -> f64

Get dot product of two embedding vectors

Source

fn cosine_similarity(&self, other: &Self, normalized: bool) -> f64

Get cosine similarity of two embedding vectors. If normalized is true, the dot product is returned.

Source

fn angular_distance(&self, other: &Self, normalized: bool) -> f64

Get angular distance of two embedding vectors.

Source

fn euclidean_distance(&self, other: &Self) -> f64

Get euclidean distance of two embedding vectors.

Source

fn manhattan_distance(&self, other: &Self) -> f64

Get manhattan distance of two embedding vectors.

Source

fn chebyshev_distance(&self, other: &Self) -> f64

Get chebyshev distance of two embedding vectors.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§