Run it — streaming edge assistant
Choose a preset — the model initialises above.
Live token stream
Output streams here token by token.
At a glance
- Repository
- onnx-community/MNN-Pocket-0.3B-ONNX (base taobao-mnn/MNN-Pocket-0.3B)
- Task / API
text-generation· AutoTokenizer + AutoModelForCausalLM.generate()- Architecture
- Qwen3ForCausalLM · 28 layers · 896 hidden · 14 heads / 2 KV heads · head_dim 64 · FFN 2560 · tied embeddings
- Context / vocab
- 40,960 positions (32K deployed) · 65,536 tokens
- Weights loaded
onnx/model_int8.onnx363,746,041 B + tokenizer/config 4,773,412 B = 368.5 MB- Revision
- e16a91daf9a044ed57a28692837d20cd2a75a08f
- License
- Apache-2.0
- Runtime
- Shared Transformers.js 3.7.5 (lib/webai.js) — zero local override
- Backend / dtype
- CPU WASM · int8 (dedicated module Web Worker)
- Special tokens
- <|im_start|> 65511 · <|im_end|> 65512 (EOS) · <|endoftext|> 65510 (EOS/pad) · <think> 65534
- Stage 0 speed
- ~57.1 decode tok/s, TTFT ~139 ms (CPU WASM int8, 3.7.5)
- Why not WebGPU
- WebGPU int8 decodes ~9.1 tok/s — ~5.8× slower than CPU WASM int8 on the same 4.3.2 runtime; the q4f16 export overflows fp16 into repeated backticks
- Baseline APIs
- WebAssembly (SIMD), Web Workers, Cache Storage, File API
Why a 0.3B edge model matters
- Structured extraction without a server Turn emails, tickets and logs into schema-checked JSON on the device that already holds the data.
- Runs where WebGPU doesn't CPU WASM int8 works on any laptop or phone browser — and here it is actually the fastest path for this model.
- Agentic glue at the edge Route a request to a local tool, draft a SQL query or regex, or summarise a doc before anything leaves the tab.
How the API works
Show the code — worker.js generateCompletion(): ChatML → generate() with TextStreamer + InterruptableStoppingCriteria
Show the code — mnn-core.mjs buildChatMlPrompt(): the chat_template.jinja ChatML rendering
Use-case ladder
Basics · Decoding Lab
Greedy T=0.0 vs sampled T=0.7 determinism, a repetition-penalty ablation, and a ChatML / <think> formatting inspector with real token ids.
Practical · Ticket & Log Triage Queue
Pause / Resume / Cancel a structured JSON classification + extraction queue with schema-valid rate and OWASP-safe CSV / JSON exports.
Wild · 4-Regime Edge Stress Suite
Minified noisy logs, an ambiguous command, multi-hop distractors and a 2k-char needle — graded for valid JSON and faithfulness.
Multi-model · MiniLM → MNN-Pocket RAG
all-MiniLM-L6-v2 retrieves top-K passages with exact cosine scores, then MNN-Pocket answers zero-context vs grounded to expose hallucination risk.