← All models

text-generation · text · WebAssembly (CPU) · ~530 MB

Qwen2.5 0.5B on the CPU — a capable instruct LLM in pure WebAssembly

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.

At a glance

Modelonnx-community/Qwen2.5-0.5B-Instruct
Tasktext-generation (causal LM, chat-tuned)
ArchitectureQwen2 decoder-only transformer, 0.5B params, 151k-token vocab
Params / dtype0.5B · q8 (8-bit weights, onnx/model_quantized.onnx)
BackendWebAssembly (CPU) — no WebGPU required
Download~530 MB, cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers

Run it

assistantThe model auto-loads when it's already cached; otherwise click Download once. Then say hello — I stream my reply token by token, on your CPU.
Sampling controls

See inside — the next-token distribution

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.

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

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.

Use cases

Basics

Ask a question, watch the answer stream on your CPU — the core chat loop.

Practical

Structured extraction: turn free text into schema-shaped JSON.

Wild

Persona engine: the same model role-plays anyone you describe.

Multi-model

RAG on-device: MiniLM retrieves, Qwen answers with citations.

How the API works

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.

References