pub struct FastembedBackend { /* private fields */ }Expand description
ONNX-backed embedding via fastembed-rs. Loads the model at construction;
inference runs on a tokio blocking thread per batch.
The inner TextEmbedding is held behind a mutex, which serializes
.embed() calls across concurrent users of the same FastembedBackend.
For schema-RAG (low QPS, small batches) this is fine. For bulk user-data
embedding (Phase C+) we may want a pool of TextEmbedding instances or
a lock-free inference path — revisit when that workload materializes.
Implementations§
Trait Implementations§
Source§impl Debug for FastembedBackend
impl Debug for FastembedBackend
Source§impl EmbeddingBackend for FastembedBackend
impl EmbeddingBackend for FastembedBackend
Source§fn id(&self) -> &str
fn id(&self) -> &str
Stable identifier, e.g.
"fastembed/bge-small-en-v1.5" or
"openai/text-embedding-3-small". Mixing IDs across writes
is a correctness bug (distance-space mismatch) — the engine
tags every vector column with its model_id.Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
texts: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbedError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Compute embeddings for a batch. Order of outputs matches inputs.
Auto Trait Implementations§
impl !RefUnwindSafe for FastembedBackend
impl !UnwindSafe for FastembedBackend
impl Freeze for FastembedBackend
impl Send for FastembedBackend
impl Sync for FastembedBackend
impl Unpin for FastembedBackend
impl UnsafeUnpin for FastembedBackend
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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