pub struct Embedding {
pub document: String,
pub vec: Vec<f64>,
}
Expand description
Struct that holds a single document and its embedding.
Fields§
§document: String
The document that was embedded. Used for debugging.
vec: Vec<f64>
The embedding vector
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Embedding
impl<'de> Deserialize<'de> for Embedding
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl VectorDistance for Embedding
impl VectorDistance for Embedding
Source§fn dot_product(&self, other: &Self) -> f64
fn dot_product(&self, other: &Self) -> f64
Get dot product of two embedding vectors
Source§fn cosine_similarity(&self, other: &Self, normalized: bool) -> f64
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
fn angular_distance(&self, other: &Self, normalized: bool) -> f64
Get angular distance of two embedding vectors.
Source§fn euclidean_distance(&self, other: &Self) -> f64
fn euclidean_distance(&self, other: &Self) -> f64
Get euclidean distance of two embedding vectors.
Source§fn manhattan_distance(&self, other: &Self) -> f64
fn manhattan_distance(&self, other: &Self) -> f64
Get manhattan distance of two embedding vectors.
Source§fn chebyshev_distance(&self, other: &Self) -> f64
fn chebyshev_distance(&self, other: &Self) -> f64
Get chebyshev distance of two embedding vectors.
impl Eq for Embedding
Auto Trait Implementations§
impl Freeze for Embedding
impl RefUnwindSafe for Embedding
impl Send for Embedding
impl Sync for Embedding
impl Unpin for Embedding
impl UnwindSafe for Embedding
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§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.