Skip to main content

Crate rightkit_embed

Crate rightkit_embed 

Source
Expand description

Local embeddings and a persistent cosine vector store.

Feature boundaries: inference (ONNX text embedder) and vector (SQLite-backed cosine store). Both are default-on; a vector-only build does not pull ort or tokenizers.

Structs§

AcceleratorParity
Result of the load-time vector parity check an accelerator passed; see Embedder::accelerator_parity.
CoreMlUnits
The compute units of each Core ML function (embed_32 .. embed_512).
CoreMlUnitsParseError
An unreadable compute-unit or unit-map specification.
Embedder
EmbedderConfig
LoadTimings
Where an E40 load spent its time; see Embedder::load_timings. Phases are wall-clock durations of the work as Embedder::load ran it; they nest (session_creates happen inside the probe and the parity check) and do not add up to total exactly.
Nearest
SessionCreate
One graph build during an E40 load.
VectorStore

Enums§

CoreMlComputeUnit
Which Core ML compute units run one function (MLComputeUnits).
EmbedError
ExecutionProvider
Where inference runs.
ParityCacheOutcome
What the load-time parity check did with the opt-in verdict cache (EmbedderConfig::with_parity_cache_dir).
VectorError

Constants§

ACCELERATOR_PARITY_MIN_COSINE
An accelerator is admitted only if every parity prompt’s native-dimension vector has at least this cosine similarity to the CPU provider’s vector for the same prompt. Two correct runs of the same Q4 graph agree at about 0.999; a DirectML run of EmbeddingGemma 2 Q4 measured 0.58-0.72.
DEFAULT_MAX_BATCH
Default rows per ONNX call for embed_batch / embed_query_batch.
DEFAULT_VECTOR_DIM
EMBEDDINGGEMMA2_COREML_MODEL_ID
EmbeddingGemma 2 Core ML build (macOS 15+): EmbeddingGemma2Text.mlpackage (one fixed-shape function per length 32, 64, 128, 256, 512) and a host-side bf16 token table, run through the Core ML framework directly (an .mlpackage cannot be loaded through ONNX Runtime). Selected when the model directory holds that layout. Same weights, different numerics from the Q4 and E40 models, so a different pipeline id.
EMBEDDINGGEMMA2_E40_MODEL_ID
EmbeddingGemma 2 E40 export: fp16, five fixed-length graphs and a host-side token table (embed_tokens.f16.npy), run on DirectML (Windows) or CPU. Selected when the model directory holds that layout. Same weights as the Q4 model, different numerics, so a different pipeline id.
EMBEDDINGGEMMA2_MODEL_ID
EmbeddingGemma 2 text-only Q4 export (b64, accuracy level 4). Selected when the model directory’s top-level config.json model_type is embedding_gemma2.
EMBEDDINGGEMMA_MODEL_ID
NEURAL_ENGINE_MAX_TOKENS
Longest graph (in tokens) the default map sends to the Neural Engine; longer graphs use the GPU.

Functions§

cosine_similarity
truncate_and_normalize