Skip to main content

Embedder

Trait Embedder 

Source
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§

Source

fn embed<'a>(&'a self, text: &'a str) -> EmbedFuture<'a>

Embed a single text. Returns a vector of f32.

Source

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.

Source

fn model_name(&self) -> &str

The model name this embedder uses.

Source

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§

Source§

impl Embedder for BgeM3Embedder

BgeM3Embedder also implements the standard Embedder trait for compatibility, returning only the dense representation.

Source§

impl Embedder for MockEmbedder

Source§

impl Embedder for OllamaEmbedder