pub struct MultiVector { /* private fields */ }Expand description
A multivector - multiple dense vectors per point (ColBERT-style) Each sub-vector typically represents a token embedding
Implementations§
Source§impl MultiVector
impl MultiVector
Sourcepub fn new(vectors: Vec<Vec<f32>>) -> Result<Self, &'static str>
pub fn new(vectors: Vec<Vec<f32>>) -> Result<Self, &'static str>
Create a new multivector from a list of sub-vectors All sub-vectors must have the same dimension
Sourcepub fn from_single(vector: Vec<f32>) -> Result<Self, &'static str>
pub fn from_single(vector: Vec<f32>) -> Result<Self, &'static str>
Create from a single dense vector (wraps it as a multivector with one sub-vector)
Sourcepub fn first(&self) -> Option<&Vec<f32>>
pub fn first(&self) -> Option<&Vec<f32>>
Get the first sub-vector (useful for backwards compatibility)
Sourcepub fn to_single_vector(&self) -> Vector
pub fn to_single_vector(&self) -> Vector
Convert to a single Vector (using first sub-vector) Used for backwards compatibility with non-multivector operations
Sourcepub fn max_sim(&self, other: &MultiVector) -> f32
pub fn max_sim(&self, other: &MultiVector) -> f32
Compute MaxSim score between two multivectors
For each sub-vector in self (query), find the maximum similarity
with any sub-vector in other (document), then sum all maximums.
This is the ColBERT scoring algorithm.
Sourcepub fn max_sim_cosine(&self, other: &MultiVector) -> f32
pub fn max_sim_cosine(&self, other: &MultiVector) -> f32
Compute MaxSim with cosine similarity (normalized dot product)
Sourcepub fn max_sim_l2(&self, other: &MultiVector) -> f32
pub fn max_sim_l2(&self, other: &MultiVector) -> f32
Compute MaxSim with negative L2 distance (for Euclidean)
Trait Implementations§
Source§impl Clone for MultiVector
impl Clone for MultiVector
Source§fn clone(&self) -> MultiVector
fn clone(&self) -> MultiVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MultiVector
impl Debug for MultiVector
Source§impl<'de> Deserialize<'de> for MultiVector
impl<'de> Deserialize<'de> for MultiVector
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>,
Source§impl From<MultiVector> for VectorData
impl From<MultiVector> for VectorData
Source§fn from(mv: MultiVector) -> Self
fn from(mv: MultiVector) -> Self
Source§impl PartialEq for MultiVector
impl PartialEq for MultiVector
Source§impl Serialize for MultiVector
impl Serialize for MultiVector
impl StructuralPartialEq for MultiVector
Auto Trait Implementations§
impl Freeze for MultiVector
impl RefUnwindSafe for MultiVector
impl Send for MultiVector
impl Sync for MultiVector
impl Unpin for MultiVector
impl UnwindSafe for MultiVector
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
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>
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>
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