Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required method
    fn embed(&self, texts: &[&str]) -> Vec<Vec<f32>>;

    // Provided method
    fn id(&self) -> &str { ... }
}
Expand description

A backend that produces dense embedding vectors for a slice of input texts.

Implementations must be deterministic for a given input set (otherwise the semantic axis becomes flappy across runs). Vector dimensionality is implementation-defined; only the requirement “every output vector has the same length” is enforced — the cosine math handles any dimensionality.

Required Methods§

Source

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

Embed each text in texts. The returned vector at position i is the embedding for texts[i]. All vectors must have the same length (panics on mismatched dimensionality are a contract bug; the caller will validate before computing cosine).

Provided Methods§

Source

fn id(&self) -> &str

Optional: a stable identifier for the embedder, included in diagnostic output so a user can tell at a glance which embedder produced a given semantic-axis score.

Implementors§

Source§

impl<F> Embedder for BoxedEmbedder<F>
where F: Fn(&[&str]) -> Vec<Vec<f32>> + Send + Sync,