pub trait Embedder: Send + Sync {
// Required methods
fn embed(&self, text: &str) -> Vec<f32>;
fn dim(&self) -> usize;
fn name(&self) -> &str;
// Provided method
fn embed_batch(&self, texts: &[String]) -> Vec<Vec<f32>> { ... }
}Expand description
A backend that maps text to a fixed-dimension embedding vector.
Implementations must be Send + Sync so the capability can share one
instance across every Harn VM / thread, matching the code_index
concurrency model. Vectors returned SHOULD be L2-normalized so the
cosine math degenerates to a dot product, but [super::similarity]
normalizes defensively regardless.
Required Methods§
Provided Methods§
Sourcefn embed_batch(&self, texts: &[String]) -> Vec<Vec<f32>>
fn embed_batch(&self, texts: &[String]) -> Vec<Vec<f32>>
Embed a batch. Default maps Embedder::embed; backends with a
cheaper batched path may override.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".