Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn backend_id(&self) -> &str;
    fn dim(&self) -> usize;
    fn embed(&self, text: &str, tags: &[String]) -> EmbedResult<Vec<f32>>;
}
Expand description

An embedder produces a deterministic, fixed-length vector from a memory’s claim text + tag context.

Backends are pluggable. Two contracts every backend MUST satisfy:

  1. backend_id is stable for the lifetime of the backend version. A (memory_id, backend_id) pair is the durable key on the storage substrate: changing backend_id is how a backend signals “all previously stored vectors are from a different version of me and should be recomputed”.
  2. dim is stable for a given backend_id. If a backend rev changes its dimensionality, that rev MUST surface as a new backend_id so legacy vectors stored under the prior id remain decodable and comparable.

The default backend (lives in local_stub.rs, slice D2-B) is a deterministic placeholder until a real model integration lands.

Required Methods§

Source

fn backend_id(&self) -> &str

Stable identifier for this backend (e.g., "stub:v1", "onnx:minilm-l6").

Source

fn dim(&self) -> usize

Output dimensionality. Must be stable for a given backend_id.

Source

fn embed(&self, text: &str, tags: &[String]) -> EmbedResult<Vec<f32>>

Embed a single text + tags pair into a Vec<f32> of length dim.

Backends MUST verify their own output length and surface a EmbedError::DimensionMismatch when the produced vector does not match the advertised dimension.

Implementors§