Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn embed(&self, text: &str) -> Result<Vec<f32>>;
}
Expand description

Turns text into a vector. Not implemented by soma: the seam exists so an embedding model can be plugged in from outside (a sentence-transformer behind the Python worker, an HTTP endpoint) without soma taking a dependency on one.

id identifies the model. It is stored next to every vector so vectors from different models are never silently compared — a cosine between two different embedding spaces is a number, not a similarity.

Required Methods§

Source

fn id(&self) -> &str

Stable identifier of the model, e.g. "minilm-l6-v2".

Source

fn embed(&self, text: &str) -> Result<Vec<f32>>

Embed one text.

Implementors§