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:
backend_idis stable for the lifetime of the backend version. A(memory_id, backend_id)pair is the durable key on the storage substrate: changingbackend_idis how a backend signals “all previously stored vectors are from a different version of me and should be recomputed”.dimis stable for a givenbackend_id. If a backend rev changes its dimensionality, that rev MUST surface as a newbackend_idso 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§
Sourcefn backend_id(&self) -> &str
fn backend_id(&self) -> &str
Stable identifier for this backend (e.g., "stub:v1",
"onnx:minilm-l6").
Sourcefn dim(&self) -> usize
fn dim(&self) -> usize
Output dimensionality. Must be stable for a given
backend_id.
Sourcefn embed(&self, text: &str, tags: &[String]) -> EmbedResult<Vec<f32>>
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.