text-generation Β· text Β· WebAssembly / WebGPU Β· ~140 MB (q8)
SmolLM2-135M-Instruct is the smallest member of Hugging Face's SmolLM2 instruct family β only ~135M parameters. That's the interesting bet: how capable can a chat model be when it's tiny enough to download in seconds and run on any device? This page runs it entirely in your browser via Transformers.js, streaming a real chat completion on the universal WebAssembly/CPU path (no GPU required). Nothing is uploaded; there is no API key and no server.
A distinct model from the 360M sibling already in this showcase
(SmolLM2-360M) β this is the extreme-low-end checkpoint. Its ONNX
build exports as the standard llama decoder architecture, so it loads through the
ordinary text-generation pipeline. Being this small, it's fast but simple: great for quick replies,
rewriting, and structured little tasks β not deep reasoning.
| Model | HuggingFaceTB/SmolLM2-135M-Instruct |
|---|---|
| Task | text-generation (causal LM, ChatML chat) |
| Architecture | Decoder-only transformer (model_type: llama) β hidden size 576, 30 layers, ~135M params |
| Params / dtype | ~135M Β· q8 on WASM (onnx/model_quantized.onnx) |
| Backend | WebAssembly (CPU) β no WebGPU required; WebGPU used as an optional accelerator with a WASM fallback |
| Download | ~140 MB (q8), cached after first load |
| Best at | Short answers, rewriting/summarising, simple structured tasks β it's tiny, so keep prompts focused |
| License | Apache-2.0 (Hugging Face) |
| Web APIs | WebAssembly, Web Workers, ES module imports (WebGPU optional) |
Heads up: the first load transfers the weights (~140 MB), then it's cached. Because it's only 135M parameters, it loads fast and tokens stream quickly even on the WASM/CPU path β the trade-off is that a model this small keeps things simple and can get facts wrong. Keep prompts short and concrete.
An LLM never "picks a word" β every step it produces a probability over its whole vocabulary, and the sampler chooses one. Below is the exact templated prompt the model receives (ChatML), 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 device, not a mock-up.
Load the model and click "Show next-token distribution".
A 135M-parameter chat model that fits in ~140 MB and runs on plain CPU makes an on-device assistant reachable on almost any device β an old phone, a locked-down laptop, a kiosk β with no GPU, no key, and nothing sent to a server. It won't out-argue a frontier model, but for fast, private, "good enough" text tasks it's a genuinely useful primitive.
Ask a question and watch the answer stream token by token β the core chat loop.
A one-shot rewriter: paste text, pick a tone, get a cleaned-up version on-device.
Temperature playground: run the same prompt greedy vs hot and compare how wild it gets.
On-device RAG: MiniLM retrieves the relevant snippet, SmolLM2 answers from it.
It's the standard Transformers.js text-generation pipeline β pass a messages array
(the pipeline applies SmolLM2's ChatML template), a TextStreamer for token-by-token
output, and your sampling settings:
import { pipeline, TextStreamer } from "@huggingface/transformers";
// q8 runs on the universal WASM/CPU path (WebGPU as an optional accelerator).
const generator = await pipeline(
"text-generation", "HuggingFaceTB/SmolLM2-135M-Instruct", { device: "wasm", dtype: "q8" },
);
const messages = [
{ role: "system", content: "You are a helpful, concise assistant." },
{ role: "user", content: "Give three tips for staying focused." },
];
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
generation never blocks the page; the loader auto-inits an already-cached copy and never silently
re-downloads.