Browser LLMs, from 681 MiB to 4.2 GB
Our llm category runs from TinyLlama at 681 MiB to Llama-3 8B at 4.2 GB. Every generated token reads the whole weight set, so size sets the speed, and that is what we check first when picking a tier.
The chat subcategory under llm lists seven models. TinyLlama 1.1B measures 681 MiB and Llama-3 8B needs 4.2 GB, a spread of more than six times. It is not just about quality. Parameter count and quantisation width set most of it, with the vocabulary, norm parameters and quantisation scales adding a fixed chunk on top.
Working out the size
Weight bytes are roughly parameters times bytes per parameter. At 4 bit that is 0.5 bytes, so a 1.5B model should be 0.75 GB; Qwen2 measures 828 MiB, the difference being the embedding table, norm parameters and quantisation scales. An 8B model at 4 bit should be 4 GB, and Llama-3 measures 4.2 GB. In practice you pick parameter count first, then decide how many bits you will accept, and that already tells you how long the download takes.
| Model | Parameters | Measured size |
|---|---|---|
| TinyLlama | 1.1B | ~681 MiB |
| Qwen2 Instruct | 1.5B | ~828 MiB |
| SmolLM2 Instruct | 1.7B | ~918 MiB |
| DeepSeek-Coder | 1.3B | ~1.3 GB |
| Gemma 2 IT | 2B | ~1.4 GB |
| Phi-3 Mini | 3.8B | ~2.0 GB |
| CodeLlama | 7B | ~3.5 GB |
| Llama-3 Instruct | 8B | ~4.2 GB |
Generation is limited by reading weights
Every generated token reads the entire weight set once, so tokens/s is roughly memory bandwidth divided by model size. On the same GPU, 828 MiB is five times faster than 4.2 GB. The compute is unchanged; there is five times less to read. That explains two familiar things: a long prompt means a slow first token and fast later ones, because prefill is a parallel matmul while decode reads weights serially; and on-device models cut parameters before giving up 4 bit.
KV cache is easy to forget. It grows linearly with context and typically costs tens to a hundred-plus MB at 4K context on a 1.5B model. 828 MiB of weights does not mean an 828 MiB tab.
What the three subcategories are for
chat generates token by token, with temperature and system prompt exposed in the demo. Qwen2 1.5B is the one we use most and handles Chinese well; step up to Phi-3 Mini when reasoning gets harder. structured-output needs legal JSON, and it matters more here than in the cloud because there is no server-side net to validate and retry. code covers DeepSeek-Coder 1.3B and CodeLlama 7B for completion, explanation and rewriting.
There are two ways to get legal JSON: constrained decoding, where a grammar or JSON schema limits the legal token at every step, or prompt plus validate-and-retry. On the client the first is almost the only option. A retry means another full forward pass, at double the power and latency.
import { CreateMLCEngine } from '@mlc-ai/web-llm';
const engine = await CreateMLCEngine('Qwen2-1.5B-Instruct-q4f16_1-MLC', {
initProgressCallback: (p) => console.log(p.text),
});
const stream = await engine.chat.completions.create({
messages: [{ role: 'user', content: 'Rewrite this as a formal email: send me the data by Friday' }],
temperature: 0.7,
stream: true,
});
for await (const chunk of stream) append(chunk.choices[0]?.delta?.content ?? '');The first load downloads weights: seconds for 1.5B on ordinary broadband, minutes for 8B. A progress indicator and a cache strategy are not optional, or users will assume the page has hung. Only the second visit, served from the browser cache, feels instant.
Cases that do not belong on the client
- Work that genuinely needs a 70B-class model
- A first screen that must answer immediately, with no time for a multi-second or multi-minute download
- Devices without WebGPU, where an 8B model on CPU is unusably slow
- Compliance requirements for server-side auditing and content retention
What is left suits the client well: under 8B, a well-bounded task such as rewriting, extraction, classification or code completion, and a user who will wait through one download. No per-token bill, no round trip, and the text never leaves the device.