Skip to main content

Embedder

Trait Embedder 

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

The embedding seam (spec.md#search): text in, vectors out. The real backend is CandleEmbedder; tests substitute an instrumented fake to assert batching behavior. The vector width is checked at the write boundary and the model id is whatever model_id returns at the time of the write.

Required Methods§

Source

fn device(&self) -> &str

A short label naming the hardware/runtime: "metal", "cuda", or "cpu". Used by pond embed to surface what backend ran the inference; benches print it alongside latency.

Source

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

Embed a batch of texts. The returned vectors are L2-normalized and embedding_dim long, one per input.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§