Skip to main content

EmbeddingModel

Trait EmbeddingModel 

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

Produces a fixed-dimension float vector from a text input.

Implementations must be deterministic: embedding the same input twice returns identical vectors. The returned vector’s length must equal Self::dimensions.

Required Methods§

Source

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

Embeds text into a Self::dimensions-length vector.

§Errors

Returns EmbeddingError::Embed when inference fails. Init-time failures surface from the implementation’s constructor.

Source

fn dimensions(&self) -> usize

Returns the dimension of vectors produced by Self::embed.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: EmbeddingModel> EmbeddingModel for Arc<T>

Source§

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

Source§

fn dimensions(&self) -> usize

Implementors§