text-generation · text · WebAssembly (CPU) · ~530 MB
No GPU, no problem. This runs the 8-bit build of Qwen2.5-0.5B-Instruct on the WebAssembly backend — pure CPU — to make one point: a genuinely useful instruct LLM now fits inside a browser tab on ordinary hardware. Chat with it, steer it with a system prompt and sampling controls, and watch the real probability distribution it samples each token from. Nothing is uploaded; there's no API key and no server.
Want the fast path? The same weights run on WebGPU on the Qwen2.5 0.5B (WebGPU) page. This page is deliberately the CPU story.
| Model | onnx-community/Qwen2.5-0.5B-Instruct |
|---|---|
| Task | text-generation (causal LM, chat-tuned) |
| Architecture | Qwen2 decoder-only transformer, 0.5B params, 151k-token vocab |
| Params / dtype | 0.5B · q8 (8-bit weights, onnx/model_quantized.onnx) |
| Backend | WebAssembly (CPU) — no WebGPU required |
| Download | ~530 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers |
An LLM never "picks a word" — every step it produces a probability over all 151,936 tokens in its 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. Raise the temperature and the tail fattens; drop it and the top token dominates. This is the real distribution, computed on your CPU, not a mock-up.
Load the model and click "Show next-token distribution".
WebGPU is still uneven across devices and browsers — but every browser has a fast WebAssembly engine. Proving a capable instruct model runs on plain CPU means client-side language becomes a universal primitive: it works on the locked-down work laptop, the older phone, the kiosk with the GPU blocklisted. Private, offline-capable, free to run, no cold start once cached.
The only difference from the GPU path is two options: device: "wasm" and
dtype: "q8". Everything else is the standard text-generation pipeline —
pass a messages array (the pipeline applies the chat template), a TextStreamer for
token-by-token output, and your sampling settings:
import { pipeline, TextStreamer } from "@huggingface/transformers";
const generator = await pipeline(
"text-generation",
"onnx-community/Qwen2.5-0.5B-Instruct",
{ device: "wasm", dtype: "q8" }, // CPU / WebAssembly — no WebGPU
);
const messages = [
{ role: "system", content: "You are a helpful, concise assistant." },
{ role: "user", content: "Explain WebAssembly in one sentence." },
];
const streamer = new TextStreamer(generator.tokenizer,
{ skip_prompt: true, skip_special_tokens: true, callback_function: (t) => append(t) });
await generator(messages, {
max_new_tokens: 200, do_sample: true, temperature: 0.7, 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
the CPU-bound generation never blocks the page; the loader auto-inits an already-cached copy and
never silently re-downloads.