pub struct MatryoshkaIndex {
pub config: MatryoshkaConfig,
/* private fields */
}Expand description
Matryoshka embedding index supporting adaptive-dimension search.
Stores embeddings at full dimensionality but can search at any prefix dimension for a speed-accuracy trade-off.
Fields§
§config: MatryoshkaConfigIndex configuration.
Implementations§
Source§impl MatryoshkaIndex
impl MatryoshkaIndex
Sourcepub fn new(config: MatryoshkaConfig) -> Result<Self>
pub fn new(config: MatryoshkaConfig) -> Result<Self>
Create a new Matryoshka index.
§Errors
Returns an error if supported_dims is empty, any dimension is zero,
or any dimension exceeds full_dim.
Sourcepub fn insert(
&mut self,
id: VectorId,
embedding: Vec<f32>,
metadata: Option<HashMap<String, Value>>,
) -> Result<()>
pub fn insert( &mut self, id: VectorId, embedding: Vec<f32>, metadata: Option<HashMap<String, Value>>, ) -> Result<()>
Insert a full-dimensional embedding into the index.
§Errors
Returns an error if the embedding dimension does not match full_dim.
Sourcepub fn search(
&self,
query: &[f32],
dim: usize,
top_k: usize,
) -> Result<Vec<SearchResult>>
pub fn search( &self, query: &[f32], dim: usize, top_k: usize, ) -> Result<Vec<SearchResult>>
Search at a specific dimension by truncating embeddings to the first
dim components.
§Arguments
query- Full-dimensional (or at leastdim-dimensional) query vector.dim- The truncation dimension to use for search.top_k- Number of results to return.
§Errors
Returns an error if dim exceeds the query length or full_dim.
Sourcepub fn funnel_search(
&self,
query: &[f32],
top_k: usize,
funnel_config: &FunnelConfig,
) -> Result<Vec<SearchResult>>
pub fn funnel_search( &self, query: &[f32], top_k: usize, funnel_config: &FunnelConfig, ) -> Result<Vec<SearchResult>>
Two-phase funnel search: coarse filter at low dimension, rerank at full dimension.
- Search at
funnel_config.filter_dimforcandidate_multiplier * top_kcandidates. - Rerank those candidates at
full_dim. - Return the top
top_k.
§Errors
Returns an error if the query is shorter than full_dim.
Sourcepub fn cascade_search(
&self,
query: &[f32],
top_k: usize,
dims: &[usize],
reduction_factor: f32,
) -> Result<Vec<SearchResult>>
pub fn cascade_search( &self, query: &[f32], top_k: usize, dims: &[usize], reduction_factor: f32, ) -> Result<Vec<SearchResult>>
Multi-stage cascade search through multiple dimensions.
Searches through dimensions in ascending order, progressively narrowing
candidates. At each stage, the candidate set is reduced by the
reduction_factor.
Trait Implementations§
Source§impl Clone for MatryoshkaIndex
impl Clone for MatryoshkaIndex
Source§fn clone(&self) -> MatryoshkaIndex
fn clone(&self) -> MatryoshkaIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MatryoshkaIndex
impl Debug for MatryoshkaIndex
Source§impl<'de> Deserialize<'de> for MatryoshkaIndex
impl<'de> Deserialize<'de> for MatryoshkaIndex
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>,
Auto Trait Implementations§
impl Freeze for MatryoshkaIndex
impl RefUnwindSafe for MatryoshkaIndex
impl Send for MatryoshkaIndex
impl Sync for MatryoshkaIndex
impl Unpin for MatryoshkaIndex
impl UnsafeUnpin for MatryoshkaIndex
impl UnwindSafe for MatryoshkaIndex
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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