Skip to main content

Crate kiromi_ai_embed_onnx

Crate kiromi_ai_embed_onnx 

Source
Expand description

kiromi-ai-embed-onnx — ONNX-backed Embedder plugin for kiromi-ai-memory.

See the mdBook chapter Writing an Embedder for the full extender guide; this crate is the reference implementation.

Slice 1 ships three models: multilingual-e5-small (default, 384d), multilingual-e5-large (1024d), and bge-m3 (1024d). All three are downloaded on first use and cached locally; honour KIROMI_AI_MODEL_CACHE_DIR to pick the cache root.

Programmatic callers construct directly:

let e = kiromi_ai_embed_onnx::multilingual_e5_small()?;

Config-driven callers register the family and build through the registry:

use kiromi_ai_memory::EmbedderRegistry;
let mut registry = EmbedderRegistry::empty();
kiromi_ai_embed_onnx::register(&mut registry);
let _e = registry
    .build("onnx", serde_json::json!({ "model": "multilingual-e5-small" }))
    .await?;

Asymmetric-prefixing convention: every E5/BGE/GTE/Jina-family constructor MUST honour EmbedRole the same way — "passage: " for Document, "query: " for Query. Models in symmetric families (BGE-M3 in our slice-1 menu, SBERT) MUST ignore role. See spec § 12.12 and the conformance harness in kiromi-ai-test-suite.

Structs§

OnnxConfig
Config-driven construction of an ONNX embedder.
OnnxEmbedder
fastembed-backed embedder. Construct via from_choice, one of the per-model helper constructors, or crate::register + EmbedderRegistry::build.

Enums§

ModelChoice
Models exposed by the ONNX plugin in slice 1.

Constants§

FAMILY
Family name used in config.toml’s [embedder] table.

Functions§

bge_m3
Convenience constructor — bge-m3.
from_choice
Build an embedder for the given choice, honouring the env-var cache dir.
from_config
Build from a parsed OnnxConfig.
multilingual_e5_large
Convenience constructor — multilingual-e5-large.
multilingual_e5_small
Convenience constructor — multilingual-e5-small. Default model.
register
Register the ONNX family under FAMILY (“onnx”). Calling twice on the same registry replaces the prior factory.

Type Aliases§

MultilingualE5Small
Backwards-compat alias for the Plan-3 MVP type. Soft-deprecated; new code should prefer OnnxEmbedder + the per-model constructors.