pub struct FastEmbedder { /* private fields */ }Expand description
Local CPU embedder backed by fastembed-rs (ONNX runtime, all-MiniLM-L6-v2).
Why: Default to local-only embeddings so consumers have zero external
network dependency and predictable latency. The LRU cache keeps the hot
path free of redundant ONNX work for repeat strings (queries, common
chunks).
What: wraps a single TextEmbedding behind a parking_lot::Mutex (the
underlying embed requires &mut self) and an LruCache<String, Vec<f32>>.
Initialisation warms the ORT graph with a small batch so the first user
query doesn’t pay the one-shot compile cost.
Test: embed_batch_returns_correct_dim and cache_hit_is_idempotent
(marked #[ignore] — they download a real model).
Implementations§
Source§impl FastEmbedder
impl FastEmbedder
Trait Implementations§
Source§impl Embedder for FastEmbedder
impl Embedder for FastEmbedder
Source§fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Embed a batch of texts. Returns one
Vec<f32> per input, each of
length self.dimension(). An empty input batch returns an empty Vec.Auto Trait Implementations§
impl Freeze for FastEmbedder
impl !RefUnwindSafe for FastEmbedder
impl Send for FastEmbedder
impl Sync for FastEmbedder
impl Unpin for FastEmbedder
impl UnsafeUnpin for FastEmbedder
impl !UnwindSafe for FastEmbedder
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> 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>
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