Skip to main content

Embedder

Trait Embedder 

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

Produces dense vectors for text. Must be deterministic for a given (model, input) so persisted vectors stay comparable across runs.

Required Methods§

Source

fn model_id(&self) -> &str

Stable model id (e.g. "bge-m3"), persisted beside each vector so a model change can be detected and the corpus re-indexed.

Source

fn dim(&self) -> usize

Embedding dimensionality.

Source

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

Embed a batch of texts → one vector per input, in order.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§