Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

feat(chrome): add Nanbeige4.2-3B as a WebGPU text preset

Emre Sokullu5818abfb0383
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 491d7e353..bc3efd5db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ This changelog was generated from the repository Git history and release tags. V
### Added
- Added OpenRouter routing variant controls, including support for encoding **Exacto** as an OpenRouter model variant
- Added LFM2.5 1.2B Instruct, 1.2B Thinking, VL 1.6B, and VL 3B to the Chromium WebGPU picker; the VL presets are exposed as multimodal providers
+- Added the Nanbeige4.2-3B ONNX WebGPU export as a Chromium WebGPU text preset, with its non-default graph file name, publisher sampling settings, and a 4k context sized for its 44 KV-cache slots
### Changed
- Restored the **default compact activity history** behavior
diff --git a/docs/apocalypse-mode.md b/docs/apocalypse-mode.md
index 446f71322..5de638453 100644
--- a/docs/apocalypse-mode.md
+++ b/docs/apocalypse-mode.md
@@ -22,8 +22,9 @@ require their own confirmation. The local **text** model defaults to LFM2.5
2.6B (about 1.55 GB), and that download starts automatically when Apocalypse
Mode is enabled. The picker also offers opt-in LFM2.5 1.2B Instruct and
Thinking presets (about 760 MB each), LFM2.5-VL 1.6B and 3B multimodal presets
-(about 2.3 GB and 4.0 GB), and Bonsai 27B (about 3.8 GB, 16 GB+ RAM/VRAM
-recommended). Only the default is auto-downloaded. The two VL choices support
+(about 2.3 GB and 4.0 GB), Nanbeige4.2-3B (about 3.1 GB), and Bonsai 27B
+(about 3.8 GB, 16 GB+ RAM/VRAM recommended). Only the default is
+auto-downloaded. The two VL choices support
image inputs directly when selected as the normal WebGPU provider. Disabling
local vision preserves its cache and any configured remote vision provider.
diff --git a/docs/providers-and-models.md b/docs/providers-and-models.md
index bf82c0741..d5bd9e113 100644
--- a/docs/providers-and-models.md
+++ b/docs/providers-and-models.md
@@ -47,7 +47,7 @@ class BaseLLMProvider {
| `gpt4all` | `openai` | local | (loaded model) | Yes (default on) |
| `local_openai_proxy` | `openai` | local | (required) | Off / manual toggle |
| `unsloth` | `openai` | local | (required) | Off / manual toggle |
-| `webgpu` (Chromium) | `webgpu` | local | Six shipped LFM2.5/Bonsai presets; experimental custom HF ONNX repos | LFM2.5-VL presets |
+| `webgpu` (Chromium) | `webgpu` | local | Seven shipped LFM2.5/Nanbeige/Bonsai presets; experimental custom HF ONNX repos | LFM2.5-VL presets |
| `azure_openai` | `azure_openai` | cloud | (deployment) | Manual toggle |
| `aws_bedrock` | `aws_bedrock` | cloud | (model id) | No |
| `openai` | `openai` | cloud | `gpt-5.6-terra` | Model-name regex |
@@ -150,7 +150,7 @@ duplicate request.
### Local Providers
On Chromium, **WebGPU (In-browser)** is an endpoint-free local provider. Its
-Apocalypse text picker offers six shipped presets:
+Apocalypse text picker offers seven shipped presets:
- [`LiquidAI/LFM2.5-2.6B-ONNX`](https://huggingface.co/LiquidAI/LFM2.5-2.6B-ONNX/)
(`q4f16`, about 1.55 GB) through the packaged Transformers.js 4.2 / ONNX
@@ -171,6 +171,20 @@ Apocalypse text picker offers six shipped presets:
exports also nest their image metadata in `processor_config.json` and ship
`chat_template.jinja` separately; the local runtime loads that layout
explicitly instead of probing for the older `preprocessor_config.json`.
+- [`Michionlion/Nanbeige4.2-3B-ONNX-WebGPU`](https://huggingface.co/Michionlion/Nanbeige4.2-3B-ONNX-WebGPU)
+ (`q4f16`, about 3.1 GB), a browser export of
+ [`Nanbeige/Nanbeige4.2-3B`](https://huggingface.co/Nanbeige/Nanbeige4.2-3B)
+ that runs the same 22 physical layers twice and therefore keeps 44 KV-cache
+ slots. It publishes one WebGPU-fused graph under a non-default file name, so
+ the worker loads it with `model_file_name: 'model_webgpu_mlp'`; the external
+ data shards come from the repository's own `use_external_data_format`. The
+ graph needs the `com.microsoft::MatMulNBitsMlp` WebGPU kernel from the
+ vendored ONNX Runtime build and an adapter with `shader-f16`. Its practical
+ context is set to 4k rather than 16k because those 44 slots cost roughly
+ 176 KB per token in FP16, on top of 3.1 GB of weights. The reference
+ implementation is the [Nanbeige Browser Lab](https://huggingface.co/spaces/borkiss/nanbeige4-2-3b-browser-lab)
+ Space, which drives the same export through a hand-written ONNX Runtime Web
+ loop rather than Transformers.js.
- [`prism-ml/Bonsai-27B-gguf`](https://huggingface.co/prism-ml/Bonsai-27B-gguf)
(`Q1_0`, about 3.8 GB) through a dedicated vendored [bitgpu](https://github.com/stfurkan/bitgpu)
worker. Bonsai is opt-in: WebBrain never auto-downloads the 27B weights.
@@ -185,11 +199,14 @@ validates the template after loading and rejects incompatible repositories.
Do not point Transformers.js at the Bonsai GGUF — 27B is not an ONNX pipeline.
The provider defaults to the Compact prompt tier with a conservative 16k
-practical context setting (4k for Bonsai). Text-only presets reject image
-blocks; the two LFM2.5-VL presets route image and text blocks through the local
-image-text runtime. LFM2.5 2.6B and 1.2B Thinking use reasoning paths; WebBrain
-keeps completed thinking out of the visible answer and reports an error when
-the 2.6B reasoning template exhausts its output budget. Bonsai uses bitgpu
+practical context setting (4k for Nanbeige and Bonsai). Text-only presets
+reject image blocks; the two LFM2.5-VL presets route image and text blocks
+through the local image-text runtime. LFM2.5 2.6B, 1.2B Thinking, and
+Nanbeige4.2-3B use reasoning paths; WebBrain keeps completed thinking out of
+the visible answer and reports an error when a template that opens `<think>`
+in the generation prompt exhausts its output budget before closing it. Those
+three presets decode with their publisher's recommended sampling settings; the
+remaining ONNX presets stay greedy. Bonsai uses bitgpu
`think: true` with a 128-token think budget and the same post-think visible-
answer UX. Each repository is cached separately in Chrome.
After downloading a preset in Apocalypse Mode, the WebGPU card in
diff --git a/docs/remote-downloads.md b/docs/remote-downloads.md
index 8a3750bd5..0f7c8f49e 100644
--- a/docs/remote-downloads.md
+++ b/docs/remote-downloads.md
@@ -22,7 +22,7 @@ WebBrain is designed to minimize remote network dependencies. All downloads fall
| Component | Remote Server / Origin | Origin Description | Typical Size | Protocol / Method | Checksum & Integrity | Local Storage Destination |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
-| **WebGPU Text / Multimodal Models** | `huggingface.co` / Hugging Face CDN | Six shipped presets: LiquidAI LFM2.5 2.6B, 1.2B Instruct, 1.2B Thinking, VL 1.6B, VL 3B, and prism-ml Bonsai 27B | ~0.76 – 4.0 GB per selected preset | HTTPS GET (Transformers.js/ONNX or bitgpu) | Hugging Face Git LFS SHA-256 hash | Browser Cache API & IndexedDB (`transformers-cache`) |
+| **WebGPU Text / Multimodal Models** | `huggingface.co` / Hugging Face CDN | Seven shipped presets: LiquidAI LFM2.5 2.6B, 1.2B Instruct, 1.2B Thinking, VL 1.6B, VL 3B, Michionlion Nanbeige4.2-3B, and prism-ml Bonsai 27B | ~0.76 – 4.0 GB per selected preset | HTTPS GET (Transformers.js/ONNX or bitgpu) | Hugging Face Git LFS SHA-256 hash | Browser Cache API & IndexedDB (`transformers-cache`) |
| **Local Vision Model** | `huggingface.co` / Hugging Face CDN | `webbrain-one/webbrain-vl-2-450M-onnx` weights for local screenshot description and UI analysis | ~810 MB | HTTPS GET (Transformers.js pipeline) | Hugging Face Git LFS SHA-256 hash | Browser Cache API & IndexedDB (`transformers-cache`) |
| **Emergency Text Pack & SQLite Index** | `github.com/webbrain-one/emergency-box-corpus` (GitHub Releases CDN) | Release assets for curated public-domain field references, prebuilt SQLite FTS5 database, and precomputed E5 embeddings | ~245 MB (compressed ZIP) | Resumable HTTP `Range: bytes={offset}-` streaming fetch | Strict **SHA-256** hash comparison against hardcoded release descriptor before activation | OPFS (`webbrain-offline-rag/emergency-box-text/`) & IndexedDB (`webbrain_offline_rag`) |
| **Multilingual Semantic Model** | `huggingface.co` / Hugging Face CDN (`Xenova/multilingual-e5-small`) | ONNX weights for multilingual query embedding and vector search / candidate reranking | ~134 MB | HTTPS GET (ONNX Runtime Web / Transformers.js) | SHA-256 verification via Transformers.js manifest | Browser Cache API & IndexedDB (`transformers-cache`) |
@@ -92,7 +92,8 @@ flowchart TD
4. **Optional WebGPU text and multimodal presets (`apocalypse-mode.html`)**:
- Selecting and starting a non-default preset downloads only that chosen
repository. The 1.2B variants are about 760 MB; VL 1.6B is about 2.3 GB;
- VL 3B is about 4.0 GB; and Bonsai is about 3.8 GB.
+ Nanbeige4.2-3B is about 3.1 GB; VL 3B is about 4.0 GB; and Bonsai is about
+ 3.8 GB.
- The separate 810 MB local vision fallback is downloaded only after the
user enables it in **Settings -> Multimodal -> Vision**.
diff --git a/src/chrome/src/offscreen/inference-worker.js b/src/chrome/src/offscreen/inference-worker.js
index 397243545..af8ff7ba2 100644
--- a/src/chrome/src/offscreen/inference-worker.js
+++ b/src/chrome/src/offscreen/inference-worker.js
@@ -30,6 +30,7 @@ const WEBGPU_LFM25_12B_INSTRUCT_MODEL_ID = 'LiquidAI/LFM2.5-1.2B-Instruct-ONNX';
const WEBGPU_LFM25_12B_THINKING_MODEL_ID = 'LiquidAI/LFM2.5-1.2B-Thinking-ONNX';
const WEBGPU_LFM25_VL_16B_MODEL_ID = 'LiquidAI/LFM2.5-VL-1.6B-ONNX';
const WEBGPU_LFM25_VL_3B_MODEL_ID = 'LiquidAI/LFM2.5-VL-3B-ONNX';
+const WEBGPU_NANBEIGE42_3B_MODEL_ID = 'Michionlion/Nanbeige4.2-3B-ONNX-WebGPU';
const WEBGPU_BONSAI27_MODEL_ID = 'prism-ml/Bonsai-27B-gguf';
const WEBGPU_LFM25_MAX_NEW_TOKENS = 2048;
const WEBGPU_LFM25_TEXT_MODEL_IDS = new Set([
@@ -41,6 +42,37 @@ const WEBGPU_LFM25_VL_MODEL_IDS = new Set([
WEBGPU_LFM25_VL_16B_MODEL_ID,
WEBGPU_LFM25_VL_3B_MODEL_ID,
]);
+// Presets whose reasoning is generated as hidden thinking rather than as part
+// of the visible answer, so they need the long output budget.
+const WEBGPU_REASONING_MODEL_IDS = new Set([
+ WEBGPU_LFM25_MODEL_ID,
+ WEBGPU_LFM25_12B_THINKING_MODEL_ID,
+ WEBGPU_NANBEIGE42_3B_MODEL_ID,
+]);
+// Chat templates that emit the opening `<think>` themselves, so the runtime
+// only returns the reasoning suffix.
+const WEBGPU_OPEN_THINKING_MODEL_IDS = new Set([
+ WEBGPU_LFM25_MODEL_ID,
+ WEBGPU_NANBEIGE42_3B_MODEL_ID,
+]);
+const WEBGPU_LONG_OUTPUT_MODEL_IDS = new Set([
+ ...WEBGPU_LFM25_TEXT_MODEL_IDS,
+ WEBGPU_NANBEIGE42_3B_MODEL_ID,
+]);
+// Publisher-recommended decoding for the shipped reasoning presets. Custom
+// repositories keep Transformers.js greedy defaults.
+const WEBGPU_TEXT_SAMPLING = new Map([
+ [WEBGPU_LFM25_MODEL_ID, { temperature: 0.1, top_k: 50, repetition_penalty: 1.1 }],
+ [WEBGPU_LFM25_12B_THINKING_MODEL_ID, { temperature: 0.05, top_k: 50, repetition_penalty: 1.05 }],
+ // Nanbeige4.2-3B's own generation_config.json.
+ [WEBGPU_NANBEIGE42_3B_MODEL_ID, { temperature: 0.6, top_k: 20, top_p: 0.95 }],
+]);
+// Nanbeige ships a single WebGPU-fused graph under a non-default file name.
+// Without this override Transformers.js looks for `onnx/model_q4f16.onnx`,
+// which the repository does not publish.
+const WEBGPU_TEXT_MODEL_FILE_NAMES = new Map([
+ [WEBGPU_NANBEIGE42_3B_MODEL_ID, 'model_webgpu_mlp'],
+]);
const WEBGPU_VISION_READY_MARKER_VERSION = 2;
const WEBGPU_VISION_READY_MARKER_PREFIX = 'https://webbrain.one/.well-known/webgpu-vision-ready/';
function createWebGpuTextSessionOptions() {
@@ -660,6 +692,9 @@ async function getTextRuntime(modelId, dtype, device, { localFilesOnly = false }
pipeline = await library.pipeline('text-generation', modelId, {
device,
dtype,
+ ...(WEBGPU_TEXT_MODEL_FILE_NAMES.has(modelId)
+ ? { model_file_name: WEBGPU_TEXT_MODEL_FILE_NAMES.get(modelId) }
+ : {}),
// ORT mutates this object while appending its default session config.
session_options: createWebGpuTextSessionOptions(),
local_files_only: localFilesOnly,
@@ -1223,17 +1258,17 @@ async function runText(payload) {
const modelId = assertOnnxTextModel(payload?.modelId);
const device = payload?.device || 'webgpu';
const dtype = payload?.dtype || 'q4f16';
- const usesLfm25ReasoningTemplate = modelId === WEBGPU_LFM25_MODEL_ID
- || modelId === WEBGPU_LFM25_12B_THINKING_MODEL_ID;
- const opensThinkingInPrompt = modelId === WEBGPU_LFM25_MODEL_ID;
- const usesLfm25TextRuntime = WEBGPU_LFM25_TEXT_MODEL_IDS.has(modelId);
+ const usesReasoningTemplate = WEBGPU_REASONING_MODEL_IDS.has(modelId);
+ const opensThinkingInPrompt = WEBGPU_OPEN_THINKING_MODEL_IDS.has(modelId);
+ const usesLongOutputBudget = WEBGPU_LONG_OUTPUT_MODEL_IDS.has(modelId);
+ const sampling = WEBGPU_TEXT_SAMPLING.get(modelId);
if (!await isTextModelReady(modelId, dtype)) {
throw new Error(`${modelId} is not downloaded. Open Apocalypse Mode > WebGPU to download it before chatting.`);
}
const runtime = await getTextRuntime(modelId, dtype, device, { localFilesOnly: true });
if (payload?.requireTools === true) assertToolCapableTextRuntime(runtime, modelId);
const requestedTokens = Number(payload?.options?.maxTokens);
- const maxTokenLimit = usesLfm25TextRuntime
+ const maxTokenLimit = usesLongOutputBudget
? WEBGPU_LFM25_MAX_NEW_TOKENS
: WEBGPU_TEXT_MAX_NEW_TOKENS;
const maxNewTokens = Number.isFinite(requestedTokens)
@@ -1245,17 +1280,13 @@ async function runText(payload) {
let output;
try {
output = await runtime.pipeline(prepareTextMessages(payload?.messages), {
- do_sample: usesLfm25ReasoningTemplate,
- ...(usesLfm25ReasoningTemplate
- ? {
- temperature: modelId === WEBGPU_LFM25_12B_THINKING_MODEL_ID ? 0.05 : 0.1,
- top_k: 50,
- repetition_penalty: modelId === WEBGPU_LFM25_12B_THINKING_MODEL_ID ? 1.05 : 1.1,
- }
- : {}),
+ do_sample: Boolean(sampling),
+ ...(sampling || {}),
max_new_tokens: maxNewTokens,
tools: tools.length ? tools : undefined,
- tokenizer_encode_kwargs: usesLfm25ReasoningTemplate
+ // Reasoning templates re-open `<think>` for the pending turn and collapse
+ // completed thinking in history; the rest suppress thinking outright.
+ tokenizer_encode_kwargs: usesReasoningTemplate
? { preserve_thinking: false }
: { enable_thinking: false },
});
diff --git a/src/chrome/src/providers/webgpu.js b/src/chrome/src/providers/webgpu.js
index 1d1b897e5..2e7f6f9bd 100644
--- a/src/chrome/src/providers/webgpu.js
+++ b/src/chrome/src/providers/webgpu.js
@@ -10,6 +10,7 @@ export const WEBGPU_LFM25_12B_INSTRUCT_MODEL_ID = 'LiquidAI/LFM2.5-1.2B-Instruct
export const WEBGPU_LFM25_12B_THINKING_MODEL_ID = 'LiquidAI/LFM2.5-1.2B-Thinking-ONNX';
export const WEBGPU_LFM25_VL_16B_MODEL_ID = 'LiquidAI/LFM2.5-VL-1.6B-ONNX';
export const WEBGPU_LFM25_VL_3B_MODEL_ID = 'LiquidAI/LFM2.5-VL-3B-ONNX';
+export const WEBGPU_NANBEIGE42_3B_MODEL_ID = 'Michionlion/Nanbeige4.2-3B-ONNX-WebGPU';
export const WEBGPU_BONSAI27_MODEL_ID = 'prism-ml/Bonsai-27B-gguf';
export const WEBGPU_DTYPE = 'q4f16';
export const WEBGPU_BONSAI27_DTYPE = 'q1';
@@ -77,6 +78,18 @@ export const WEBGPU_MODEL_PRESETS = Object.freeze([
contextWindow: 16384,
supportsVision: true,
}),
+ Object.freeze({
+ id: WEBGPU_NANBEIGE42_3B_MODEL_ID,
+ runtime: WEBGPU_RUNTIME_ONNX,
+ label: 'Nanbeige4.2-3B',
+ size: '3.1 GB',
+ dtype: WEBGPU_DTYPE,
+ dtypeLabel: WEBGPU_DTYPE,
+ // The 44 logical KV slots cost about 176 KB per token in FP16, so a 16k
+ // window would need roughly 2.9 GB of cache on top of 3.1 GB of weights.
+ contextWindow: 4096,
+ supportsVision: false,
+ }),
Object.freeze({
id: WEBGPU_BONSAI27_MODEL_ID,
runtime: WEBGPU_RUNTIME_BITGPU,
diff --git a/src/chrome/src/ui/apocalypse-mode.html b/src/chrome/src/ui/apocalypse-mode.html
index ec20e4ed6..25cd60b44 100644
--- a/src/chrome/src/ui/apocalypse-mode.html
+++ b/src/chrome/src/ui/apocalypse-mode.html
@@ -163,6 +163,10 @@
<span>LFM2.5-VL-3B</span>
<span class="webgpu-capability" data-i18n="st.tab.multimodal" data-i18n-title="st.provider.field.supports_vision">Multimodal</span>
</label>
+ <label class="webgpu-text-preset">
+ <input type="radio" name="webgpu-text-preset" value="Michionlion/Nanbeige4.2-3B-ONNX-WebGPU" data-webgpu-text-preset>
+ <span>Nanbeige4.2-3B</span>
+ </label>
<label class="webgpu-text-preset">
<input type="radio" name="webgpu-text-preset" value="prism-ml/Bonsai-27B-gguf" data-webgpu-text-preset>
<span data-i18n="ap.models.text.bonsai">Basic text model</span>
diff --git a/src/chrome/vendor/transformers/README.md b/src/chrome/vendor/transformers/README.md
index 3f11dd21e..76ce77c54 100644
--- a/src/chrome/vendor/transformers/README.md
+++ b/src/chrome/vendor/transformers/README.md
@@ -4,9 +4,10 @@ This directory packages the JavaScript and WASM runtime used by two local
WebGPU paths in Chrome and by offline RAG's CPU/WASM semantic reranker:
- **Apocalypse Mode -> local WebGPU chat** downloads the selected LFM2.5 text
- or vision-language preset used by the standalone-chat nuclear override. An
- opt-in Bonsai 27B preset uses a separate vendored bitgpu worker, not this
- Transformers.js runtime; see `src/chrome/vendor/bitgpu/README.webbrain.md`.
+ or vision-language preset, or the Nanbeige4.2-3B ONNX export, used by the
+ standalone-chat nuclear override. An opt-in Bonsai 27B preset uses a separate
+ vendored bitgpu worker, not this Transformers.js runtime; see
+ `src/chrome/vendor/bitgpu/README.webbrain.md`.
- **Settings -> Multimodal -> Vision -> LFM2.5-VL local fallback** runs
`LiquidAI/LFM2.5-VL-450M-ONNX` as the dedicated screenshot sidecar.
- **Apocalypse Mode -> Offline RAG** runs the explicitly downloaded, pinned
@@ -15,7 +16,8 @@ WebGPU paths in Chrome and by offline RAG's CPU/WASM semantic reranker:
Model weights are not bundled. Transformers.js downloads each selected WebGPU
model on first use and stores it in the browser cache. The shipped ONNX chat
-presets are LFM2.5 2.6B, 1.2B Instruct, 1.2B Thinking, VL 1.6B, and VL 3B.
+presets are LFM2.5 2.6B, 1.2B Instruct, 1.2B Thinking, VL 1.6B, VL 3B, and
+Nanbeige4.2-3B.
They are available through the nuclear control in standalone chat and can also
be selected as the normal provider after download. The reasoning presets keep
completed thinking out of visible answers. Current LFM2.5-VL layouts use:
@@ -24,6 +26,18 @@ completed thinking out of visible answers. Current LFM2.5-VL layouts use:
- `vision_encoder`: FP16
- `decoder_model_merged`: Q4
+`Michionlion/Nanbeige4.2-3B-ONNX-WebGPU` needs no bundle patch, but it does
+need two things from this runtime. It publishes one WebGPU-fused graph named
+`onnx/model_webgpu_mlp_q4f16.onnx` instead of the default `model_q4f16.onnx`,
+so the worker passes `model_file_name: 'model_webgpu_mlp'`; the two external
+data shards are declared by the repository's own
+`transformers.js_config.use_external_data_format`. Its graph also uses the
+`com.microsoft::MatMulNBitsMlp` WebGPU kernel, which is compiled into the
+vendored `ort-wasm-simd-threaded.asyncify.wasm`. Do not replace the ONNX
+Runtime artifacts with a build that drops that kernel; a test asserts it is
+present because its absence only shows up as an opaque session-creation
+failure at runtime.
+
The dedicated 450M vision sidecar uses the same component layout and is
approximately 810 MB. The VL 1.6B chat export instead names its vision and
decoder components `embed_images` and `decoder`; the compatibility patch below
@@ -131,7 +145,7 @@ ProviderManager._createProvider('webgpu') / getVisionProvider()
-> MV3 offscreen document
-> dedicated module Worker
-> text-generation pipeline / AutoProcessor + AutoModelForImageTextToText
- -> selected LFM2.5 ONNX repo / LFM2.5-VL-450M-ONNX over WebGPU
+ -> selected LFM2.5 or Nanbeige ONNX repo / LFM2.5-VL-450M-ONNX over WebGPU
```
Keep inference in the Worker. The MV3 service worker has no WebGPU, while the
diff --git a/test/run.js b/test/run.js
index fc64f89c1..309fe61b5 100644
--- a/test/run.js
+++ b/test/run.js
@@ -973,6 +973,7 @@ const {
WEBGPU_LFM25_12B_THINKING_MODEL_ID,
WEBGPU_LFM25_VL_16B_MODEL_ID,
WEBGPU_LFM25_VL_3B_MODEL_ID,
+ WEBGPU_NANBEIGE42_3B_MODEL_ID,
WEBGPU_BONSAI27_MODEL_ID,
WEBGPU_MODEL_ID,
WEBGPU_MODEL_PRESETS,
@@ -58664,6 +58665,7 @@ test('Chrome exposes separate endpoint-free WebGPU text and vision providers', a
{ id: WEBGPU_LFM25_12B_THINKING_MODEL_ID, label: 'LFM2.5-1.2B-Thinking', runtime: 'onnx', contextWindow: 16384, supportsVision: false },
{ id: WEBGPU_LFM25_VL_16B_MODEL_ID, label: 'LFM2.5-VL-1.6B', runtime: 'onnx-vl', contextWindow: 16384, supportsVision: true },
{ id: WEBGPU_LFM25_VL_3B_MODEL_ID, label: 'LFM2.5-VL-3B', runtime: 'onnx-vl', contextWindow: 16384, supportsVision: true },
+ { id: WEBGPU_NANBEIGE42_3B_MODEL_ID, label: 'Nanbeige4.2-3B', runtime: 'onnx', contextWindow: 4096, supportsVision: false },
{ id: WEBGPU_BONSAI27_MODEL_ID, label: 'Basic text model', runtime: 'bitgpu', contextWindow: 4096, supportsVision: false },
]);
assert.equal(new WebGPUProvider({ model: WEBGPU_BONSAI27_MODEL_ID }).dtype, 'q1');
@@ -59484,11 +59486,15 @@ test('WebGPU worker follows local text-generation and WebBrain VL vision contrac
'aliased ONNX files must resolve device and precision by logical session name');
assert.equal(chromeTransformers, firefoxTransformers,
'the patched Transformers.js browser bundle must stay byte-identical across builds');
+ const ortWasm = fs.readFileSync(path.join(ROOT, 'src/chrome/vendor/transformers/ort-wasm-simd-threaded.asyncify.wasm'));
+ assert.ok(ortWasm.includes(Buffer.from('MatMulNBitsMlp')),
+ 'the vendored ONNX Runtime build must keep the WebGPU kernel the Nanbeige graph is fused around');
for (const modelId of [
WEBGPU_LFM25_12B_INSTRUCT_MODEL_ID,
WEBGPU_LFM25_12B_THINKING_MODEL_ID,
WEBGPU_LFM25_VL_16B_MODEL_ID,
WEBGPU_LFM25_VL_3B_MODEL_ID,
+ WEBGPU_NANBEIGE42_3B_MODEL_ID,
]) {
assert.match(apocalypseHtml, new RegExp(modelId.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')),
`${modelId} is missing from the Apocalypse WebGPU picker`);
@@ -59627,6 +59633,9 @@ test('WebGPU worker follows local text-generation and WebBrain VL vision contrac
assert.match(worker, /Object\.entries\(dtype\)\.sort/);
assert.match(worker, /const WEBGPU_TEXT_MAX_NEW_TOKENS = 256/);
assert.match(worker, /const WEBGPU_LFM25_MAX_NEW_TOKENS = 2048/);
+ assert.match(worker, /\[WEBGPU_NANBEIGE42_3B_MODEL_ID, 'model_webgpu_mlp'\]/,
+ 'the Nanbeige export publishes no default model_q4f16.onnx, so its graph file name must be overridden');
+ assert.match(worker, /model_file_name: WEBGPU_TEXT_MODEL_FILE_NAMES\.get\(modelId\)/);
assert.match(worker, /'ep\.webgpuexecutionprovider\.storageBufferCacheMode': 'simple'/);
assert.match(worker, /session_options: createWebGpuTextSessionOptions\(\)/);
assert.match(worker, /addEventListener\?\.\('uncapturederror'/);
@@ -60392,6 +60401,7 @@ test('WebGPU worker replays text tool history and applies model-specific generat
}
globalThis.__webgpuGenerationOptions = options;
const content = modelId === 'LiquidAI/LFM2.5-2.6B-ONNX'
+ || modelId === 'Michionlion/Nanbeige4.2-3B-ONNX-WebGPU'
? 'private model reasoning</think>Hello!'
: 'text answer';
return [{ generated_text: [...input, { role: 'assistant', content }] }];
@@ -60672,6 +60682,43 @@ test('WebGPU worker replays text tool history and applies model-specific generat
tokenizer_encode_kwargs: { preserve_thinking: false },
}, 'LFM2.5 must use LiquidAI generation settings and its reasoning-template argument');
+ const nanbeigePayload = {
+ ...textPayload,
+ modelId: WEBGPU_NANBEIGE42_3B_MODEL_ID,
+ };
+ await dispatch('download-text', nanbeigePayload);
+ assert.equal(
+ globalThis.__webgpuPipelineOptions.options.model_file_name,
+ 'model_webgpu_mlp',
+ 'Nanbeige publishes onnx/model_webgpu_mlp_q4f16.onnx, not the default model_q4f16.onnx',
+ );
+ const nanbeigeResponse = await dispatch('text-chat', nanbeigePayload);
+ assert.equal(nanbeigeResponse.content, 'Hello!');
+ assert.equal(nanbeigeResponse.reasoningContent, 'private model reasoning',
+ 'Nanbeige opens <think> in the generation prompt, so the returned suffix is reasoning');
+ assert.deepEqual(globalThis.__webgpuGenerationOptions, {
+ do_sample: true,
+ temperature: 0.6,
+ top_k: 20,
+ top_p: 0.95,
+ max_new_tokens: 2048,
+ tools: undefined,
+ tokenizer_encode_kwargs: { preserve_thinking: false },
+ }, 'Nanbeige must use its own generation_config sampling and the reasoning-template argument');
+ assert.equal(
+ globalThis.__webgpuPipelineOptions.options.model_file_name,
+ 'model_webgpu_mlp',
+ 'the chat path must load the same overridden graph file name as the download path',
+ );
+
+ const lfmInstructPayload = {
+ ...textPayload,
+ modelId: WEBGPU_LFM25_12B_INSTRUCT_MODEL_ID,
+ };
+ await dispatch('download-text', lfmInstructPayload);
+ assert.equal(globalThis.__webgpuPipelineOptions.options.model_file_name, undefined,
+ 'presets that publish the default graph name must not send a file-name override');
+
const incompatiblePayload = {
...textPayload,
modelId: 'custom-no-tools',