pub struct EmbeddingIndex { /* private fields */ }Expand description
Mmap-backed embedding index for fast semantic lookup.
Implementations§
Source§impl EmbeddingIndex
impl EmbeddingIndex
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Number of stored (embedded) blocks.
Sourcepub fn embedding(&self, block_idx: usize) -> Option<&[f32]>
pub fn embedding(&self, block_idx: usize) -> Option<&[f32]>
Get the embedding for a block index (zero-copy mmap access).
Sourcepub fn search(&self, query_emb: &[f32], k: usize) -> Vec<(f32, usize)>
pub fn search(&self, query_emb: &[f32], k: usize) -> Vec<(f32, usize)>
Search for top-k most similar blocks to query embedding. Returns Vec<(similarity, block_index)> sorted descending.
Sourcepub fn all_block_ids(&self) -> &[u32]
pub fn all_block_ids(&self) -> &[u32]
Every stored block id, in ascending order.
Exposed for diagnostics that reason about the whole embedded set (a depth histogram, a per-block score) rather than a top-k slice of it.
Sourcepub fn similarity_of(&self, block_idx: usize, query_emb: &[f32]) -> Option<f32>
pub fn similarity_of(&self, block_idx: usize, query_emb: &[f32]) -> Option<f32>
Cosine similarity of one stored block against a query embedding.
Sourcepub fn full_rank_of(
&self,
block_idx: usize,
query_emb: &[f32],
) -> Option<(usize, f32)>
pub fn full_rank_of( &self, block_idx: usize, query_emb: &[f32], ) -> Option<(usize, f32)>
Rank of a stored block within the full untruncated cosine ordering.
Diagnostics only. This separates “the embedding is bad” from “the top-k is crowded out”: a block with a high score at a high rank is being drowned by redundant neighbours, not poorly represented.
Auto Trait Implementations§
impl Freeze for EmbeddingIndex
impl RefUnwindSafe for EmbeddingIndex
impl Send for EmbeddingIndex
impl Sync for EmbeddingIndex
impl Unpin for EmbeddingIndex
impl UnsafeUnpin for EmbeddingIndex
impl UnwindSafe for EmbeddingIndex
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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