pub struct Embedding {
pub vector: Vec<f64>,
}
Expand description
Node embedding vector
Fields§
§vector: Vec<f64>
The embedding vector
Implementations§
Source§impl Embedding
impl Embedding
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Get the dimensionality of the embedding
Sourcepub fn cosine_similarity(&self, other: &Embedding) -> Result<f64>
pub fn cosine_similarity(&self, other: &Embedding) -> Result<f64>
Calculate cosine similarity with another embedding (SIMD optimized)
Sourcepub fn dot_product(&self, other: &Embedding) -> Result<f64>
pub fn dot_product(&self, other: &Embedding) -> Result<f64>
Compute dot product with another embedding (SIMD optimized)
Sourcepub fn update_gradient(&mut self, gradient: &[f64], learningrate: f64)
pub fn update_gradient(&mut self, gradient: &[f64], learningrate: f64)
Update embedding using gradient (SIMD optimized)
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
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more