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;
// Provided methods
fn embed_multi_optional<'a>(
&'a self,
_text: &'a str,
) -> OptionalMultiEmbedFuture<'a> { ... }
fn embed_batch_multi_optional<'a>(
&'a self,
texts: Vec<String>,
) -> OptionalMultiEmbedBatchFuture<'a> { ... }
}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.
Provided Methods§
Sourcefn embed_multi_optional<'a>(
&'a self,
_text: &'a str,
) -> OptionalMultiEmbedFuture<'a>
fn embed_multi_optional<'a>( &'a self, _text: &'a str, ) -> OptionalMultiEmbedFuture<'a>
Optionally produce dense and sparse representations in one model call.
Existing dense-only embedders remain source-compatible and report no sparse capability. Callers may derive a generic sparse vector from the dense output only when explicitly configured to do so.
Sourcefn embed_batch_multi_optional<'a>(
&'a self,
texts: Vec<String>,
) -> OptionalMultiEmbedBatchFuture<'a>
fn embed_batch_multi_optional<'a>( &'a self, texts: Vec<String>, ) -> OptionalMultiEmbedBatchFuture<'a>
Optionally produce batched dense and sparse representations.
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.