Skip to main content

Embedder

Trait Embedder 

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

Turn text into dense vectors. Implementations must return one vector per input string, each of length Embedder::dim.

Required Methods§

Source

fn dim(&self) -> usize

The fixed output dimension. Must equal the vector(N) column width.

Source

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

Embed a batch of texts. Returns texts.len() vectors, each dim() long.

§Errors

Returns an error if the backing embedding service fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§