← All models

text-generation Β· text Β· WebAssembly / WebGPU Β· ~2.5 GB (q8)

IBM Granite 3.0 2B Instruct β€” an enterprise-tuned LLM in your browser

Granite is IBM's open model family, built and licensed (Apache-2.0) for enterprise work: structured extraction, retrieval-augmented generation, tool/function calling and summarisation over business data. This page runs the 2B Instruct model entirely in your browser via Transformers.js β€” it takes the WebGPU fast path (q4f16) when your device has a GPU and falls back to the universal WebAssembly/CPU path (q8) otherwise. Chat with it, steer it with a system prompt and sampling controls, and watch the real probability distribution behind every token. Nothing is uploaded; there is no API key and no server.

A distinct family from the other chat models here (Qwen2, Llama, Gemma, Mistral, Falcon3): Granite is IBM's own granite architecture (GraniteForCausalLM), tuned for the kinds of governed, on-prem tasks enterprises actually ship.

At a glance

Modelonnx-community/granite-3.0-2b-instruct (ONNX build of ibm-granite/granite-3.0-2b-instruct)
Tasktext-generation (causal LM, instruction-tuned chat)
ArchitectureGranite β€” IBM's decoder-only transformer (model_type: granite, GraniteForCausalLM), 2.5B params, 49k-token vocab, 4k context
Params / dtype2.5B Β· q8 on WASM (onnx/model_quantized.onnx) Β· q4f16 on WebGPU (onnx/model_q4f16.onnx)
BackendWebGPU (q4f16) when a real adapter is present β€” recommended for a 2B model; else the universal WebAssembly/CPU (q8) path (slower)
Download~2.5 GB (q8, WASM) or ~1.6 GB (q4f16, WebGPU), cached after first load
Enterprise tuningExtraction, RAG, tool/function calling, summarisation, classification β€” IBM's stated focus for Granite
LicenseApache-2.0 (commercial use, no gating)
Web APIsWebAssembly, Web Workers, ES module imports (WebGPU when available)

A 2B model is heavier than the sub-1B chat models here β€” on the WASM/CPU path it's a ~2.5 GB download and streams at a modest pace. On a machine with a WebGPU adapter it uses the smaller, much faster q4f16 build automatically. Both paths produce real, on-device output.

Run it

Heads up: the first load transfers the weights (~2.5 GB on CPU, ~1.6 GB on WebGPU), then it's cached. On the CPU path a 2.5B model streams slowly β€” that's the honest cost of a governed, private, GPU-free enterprise LLM.

assistantThe model auto-loads when it's already cached; otherwise click Download once. Then ask me to summarise, extract, or classify something β€” I stream my reply token by token, on your device.
Sampling controls

See inside β€” the next-token distribution

An LLM never "picks a word" β€” every step it produces a probability over all 49,155 tokens in Granite's vocabulary, and the sampler chooses one. Below is the exact templated prompt the model receives, and β€” from one real forward pass over the current conversation β€” the actual top candidates for the very next token, with their probabilities. On a low temperature (the default here is 0.40, tuned for reliable enterprise output) the top token dominates; raise it and the tail fattens. This is the real distribution, computed on your device, not a mock-up.

Constructed chat template

Load the model and click "Show next-token distribution".

Top candidates for the next token

The bars appear here.

Why it matters

Granite was designed for the enterprise problem the big consumer chatbots don't solve: governed, auditable, commercially-licensed models you can run where the data lives. Running the 2B Instruct in the browser takes that to its logical end β€” the data never leaves the device at all. Apache-2.0 means no gating and no per-token bill; the enterprise tuning means it's genuinely good at the unglamorous tasks businesses actually pay for.

Use cases

Basics

Ask a question, watch the answer stream on your device β€” the core chat loop.

Practical

Enterprise document extraction: a business record β†’ strict, schema-shaped JSON.

Wild

Synthetic data factory: describe a schema, get realistic fake records as JSON.

Multi-model

On-device RAG over a policy handbook: MiniLM retrieves, Granite answers with citations.

How the API works

It's the standard Transformers.js text-generation pipeline β€” pass a messages array (the pipeline applies Granite's chat template), a TextStreamer for token-by-token output, and your sampling settings. The only device-specific choice is device + dtype, which this page picks by probing for a real WebGPU adapter:

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

// Probe for a real adapter β€” WebGPU (q4f16) for a 2B model, else universal WASM (q8) on the CPU.
const adapter = navigator.gpu && await navigator.gpu.requestAdapter().catch(() => null);
const [device, dtype] = adapter ? ["webgpu", "q4f16"] : ["wasm", "q8"];

const generator = await pipeline(
  "text-generation", "onnx-community/granite-3.0-2b-instruct", { device, dtype },
);

const messages = [
  { role: "system", content: "You are a precise enterprise assistant." },
  { role: "user", content: "Classify this ticket as billing/bug/feature: 'charged twice'." },
];

const streamer = new TextStreamer(generator.tokenizer,
  { skip_prompt: true, skip_special_tokens: true, callback_function: (t) => append(t) });

await generator(messages, {
  max_new_tokens: 220, do_sample: true, temperature: 0.4, top_p: 0.9, streamer,
});

The "see inside" panel runs one raw forward pass β€” generator.model(generator.tokenizer(prompt)) β€” reads the last position's logits, softmaxes them, and shows the real top-k. Everything runs in a Web Worker so generation never blocks the page; the loader auto-inits an already-cached copy and never silently re-downloads.

References