Qwen3-Embedding-0.6B Core AI fp16 bundle (s512) + tokenizer + reference + card
Browse filesFiles changed (9)
- .gitattributes+2
- README.mdAdded+89
- qwen3-embedding-0.6b_float16_s512_static.aimodel/main.hashAdded+1
- qwen3-embedding-0.6b_float16_s512_static.aimodel/main.mlirbAdded+3
- qwen3-embedding-0.6b_float16_s512_static.aimodel/metadata.jsonAdded+7
- reference.jsonAdded
- tokenizer/chat_template.jinjaAdded+85
- tokenizer/tokenizer.jsonAdded+3
- tokenizer/tokenizer_config.jsonAdded+15
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines333435363732 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textqwen3-embedding-0.6b_float16_s512_static.aimodel/main.mlirb filter=lfs diff=lfs merge=lfs -texttokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889---license: apache-2.0base_model: Qwen/Qwen3-Embedding-0.6Btags: - coreai - sentence-similarity - feature-extraction - apple-silicon - on-devicelanguage: - multilingualpipeline_tag: sentence-similarity---
# Qwen3-Embedding-0.6B — Core AI export
[Qwen/Qwen3-Embedding-0.6B](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B) as a single staticCore AI graph for macOS 27 / iOS 27: the full sentence-transformers pipeline (Qwen3-0.6B backbone→ **last-token pooling** → **L2 normalize**) runs in-graph, so one call returns a normalized,**MRL-truncatable 1024-d** embedding. Multilingual (incl. Japanese), instruction-awareon-device semantic search / RAG.
**This is an encoder** — one forward over the (right-padded) input → one pooled vector. Noautoregressive loop, no KV cache, no LM head. It runs as a plain `.aimodel` via `AIModel.run`(like the vision encoders), not the pipelined generate engine.
## Graph contract
| | name | shape | dtype ||---|---|---|---|| input | `input_ids` | [1, 512] | int32 (right-padded; pad id 151643) || input | `attention_mask` | [1, 512] | int32 (1 = real token, 0 = padding) || output | `embedding` | [1, 1024] | fp16, L2-normalized |
The grid (512) is an export-time choice — a smaller grid is proportionally faster for shortqueries. Last-token pooling under the causal mask is right-pad safe (real tokens never attend totrailing pads), so the host just right-pads to the grid.
## Host recipe (everything else is in-graph)
- **Query** → prepend the instruction prefix: `Instruct: Given a web search query, retrieve relevant passages that answer the query\nQuery:` **Document** → no prefix.- Tokenize, **right-pad** to 512 (truncate longer text). Run → 1024-d unit vector.- **Similarity** = cosine = dot product (vectors are unit-norm).- **Matryoshka (MRL)**: to shrink, take the first D dims (32 ≤ D ≤ 1024) and **re-L2-normalize** on the host. Rankings are preserved down to 256; verified to 128.
```python# Core AI runtime (Python), GPU delegateimport coreai.runtime as rt, numpy as npfrom transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("tokenizer")m = await rt.AIModel.load("qwen3-embedding-0.6b_float16_s512_static.aimodel", rt.SpecializationOptions.from_preferred_compute_unit_kind(rt.ComputeUnitKind.gpu()))fn = m.load_function("main")
def embed(text, is_query): prefix = ("Instruct: Given a web search query, retrieve relevant passages that " "answer the query\nQuery:") if is_query else "" enc = tok(prefix + text, padding="max_length", truncation=True, max_length=512, return_tensors="np", padding_side="right") res = await fn({"input_ids": rt.NDArray(enc["input_ids"].astype(np.int32)), "attention_mask": rt.NDArray(enc["attention_mask"].astype(np.int32))}) return res["embedding"].numpy()[0] # [1024], unit-norm```
## Bundle layout
```qwen3-embedding-0.6b_float16_s512_static.aimodel (~1.1 GB, fp16)tokenizer/ (HF tokenizer files)reference.json (torch reference embeddings + cosines)```
## Parity
Precision **fp16**. Verified against the official `sentence-transformers` pipeline (fp32):per-text embedding cosine **1.000000**, retrieval order identical, MRL rankings preserved at512 / 256 / 128. On the Core AI GPU delegate the `.aimodel` reproduces the torch reference atcosine **0.999998** end-to-end (host tokenize → run). Measured ~25 ms (256-grid) / ~45 ms(512-grid) per embedding on an M4 Max GPU.
## License
Apache-2.0 (upstream model and code are Apache-2.0). Conversion script:[`conversion/export_qwen3_embedding.py`](https://github.com/john-rocky/coreai-model-zoo/blob/main/conversion/export_qwen3_embedding.py)in the coreai-model-zoo.1B
�e��������!+���es�ȓ=M6�b?�s_123version https://git-lfs.github.com/spec/v1oid sha256:420dd36581e8feb1afed13b8f6212b89d2e06573c2c8933d4d36e8623f89735fsize 11924976961234567{ "description" : "Qwen3-Embedding-0.6B text embedding model (Qwen3-0.6B backbone, last-token pooling, L2-normalized 1024-d, MRL-truncatable 32-1024). Source: https:\/\/huggingface.co\/Qwen\/Qwen3-Embedding-0.6B", "creationDate" : "20260614T050108Z", "author" : "Alibaba Qwen", "assetVersion" : "2.0", "license" : "Apache-2.0"}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485{%- if tools %} {{- '<|im_start|>system\n' }} {%- if messages[0].role == 'system' %} {{- messages[0].content + '\n\n' }} {%- endif %} {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }} {%- for tool in tools %} {{- "\n" }} {{- tool | tojson }} {%- endfor %} {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}{%- else %} {%- if messages[0].role == 'system' %} {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} {%- endif %}{%- endif %}{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}{%- for message in messages[::-1] %} {%- set index = (messages|length - 1) - loop.index0 %} {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %} {%- set ns.multi_step_tool = false %} {%- set ns.last_query_index = index %} {%- endif %}{%- endfor %}{%- for message in messages %} {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} {%- elif message.role == "assistant" %} {%- set content = message.content %} {%- set reasoning_content = '' %} {%- if message.reasoning_content is defined and message.reasoning_content is not none %} {%- set reasoning_content = message.reasoning_content %} {%- else %} {%- if '</think>' in message.content %} {%- set content = message.content.split('</think>')[-1].lstrip('\n') %} {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %} {%- endif %} {%- endif %} {%- if loop.index0 > ns.last_query_index %} {%- if loop.last or (not loop.last and reasoning_content) %} {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }} {%- else %} {{- '<|im_start|>' + message.role + '\n' + content }} {%- endif %} {%- else %} {{- '<|im_start|>' + message.role + '\n' + content }} {%- endif %} {%- if message.tool_calls %} {%- for tool_call in message.tool_calls %} {%- if (loop.first and content) or (not loop.first) %} {{- '\n' }} {%- endif %} {%- if tool_call.function %} {%- set tool_call = tool_call.function %} {%- endif %} {{- '<tool_call>\n{"name": "' }} {{- tool_call.name }} {{- '", "arguments": ' }} {%- if tool_call.arguments is string %} {{- tool_call.arguments }} {%- else %} {{- tool_call.arguments | tojson }} {%- endif %} {{- '}\n</tool_call>' }} {%- endfor %} {%- endif %} {{- '<|im_end|>\n' }} {%- elif message.role == "tool" %} {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} {{- '<|im_start|>user' }} {%- endif %} {{- '\n<tool_response>\n' }} {{- message.content }} {{- '\n</tool_response>' }} {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} {{- '<|im_end|>\n' }} {%- endif %} {%- endif %}{%- endfor %}{%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }} {%- if enable_thinking is defined and enable_thinking is false %} {{- '<think>\n\n</think>\n\n' }} {%- endif %}{%- endif %}123version https://git-lfs.github.com/spec/v1oid sha256:4b325f4efa94e389220ec20b055177a846870f4614762b59b1d6c7450c2830ecsize 11423979123456789101112131415{ "add_prefix_space": false, "backend": "tokenizers", "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "is_local": false, "local_files_only": false, "model_max_length": 32768, "pad_token": "<|endoftext|>", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null}.gitattributes+2
README.mdAdded+89
qwen3-embedding-0.6b_float16_s512_static.aimodel/main.hashAdded+1
qwen3-embedding-0.6b_float16_s512_static.aimodel/main.mlirbAdded+3
qwen3-embedding-0.6b_float16_s512_static.aimodel/metadata.jsonAdded+7
reference.jsonAdded
tokenizer/chat_template.jinjaAdded+85
tokenizer/tokenizer.jsonAdded+3
tokenizer/tokenizer_config.jsonAdded+15