← All models

text-generation · text · WebGPU · ~500 MB

Qwen2.5 0.5B — a chat model that runs in your tab

A 500-million-parameter instruct LLM, small enough to load into a browser and stream tokens on your own GPU. Chat with it, steer it with a system prompt and sampling controls, then open the hood and watch the real probability distribution it samples each next token from — no server, no API key, nothing uploaded.

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 · q4f16 on WebGPU (4-bit weights, fp16 compute)
BackendWebGPU (required — gates on a real GPU adapter)
Download~500 MB, cached after first load
LicenseApache-2.0
Web APIsWebGPU, Web Workers

Run it

assistantLoad the model, then say hello. I stream my reply token by token, right here on your device.
Sampling controls

See inside — the next-token distribution

An LLM never "chooses a word" — every step it produces a probability over all 151,936 tokens in its vocabulary, and the sampler picks 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-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

A capable instruct model that fits in a browser tab turns language into a client-side primitive: private, offline-capable, and free to run at any scale. No inference bill, no data leaving the device, no cold-start latency once it's cached.

Use cases

Basics

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

Practical

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

Wild

A tiny text-adventure dungeon master you play in the browser.

Multi-model

Florence-2 reads an image → Qwen answers about it.

How the API works

Qwen uses the standard text-generation pipeline. Pass a messages array (the pipeline applies the chat template for you), 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",
  { dtype: "q4f16", device: "webgpu" },   // WebGPU required
);

const messages = [
  { role: "system", content: "You are a helpful, concise assistant." },
  { role: "user", content: "Explain WebGPU 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: 256, 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 and gates on a real WebGPU adapter first; with none, it shows a labelled needs-WebGPU state instead of faking tokens.

References