Skip to main content

EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel: Send + Sync {
    // Required methods
    fn embed(
        &self,
        texts: &[&str],
    ) -> impl Future<Output = Result<Vec<Vec<f32>>>> + Send;
    fn dimensions(&self) -> usize;
}
Expand description

Trait for models that produce vector embeddings from text.

Implement this for your embedding provider, then use it with vector stores and RAG pipelines.

Required Methods§

Source

fn embed( &self, texts: &[&str], ) -> impl Future<Output = Result<Vec<Vec<f32>>>> + Send

Computes embeddings for one or more texts. Returns one vector per input.

Source

fn dimensions(&self) -> usize

Returns the dimensionality of the embedding vectors this model produces.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§