Expand description
Qwen3-Embedding-0.6B provider (ADR-059) — the preferred ECC embedder.
Unlike the BERT OnnxEmbeddingProvider,
Qwen3-Embedding is a causal decoder-with-KV-cache ONNX export. This
provider therefore:
- feeds
input_ids/attention_mask/position_ids(0..seq_len) plus empty, dtype-matchedpast_key_values.*tensors for every layer (shape[1, n_kv_heads, 0, head_dim], derived from the graph — never hardcoded); - pools the last non-pad token hidden state (not mean/CLS);
- applies MRL: slice to the first
QWEN3_DIMSdims, then L2-renormalize; - uses the HF
tokenizerscrate (Qwen3 BPE fromtokenizer.json); - exposes
embed_queryfor the asymmetric query lane (prepends the Qwen3 instruction prefix); theEmbeddingProvider::embedtrait method is document mode.
Without the onnx-embeddings feature, the model file, or the tokenizer, the
provider degrades gracefully to a MockEmbeddingProvider so builds and
tests never require the ~1.2 GB artifact. The BERT provider stays intact as a
lower-priority fallback (see select_embedding_provider).
Structs§
- Qwen3
Embedding Provider - Qwen3-Embedding-0.6B provider — decoder-ONNX, last-token pooling, MRL-512.
Constants§
- QUERY_
INSTRUCTION - Qwen3 asymmetric query instruction prefix. Documents are embedded raw;
queries are prefixed with this (
Instruct: {task}\nQuery: {q}format). The task description is the code-search instruction pinned by the lab probe set (ADR-059 consistency contract) so the lab and prod share one vector space;embed_queryappends the raw query directly after the trailing space. - QWEN3_
DIMS - MRL target dimensionality — the empirical sweet spot (ADR-059, recall@10 0.983).
- QWEN3_
MODEL_ NAME - Canonical model identifier (pins the consistency contract; ADR-059).