Skip to main content

QueryEmbedder

Trait QueryEmbedder 

Source
pub trait QueryEmbedder:
    Send
    + Sync
    + Debug {
    // Required methods
    fn embed_query(&self, text: &str) -> Result<Vec<f32>, EmbedderError>;
    fn identity(&self) -> QueryEmbedderIdentity;
    fn max_tokens(&self) -> usize;
}
Expand description

A read-time query embedder.

Implementations must be Send + Sync so the coordinator can share a single Arc<dyn QueryEmbedder> across reader threads without cloning per call. All methods are &self — embedders are expected to be internally immutable or to manage their own interior mutability.

Required Methods§

Source

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

Embed a single query string into a dense vector.

§Errors

Returns EmbedderError::Unavailable if the embedder cannot produce a vector right now (e.g. the model weights failed to load under a feature-flag stub), or EmbedderError::Failed if the embedding pipeline itself errored. The coordinator treats either variant as a graceful degradation, NOT a hard query failure.

Source

fn identity(&self) -> QueryEmbedderIdentity

Model identity / version / dimension / normalization identity.

Must match the write-time contract for the corresponding vec table. Phase 12.5a does not yet enforce the match at runtime; Phase 12.5b will gate the vector branch on identity() equality with the active vector profile.

Source

fn max_tokens(&self) -> usize

Maximum number of tokens this embedder can process in one call.

The write-time chunker uses this to size text chunks: content that fits within max_tokens() is stored as one chunk; content exceeding it is split at token boundaries. BGE-small-en-v1.5 has a 512-token context window; long-context embedders (Nomic, Jina) return 8192.

Implementors§