pub struct Embedding(pub Vec<f32>);Expand description
Represents an embedding vector.
This struct simply wraps a Vec<f32>.
Tuple Fields§
§0: Vec<f32>Implementations§
Source§impl Embedding
impl Embedding
Sourcepub fn similarity(&self, other: &Embedding) -> Result<f32, EmbeddingError>
pub fn similarity(&self, other: &Embedding) -> Result<f32, EmbeddingError>
Computes the cosine similarity between two embeddings.
Returns an error if the vectors are empty or have mismatched lengths.
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
impl StructuralPartialEq 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 UnsafeUnpin 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