pub trait Embedder: Send + Sync {
// Required methods
fn embed<'a>(&'a self, text: &'a str) -> EmbedFuture<'a>;
fn embed_batch<'a>(&'a self, texts: Vec<String>) -> EmbedBatchFuture<'a>;
fn model_name(&self) -> &str;
fn dimensions(&self) -> usize;
}Expand description
Trait for embedding text into vectors.
Implement this to swap embedding providers.
Required Methods§
Sourcefn embed<'a>(&'a self, text: &'a str) -> EmbedFuture<'a>
fn embed<'a>(&'a self, text: &'a str) -> EmbedFuture<'a>
Embed a single text. Returns a vector of f32.
Sourcefn embed_batch<'a>(&'a self, texts: Vec<String>) -> EmbedBatchFuture<'a>
fn embed_batch<'a>(&'a self, texts: Vec<String>) -> EmbedBatchFuture<'a>
Embed multiple texts in a batch.
Takes owned strings to avoid lifetime issues across async boundaries.
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
The model name this embedder uses.
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Expected embedding dimensions.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Embedder for BgeM3Embedder
BgeM3Embedder also implements the standard Embedder trait for compatibility,
returning only the dense representation.