← All models

text-generation · text · WASM · ~576 MB

Granite-4.0-350M — a hybrid-Mamba LLM in your browser

IBM's Granite 4.0 is a newer generation than the Granite-3.0 already in this showcase, and a genuinely different design: a hybrid architecture that interleaves Mamba-2 state-space layers with a few attention layers, for long context at a small memory footprint. This 350M "micro" chat model runs on the universal WebAssembly/CPU path with no GPU — distinct in both family and architecture from every LLM here. Everything runs on your device — no key, no server.

At a glance

Modelonnx-community/granite-4.0-350m-ONNX-web — ONNX export of ibm-granite/granite-4.0-350m
Tasktext-generation — ChatML instruct/chat
Architecturegranitemoehybrid — hybrid Mamba-2 state-space + attention layers, ~350M params
DistinctGranite 4.0 (vs the built Granite-3.0) AND hybrid Mamba (vs transformer) — new family + new architecture
Quantizationq4 (onnx/model_q4.onnx + external data). q4f16/fp16 are WebGPU-only
Runtime / backendTransformers.js · WebAssembly (runs anywhere; WebGPU used as an optional accelerator)
Download~576 MB (q4), cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers, (optional WebGPU) — all Baseline widely available

Run it

Ask something; the answer streams token by token. It's a tiny model, so facts can be wrong — the point is a distinct architecture running fully on-device.

See inside — next-token probabilities

The model computes a probability for every token in its vocabulary. This is the real top-12 distribution for the token right after your prompt — one forward pass, on your device.

Why it matters

Hybrid Mamba models trade some attention layers for state-space layers, which scale better with sequence length. Seeing one run in a browser at ~350M shows the architecture is practical for on-device, offline assistants — no GPU required.

Use cases

Basics

A plain chat — ask questions and watch tokens stream.

Practical

A rewrite/summarise toolbox with a system prompt.

Wild

Temperature lab: run the same prompt across temperatures and compare.

Multi-model

MiniLM → Granite: retrieve the most relevant note, then answer from it (RAG).

How the API works

import { pipeline, TextStreamer } from "@huggingface/transformers";

const generate = await pipeline("text-generation",
  "onnx-community/granite-4.0-350m-ONNX-web", { dtype: "q4" });   // ~576 MB, cached once

const messages = [{ role: "user", content: "…" }];
const streamer = new TextStreamer(generate.tokenizer, { skip_prompt: true });
const out = await generate(messages, {
  max_new_tokens: 200, do_sample: true, temperature: 0.7, streamer,
});
// out[0].generated_text.at(-1).content → the assistant's reply

This page runs exactly that in a Web Worker (so streaming never blocks the UI), and does one extra forward pass for the real next-token probabilities.

References