Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder:
    Send
    + Sync
    + Debug {
    // Required methods
    fn model(&self) -> &str;
    fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, Error>;
    fn dimension(&self) -> usize;
}
Expand description

Turns texts into vectors of one dimension.

Required Methods§

Source

fn model(&self) -> &str

Names the model, so vectors from another one are never compared with these: static:<file name> or local:<program>.

Source

fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, Error>

One vector per text, in order, each dimension long. A text the model has nothing for gets zeros.

Source

fn dimension(&self) -> usize

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§