Skip to main content

EmbeddingBackend

Trait EmbeddingBackend 

Source
pub trait EmbeddingBackend: Send + Sync {
    // Required methods
    fn embedding_dimension(&self) -> usize;
    fn is_bert_based(&self) -> bool;
    fn process_batch<'life0, 'async_trait>(
        &'life0 self,
        texts: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A backend capable of producing embedding vectors for a batch of texts.

Required Methods§

Source

fn embedding_dimension(&self) -> usize

Dimension of the produced embedding vectors.

Source

fn is_bert_based(&self) -> bool

Whether this backend runs a BERT-style model. BERT backends are routed through the engine’s concurrency controller, timeout, and adaptive batching machinery; non-BERT backends are invoked directly.

Source

fn process_batch<'life0, 'async_trait>( &'life0 self, texts: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process a batch of texts and return one embedding vector per text. The engine slices large inputs into chunks no larger than the engine’s current_batch_size before calling this method.

Implementors§