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.