Browser-focused ONNX export of
Nanbeige/Nanbeige4.2-3B
for Transformers.js and ONNX Runtime Web.
This export currently requires the ONNX Runtime Web development build used by
Shlvl because MatMulNBitsMlp has not reached a stable release.
1import { pipeline } from "@huggingface/transformers";
2
3const generator = await pipeline(
4 "text-generation",
5 "Michionlion/Nanbeige4.2-3B-ONNX-WebGPU",
6 {
7 device: "webgpu",
8 dtype: "q4f16",
9 model_file_name: "model_webgpu_mlp",
10 use_external_data_format: 2,
11 },
12);
The two external-data shards are approximately 1.89 GB and 1.19 GB. Shlvl
pins the Hub revision used in production and adds a guarded Apple subgroup
reduction for the generated q4 decode shaders; other devices use ONNX Runtime's
default kernels.
The tiny fp32 export matched the source PyTorch model for both prefill and
cached decode. Full-model paired browser tests retained exact token
fingerprints for a 512-token prompt followed by 128 greedy tokens and for a
separate chat-like prompt.
This is an experimental browser export. Reduction-order changes in optimized
GPU kernels can change close greedy decisions, so evaluate it for your use
case before relying on exact reproducibility.