text-generation · text · WebGPU + WASM fallback · ~600 MB
A 1.1-billion-parameter Llama-architecture chat model, pretrained on 3 trillion tokens and small enough to run in a browser tab. Unlike the WebGPU-only chat models in this catalogue, TinyLlama goes through Transformers.js, so it runs on your GPU via WebGPU when you have one and falls back to a genuine (slower) WebAssembly CPU path when you don't — it even works in headless Chrome. Chat with it, steer it with a system prompt and sampling, then open the hood and watch the real next-token distribution. Nothing leaves your device.
| Model | Xenova/TinyLlama-1.1B-Chat-v1.0 |
|---|---|
| Task | text-generation (causal LM, chat-tuned) |
| Architecture | Llama 2 decoder-only transformer, 1.1B params, 32k-token vocab, 2048 context |
| Chat template | Zephyr-style <|system|> / <|user|> / <|assistant|> role blocks |
| Params / dtype | 1.1B · q4f16 on WebGPU · q4 on the WASM fallback |
| Backend | WebGPU when a GPU adapter exists, else honest WebAssembly (CPU) — no GPU required |
| Download | ~600 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebGPU (optional), WebAssembly, Web Workers |
How it differs from the other chat pages: Qwen 0.5B and the WebLLM models (Llama 3.2, Gemma 2) require WebGPU. TinyLlama is the Llama-family chat model that also runs on CPU — the widest-reach option, and double the parameters of Qwen 0.5B.
An LLM never "chooses a word" — every step it produces a probability over all 32,000 tokens in its vocabulary, and the sampler picks one. Below is the exact templated prompt TinyLlama receives (its Zephyr chat markup), 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".
Because TinyLlama runs on the CPU as well as the GPU, it's the chat model with the fewest prerequisites: a capable-enough instruct LLM you can ship to any visitor, GPU or not, with the conversation never leaving their device and no inference bill.
Ask a question, watch the answer stream — the core chat loop.
Inspect and edit the raw Zephyr chat template that steers an on-device assistant.
Constrained creative writing — force acrostics, lipograms, and fixed forms.
RAG: MiniLM retrieves from a pasted doc, TinyLlama answers grounded in it — all on CPU.
TinyLlama uses the standard text-generation pipeline. Pass a messages array (the
pipeline applies the Zephyr chat template for you), a TextStreamer for token-by-token
output, and your sampling settings. This page probes for a real GPU adapter first and only asks
for device: "webgpu" when one exists — otherwise it runs on WebAssembly:
import { pipeline, TextStreamer } from "@huggingface/transformers";
const hasGPU = "gpu" in navigator && await navigator.gpu.requestAdapter();
const generator = await pipeline(
"text-generation",
"Xenova/TinyLlama-1.1B-Chat-v1.0",
hasGPU ? { dtype: "q4f16", device: "webgpu" } // GPU path
: { dtype: "q4", device: "wasm" }, // honest CPU fallback
);
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; the
readout reports whether WebGPU or WASM actually ran.