Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn dimension(&self) -> usize;
    fn embed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, MemoryError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Compute embeddings for one or more texts.

Output vectors must each be of length Embedder::dimension. Implementations must be deterministic at the type level — the dimensionality cannot vary across calls on the same instance.

Required Methods§

Source

fn dimension(&self) -> usize

Embedding dimensionality. Must be constant for a given Embedder instance — long-term memory backends reject vectors of the wrong length at runtime.

Source

fn embed<'life0, 'life1, 'async_trait>( &'life0 self, texts: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, MemoryError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Compute one embedding per input text.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§