Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn identity(&self) -> EmbedderIdentity;
    fn embed(&self, input: &str) -> Result<Vector, EmbedderError>;

    // Provided method
    fn embed_batch(&self, inputs: &[&str]) -> Result<Vec<Vector>, EmbedderError> { ... }
}

Required Methods§

Provided Methods§

Source

fn embed_batch(&self, inputs: &[&str]) -> Result<Vec<Vector>, EmbedderError>

Embed many inputs in one call. The default implementation loops embed, so every backend works unchanged; backends with a true batched forward (e.g. the candle GPU path) override this to amortize per-call overhead and saturate the device (minutes -> seconds on a full-corpus embed).

Contract: embed_batch MUST be numerically equivalent (within float tolerance) to calling embed on each input, so a caller can switch to batching WITHOUT changing the vectors written to an index. Locked by a parity test in the default-embedder crate.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§