Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: EmbedderBound {
Show 14 methods // Required method fn embed_dense<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, QqlError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; // Provided methods fn embed_sparse<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<SparseVector, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_sparse_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SparseVector>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_joint<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<JointEmbeddingOutput, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_joint_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<JointEmbeddingOutput>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn dimension(&self) -> Option<usize> { ... } fn multi_dimension(&self) -> Option<usize> { ... } fn accepts_model(&self, _model: &str) -> bool { ... } fn embed_dense_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_multi<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_multi_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Vec<f32>>>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_image<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, source: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn embed_image_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, sources: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn rerank_pairs<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, query: &'life1 str, documents: &'life2 [String], model: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, QqlError>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait { ... }
}
Expand description

Host-agnostic embedding backend.

Dense calls should batch when possible (embed_dense_batch → one HTTP request or one ONNX batch). Sparse defaults to local BM25-style hashing. Multivector (ColBERT-style) uses Self::embed_multiVec<Vec<f32>>.

Required Methods§

Source

fn embed_dense<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, QqlError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Provided Methods§

Source

fn embed_sparse<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<SparseVector, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sparse embedding (BM25-like local hash or model-aware SPLADE / BGE-M3).

Default implementation uses local BM25 hashing when model is empty or "default". Non-default sparse models are rejected — override this method to provide model-aware sparse inference.

Source

fn embed_sparse_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SparseVector>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batch sparse embedding. Default loops Self::embed_sparse.

Source

fn embed_joint<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<JointEmbeddingOutput, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Single-pass joint multi-modal / BGE-M3 embedding (dense + sparse + multi-vectors).

Default implementation delegates to separate dense, sparse, and multi calls. Override this to make a single inference pass (e.g. Bgem3Embedding::embed). The default propagates the first error and does not suppress failures.

Source

fn embed_joint_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<JointEmbeddingOutput>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batch joint embedding. Default loops Self::embed_joint.

Source

fn dimension(&self) -> Option<usize>

Dense output dimension when it is known without running inference. Custom and remote embedders may return None.

Source

fn multi_dimension(&self) -> Option<usize>

Multivector (ColBERT) per-token dimension when known without inference.

Source

fn accepts_model(&self, _model: &str) -> bool

Whether this embedder can satisfy a requested model identifier. Dynamic providers may return true for every model.

Source

fn embed_dense_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Embed many texts in one shot. Default loops embed_dense; override for real batching (OpenAI-compatible input: [...], fastembed batch, etc.).

Source

fn embed_multi<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, text: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Multivector embedding (ColBERT-style late interaction).

Returns one dense vector per token/segment. Default rejects so hosts that only support single-vector dense must opt in explicitly.

Source

fn embed_multi_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, texts: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Vec<f32>>>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batch multivector embedding. Default loops Self::embed_multi.

Source

fn embed_image<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, source: &'life1 str, model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Image / CLIP vision embedding. source is a filesystem path or URL.

Returns a single dense vector in the same space as the paired text encoder (e.g. CLIP). Default rejects until the host opts in.

Source

fn embed_image_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, sources: &'life1 [String], model: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batch image embedding. Default loops Self::embed_image.

Source

fn rerank_pairs<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, query: &'life1 str, documents: &'life2 [String], model: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, QqlError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Cross-encoder pair scores: (query, documents[i]) → score.

Returns one score per document in the same order as documents (not sorted). Hosts that return ranked results must unpermute. Default rejects until the host opts in (edge TextRerank, HTTP rerank API).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§