pub struct FastEmbedEmbedder {
model_name: &'static str,
}Expand description
FastEmbed embedder using all-MiniLM-L6-v2.
Uses the fastembed-rs library for real semantic embeddings. The model is lazily loaded on first embed call to preserve cold start time.
Fields§
§model_name: &'static strModel name for logging/debugging.
Implementations§
Source§impl FastEmbedEmbedder
impl FastEmbedEmbedder
Sourcepub const DEFAULT_DIMENSIONS: usize = DEFAULT_DIMENSIONS
pub const DEFAULT_DIMENSIONS: usize = DEFAULT_DIMENSIONS
Default embedding dimensions for all-MiniLM-L6-v2.
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new FastEmbed embedder.
Note: Model is lazily loaded on first embed() call.
Sourcepub const fn with_dimensions(_dimensions: usize) -> Self
pub const fn with_dimensions(_dimensions: usize) -> Self
Creates a new embedder with custom dimensions.
Note: This is provided for API compatibility but dimensions are fixed by the model (384 for all-MiniLM-L6-v2).
Sourcefn get_model() -> Result<&'static Mutex<TextEmbedding>>
fn get_model() -> Result<&'static Mutex<TextEmbedding>>
Gets or initializes the embedding model (thread-safe).
§Performance Note
The model is loaded lazily on first use to preserve cold start time. Subsequent calls return the cached instance.
The first call blocks synchronously (~100-500ms) while loading the ONNX model. This is an intentional design decision:
- One-time cost amortized over all subsequent calls (instant)
- Sync API is simpler and doesn’t require async runtime everywhere
- Alternative (
tokio::spawn_blocking) would require asyncEmbeddertrait
For applications sensitive to first-call latency, consider warming up the
embedder during startup: FastEmbedEmbedder::new().embed("warmup").ok();
Sourcepub const fn model_name(&self) -> &'static str
pub const fn model_name(&self) -> &'static str
Returns the model name.
Trait Implementations§
Source§impl Default for FastEmbedEmbedder
impl Default for FastEmbedEmbedder
Source§impl Embedder for FastEmbedEmbedder
impl Embedder for FastEmbedEmbedder
Auto Trait Implementations§
impl Freeze for FastEmbedEmbedder
impl RefUnwindSafe for FastEmbedEmbedder
impl Send for FastEmbedEmbedder
impl Sync for FastEmbedEmbedder
impl Unpin for FastEmbedEmbedder
impl UnwindSafe for FastEmbedEmbedder
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<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].