pub enum Embedder {
Local {
model: Arc<Mutex<BertModel>>,
tokenizer: Arc<Tokenizer>,
device: Device,
},
Ollama {
client: Arc<OllamaClient>,
model_name: String,
},
}Expand description
Semantic embedding engine supporting multiple backends.
- Local (candle): all-MiniLM-L6-v2, 384-dim. Used at the semantic tier.
- Ollama: nomic-embed-text-v1.5, 768-dim. Used at smart/autonomous tiers.
Variants§
Local
Candle-based local embedding (MiniLM-L6-v2, 384-dim)
Ollama
Ollama-based embedding (nomic-embed-text-v1.5, 768-dim)
Implementations§
Source§impl Embedder
impl Embedder
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new local (candle) embedder for MiniLM-L6-v2. Downloads the model if it is not already cached.
Sourcepub fn new_ollama(client: Arc<OllamaClient>) -> Self
pub fn new_ollama(client: Arc<OllamaClient>) -> Self
Create an Ollama-based embedder for nomic-embed-text-v1.5 (768-dim).
Requires the Ollama client to already be connected and the model pulled.
Sourcepub fn for_model(
model: EmbeddingModel,
ollama_client: Option<Arc<OllamaClient>>,
) -> Result<Self>
pub fn for_model( model: EmbeddingModel, ollama_client: Option<Arc<OllamaClient>>, ) -> Result<Self>
Create an embedder for the specified model.
MiniLmL6V2→ local candle embedderNomicEmbedV15→ Ollama-based (requiresollama_client)
Sourcepub fn model_description(&self) -> &str
pub fn model_description(&self) -> &str
Human-readable description of the active embedding model.
Sourcepub fn embed(&self, text: &str) -> Result<Vec<f32>>
pub fn embed(&self, text: &str) -> Result<Vec<f32>>
Generate an embedding for a single text input.
Sourcepub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
pub fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
Generate embeddings for multiple texts in one call.
Sourcepub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
Compute cosine similarity between two embedding vectors.
Sourcepub fn fuse(primary: &[f32], secondary: &[f32], primary_weight: f32) -> Vec<f32>
pub fn fuse(primary: &[f32], secondary: &[f32], primary_weight: f32) -> Vec<f32>
Fuse a primary query embedding with a secondary context embedding via weighted linear combination (v0.6.0.0 contextual recall).
primary_weight clamped to [0.0, 1.0]. The result is returned
un-normalized — cosine_similarity divides out magnitudes, so the
downstream signal is direction-only. Returns primary.to_vec() when
dimensions differ (graceful fallback, same policy as
cosine_similarity).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Embedder
impl !RefUnwindSafe for Embedder
impl Send for Embedder
impl Sync for Embedder
impl Unpin for Embedder
impl UnsafeUnpin for Embedder
impl !UnwindSafe for Embedder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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