Skip to main content

EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn version(&self) -> &str;
    fn dimension(&self) -> u32;
    fn embed_batch(&self, texts: &[&str]) -> OrbokResult<Vec<Vec<f32>>>;

    // Provided method
    fn embed_batch_with_stats(
        &self,
        texts: &[&str],
    ) -> OrbokResult<(Vec<Vec<f32>>, Option<EmbeddingBatchStats>)> { ... }
}
Expand description

Local embedding model abstraction (RFC-008 §6).

Implementations must not transmit text externally (NFR-001).

Required Methods§

Source

fn name(&self) -> &str

Stable name stored in models.model_name.

Source

fn version(&self) -> &str

Version string stored in models.model_version.

Source

fn dimension(&self) -> u32

Output dimension — must match stored embeddings (RFC-008 §11).

Source

fn embed_batch(&self, texts: &[&str]) -> OrbokResult<Vec<Vec<f32>>>

Embed a batch of normalized texts. Returns one vector per input, each L2-normalized.

Provided Methods§

Source

fn embed_batch_with_stats( &self, texts: &[&str], ) -> OrbokResult<(Vec<Vec<f32>>, Option<EmbeddingBatchStats>)>

embed_batch, plus this call’s batch statistics (RFC-048 Task 011) — None when a backend doesn’t track them. The default implementation delegates to embed_batch and reports no stats, so every existing backend and call site is unaffected; a backend that can report real figures overrides this instead, as a byproduct of work it already performs, adding no cost to plain embed_batch.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§