EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel:
    Send
    + Sync
    + Any {
    // Required methods
    fn embed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: Vec<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn dimensions(&self) -> u32;
    fn model_id(&self) -> &str;

    // Provided method
    fn warmup<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A model that produces dense vector embeddings from text.

Required Methods§

Source

fn embed<'life0, 'life1, 'async_trait>( &'life0 self, texts: Vec<&'life1 str>, ) -> 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 text strings into dense vectors.

Returns one Vec<f32> per input text, each with dimensions() elements.

Source

fn dimensions(&self) -> u32

The dimensionality of the embedding vectors produced by this model.

Source

fn model_id(&self) -> &str

The underlying model identifier (e.g. a HuggingFace repo ID or API model name).

Provided Methods§

Source

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

Optional warmup hook (e.g. load weights into memory on first access). The default is a no-op.

Implementors§