text-generation · text · WebGPU + WASM · ~360 MB
A 360-million-parameter instruct LLM from Hugging Face, small enough to stream tokens on your own device — on the GPU via WebGPU when there is one, and genuinely on the CPU via WebAssembly when there isn't. 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.
| Model | HuggingFaceTB/SmolLM2-360M-Instruct |
|---|---|
| Task | text-generation (causal LM, chat-tuned) |
| Architecture | Llama-style decoder-only transformer, 360M params, 49k-token vocab |
| Params / dtype | 360M · q4f16 on WebGPU · q8 on WebAssembly |
| Backend | WebGPU when a real adapter exists, else WebAssembly (CPU) — auto-picked |
| Download | ~360 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebGPU (optional), WebAssembly, Web Workers |
Unlike the WebGPU-only chat models in this catalogue, SmolLM2-360M is small enough that its WebAssembly path is genuinely usable — slower than the GPU, but real. That's why this page auto-initialises everywhere, no "needs a GPU" wall.
An LLM never "chooses a word" — every step it produces a probability over all 49,152 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.
Load the model and click "Show next-token distribution".
A chat model that runs even without a GPU turns language into a client-side primitive you can ship to everyone, not just visitors with modern graphics hardware: private, offline-capable, and free to run at any scale. No inference bill, no data leaving the device.
SmolLM2 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. The only twist is the device pick — WebGPU with
q4f16 if a real adapter is present, WebAssembly with q8 if not:
import { pipeline, TextStreamer } from "@huggingface/transformers";
const gpu = "gpu" in navigator && await navigator.gpu.requestAdapter();
const generator = await pipeline(
"text-generation",
"HuggingFaceTB/SmolLM2-360M-Instruct",
gpu ? { dtype: "q4f16", device: "webgpu" } // fast path
: { dtype: "q8", device: "wasm" }, // real CPU fallback
);
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: 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,
so the UI never blocks.