Trait Embeddings

Source
pub trait Embeddings:
    Send
    + Sync
    + 'static {
    // Required methods
    fn dimension(&self) -> usize;
    fn embed_query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Embedding>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn model_name(&self) -> &str;

    // Provided methods
    fn embed_documents<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn model_type(&self) -> &str { ... }
}
Expand description

Base trait for all embedding models

Required Methods§

Source

fn dimension(&self) -> usize

Get the dimension of the embeddings produced by this model

Source

fn embed_query<'life0, 'life1, 'async_trait>( &'life0 self, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Embedding>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Embed a single text

Source

fn model_name(&self) -> &str

Get the model name

Provided Methods§

Source

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

Embed multiple texts

Source

fn model_type(&self) -> &str

Get the model type

Implementors§