Views
No views yet
nicolasembleton/Nanbeige4.2-3B-GGUF (native/server-side via llama.cpp, Ollama, LM Studio).num_loops=2 — two passes per physical layer). Stock ONNX Runtime Web doesn't have a MatMulNBits loop unroller for this. We solve it by unrolling the loop at the Python level: 44 sequential layer calls share 22 weight matrices. The exported graph is a standard ONNX opset-18 graph that runs in stock ONNX Runtime Web and transformers.js — no custom kernels needed.model.onnx — 1.8 MB graphmodel.onnx_data — 4.0 GB consolidated BF16 weightsconfig.json, tokenizer*, vocab.json, etc.1import * as ort from "onnxruntime-web";
2
3const session = await ort.InferenceSession.create(
4 "https://huggingface.co/nicolasembleton/Nanbeige4.2-3B-ONNX/resolve/main/model.onnx",
5 { executionProviders: ["webgpu", "wasm"] }, // Safari 17 macOS falls back to WASM
6);
7
8const tokens = [166100, 1234, 5678]; // your token ids
9const feeds = {
10 input_ids: new ort.Tensor("int64", BigInt64Array.from(tokens.map(BigInt)), [1, tokens.length]),
11 attention_mask: new ort.Tensor("int64", BigInt64Array.from(tokens.map(() => 1n)), [1, tokens.length]),
12 position_ids: new ort.Tensor("int64", BigInt64Array.from(tokens.map((_, i) => BigInt(i))), [1, tokens.length]),
13};
14const { logits } = await session.run(feeds);1import { pipeline } from "@huggingface/transformers";
2
3const generator = await pipeline(
4 "text-generation",
5 "nicolasembleton/Nanbeige4.2-3B-ONNX",
6 { device: "webgpu" }, // or "wasm"
7);
8const output = await generator("Hello, how are you?", { max_new_tokens: 256 });Note: This model is prefill-only (forward pass, no KV cache baked in). For autoregressive generation you'll need to feed inputs back through and argmax over logits. KV-cache export is a future enhancement.
Safari note: Safari 17+ on macOS Sonoma supports partial WebGPU. iOS Safari has no WebGPU — use the WASM execution provider (slower but works). Node.js also works via WASM.
1@misc{nanbeige42-3b-onnx,
2 title = {{Nanbeige4.2-3B-ONNX}},
3 author = {{nicolasembleton}},
4 year = {{2026}},
5 howpublished = {{Hugging Face}},
6 note = {{Cross-browser ONNX export with Python-level num_loops=2 unroll. BF16, 4 GB.}},
7}}