Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn dimensions(&self) -> usize;
    fn embed(&self, text: &str) -> Result<Vec<f32>>;

    // Provided method
    fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>> { ... }
}
Expand description

A text → vector embedding model.

Required Methods§

Source

fn dimensions(&self) -> usize

Output dimension; must match the bound vector type’s dimensions.

Source

fn embed(&self, text: &str) -> Result<Vec<f32>>

Embed a single text.

Provided Methods§

Source

fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>

Embed a batch. Default loops embed; implementors may override with a vectorized path.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§