Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn dim(&self) -> usize;
    fn embed(&self, text: &str) -> Result<Embedding>;

    // Provided methods
    fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Embedding>> { ... }
    fn model_id(&self) -> &str { ... }
}
Expand description

The embedding contract every backend implements.

Backends ship in ijima-server (candle is the IA-standard default, consistent with Quantizon); a remote-API backend may follow.

Send + Sync so an Arc<dyn Embedder> can be shared across an async store’s worker pool.

Required Methods§

Source

fn dim(&self) -> usize

Dimensionality of the vectors this embedder produces.

Source

fn embed(&self, text: &str) -> Result<Embedding>

Embeds a single piece of text.

§Errors

Returns crate::IjimaError::Store on a backend failure (model load, inference, device error).

Provided Methods§

Source

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

Embeds a batch of texts. The default loops over [embed]; backends with batch acceleration override this.

§Errors

Propagates any per-item embedding error.

Source

fn model_id(&self) -> &str

The model id that produced these embeddings (e.g. sentence-transformers/all-MiniLM-L6-v2@main). Used for embedding provenance (D10): memories stamp the model that embedded them, so a model swap is detectable and a re-embed pass can be triggered rather than silently producing incomparable vectors. Default "unknown" for backends that don’t track it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§