pub enum VectorDistance {
Cosine,
Euclidean,
DotProduct,
}Expand description
Distance metric for vector similarity search.
Variants§
Cosine
Cosine similarity distance (1 - cosine similarity)
Euclidean
Euclidean distance (L2 norm)
DotProduct
Dot-product (inner-product) distance.
Ranks by the inner product of two vectors: a larger inner product
means greater similarity. The HNSW index treats smaller scores as
closer, so the distance function returns the negated inner product
(see dot_product_distance). For L2-normalized embeddings this
ranks identically to VectorDistance::Cosine while skipping the
per-vector normalization step.
Trait Implementations§
Source§impl Clone for VectorDistance
impl Clone for VectorDistance
Source§fn clone(&self) -> VectorDistance
fn clone(&self) -> VectorDistance
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for VectorDistance
Source§impl Debug for VectorDistance
impl Debug for VectorDistance
Source§impl Default for VectorDistance
impl Default for VectorDistance
Source§fn default() -> VectorDistance
fn default() -> VectorDistance
Returns the “default value” for a type. Read more
impl Eq for VectorDistance
Source§impl PartialEq for VectorDistance
impl PartialEq for VectorDistance
Source§fn eq(&self, other: &VectorDistance) -> bool
fn eq(&self, other: &VectorDistance) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for VectorDistance
Auto Trait Implementations§
impl Freeze for VectorDistance
impl RefUnwindSafe for VectorDistance
impl Send for VectorDistance
impl Sync for VectorDistance
impl Unpin for VectorDistance
impl UnsafeUnpin for VectorDistance
impl UnwindSafe for VectorDistance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.