pub struct StubEmbedder { /* private fields */ }Expand description
Deterministic, dependency-free pseudo-embedder used in tests.
Hashes each word into a fixed-dim bucket (count-of-hash-buckets), then L2-normalizes the resulting vector. NOT semantic — texts that share words will be close; texts that don’t share words will be far. Good enough to exercise the hybrid-scoring code path without depending on a real ML model.
Default dimension is 8 (small enough to keep tests fast).
Implementations§
Trait Implementations§
Source§impl Clone for StubEmbedder
impl Clone for StubEmbedder
Source§fn clone(&self) -> StubEmbedder
fn clone(&self) -> StubEmbedder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for StubEmbedder
Source§impl Debug for StubEmbedder
impl Debug for StubEmbedder
Source§impl Default for StubEmbedder
impl Default for StubEmbedder
Source§impl Embedder for StubEmbedder
impl Embedder for StubEmbedder
Source§fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedderError>
fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedderError>
Compute an embedding for
text. The returned vector MUST have
length == self.dim(). Implementations may normalize.Source§fn model_id(&self) -> &str
fn model_id(&self) -> &str
Stable identifier for the model used. Stored alongside each
embedding so retrieval can detect cross-model mismatches and
skip the cosine blend rather than comparing apples-to-oranges.
Source§fn dim(&self) -> usize
fn dim(&self) -> usize
Embedding dimension. Used by the BLOB codec to validate
stored vectors against the active model on retrieval.
Source§fn is_noop(&self) -> bool
fn is_noop(&self) -> bool
Convenience: true when this embedder is the production no-op.
Callers can short-circuit the write/retrieval cosine path
instead of allocating a vec only to discard it.
Source§fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedderError>
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbedderError>
Embed many texts in as few backend calls as possible. The
production fastembed backend runs them through ONNX in batched
tensors (~10-40x faster than calling
embed per text). The
returned Vec is 1:1 with texts (same order, same length).
The default impl loops embed, so non-batching embedders work
unchanged. On any failure the whole batch errors — callers that
want per-row resilience should fall back to embed per text.Auto Trait Implementations§
impl Freeze for StubEmbedder
impl RefUnwindSafe for StubEmbedder
impl Send for StubEmbedder
impl Sync for StubEmbedder
impl Unpin for StubEmbedder
impl UnsafeUnpin for StubEmbedder
impl UnwindSafe for StubEmbedder
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