← All models

text-generation Β· chat LLM Β· WebLLM (MLC) Β· WebGPU Β· ~880 MB

Llama 3.2 1B β€” a chat model that runs on your GPU

This is a real large-language-model chat, running entirely in your browser. Meta's Llama 3.2 1B is compiled to WebGPU by MLC's WebLLM engine β€” you get streaming tokens, sampling controls, a system prompt and full conversation history, with nothing uploaded and no API bill. It's a different runtime from the rest of the catalogue: no WASM fallback, so it needs a real GPU.

At a glance

Modelmeta-llama/Llama-3.2-1B-Instruct
MLC buildLlama-3.2-1B-Instruct-q4f16_1-MLC
RuntimeWebLLM / MLC β€” not Transformers.js. Weights are precompiled to WebGPU shaders.
Tasktext-generation (instruction-tuned chat)
Params / dtype1.24B Β· q4f16_1 (4-bit weights, fp16 compute)
BackendWebGPU only β€” no WASM fallback. Gated on a real GPU adapter.
Download~880 MB, cached after first load
Context window4096 tokens (MLC prebuilt config)
LicenseLlama 3.2 Community License
Web APIsWebGPU, Web Workers, ES module imports

Run it β€” chat

The conversation will appear here. Load the model, then say hello.
History is kept in-tab only β€” reloading forgets it.

See inside

An LLM does two very different jobs per turn: it prefills your whole prompt (fast, parallel) and then decodes the answer one token at a time (the part you watch stream). The split below is measured live β€” time-to-first-token is essentially the prefill cost; everything after is decode. WebLLM reuses a KV cache across turns, so later replies in the same conversation reprocess less of the history.

decode speed
–
time to first token
–
decode time
–
generated
–
context used (est.)
–
total time
–

Exact chat messages sent to the model (last turn)

Send a message to see the messages array that WebLLM receives.

Why it matters

A genuinely useful chat LLM used to mean a server, an API key, and a per-token bill. Llama 3.2 1B on WebLLM makes conversational AI a client-side primitive: private by construction, free to run, and available offline once the weights are cached.

Use cases

Basics

A clean streaming chat β€” the fundamental "talk to the model" loop.

Practical

Structured extraction: turn messy text into strict JSON, on-device.

Wild

Persona role-play β€” swap the system prompt and become someone else.

Multi-model

RAG: MiniLM retrieves from a pasted doc, Llama answers grounded in it.

How the API works

WebLLM gives you an OpenAI-shaped chat API backed by a WebGPU engine. You create the engine (which downloads and compiles the weights), then stream a completion. This page uses the shared helpers in lib/webllm.js, running inside a Web Worker so the UI stays responsive:

import { webGPUAdapterAvailable, createEngine, streamChat }
  from "/lib/webllm.js";

// WebLLM is WebGPU-only β€” gate before doing anything (headless requestAdapter() β†’ null).
if (!(await webGPUAdapterAvailable())) {
  showNeedsWebGPU();          // never a faked reply
} else {
  const engine = await createEngine({
    model: "Llama-3.2-1B-Instruct-q4f16_1-MLC",
    onProgress: (p) => setProgress(p.text, p.progress),   // ~880 MB, cached after first load
  });

  const messages = [
    { role: "system", content: "You are a concise, helpful assistant." },
    { role: "user",   content: "Explain WebGPU in one sentence." },
  ];

  const full = await streamChat(
    engine,
    { messages, temperature: 0.7, top_p: 0.95, max_tokens: 256 },
    (delta) => appendToken(delta),          // streams token-by-token on your GPU
  );
  // engine.interruptGenerate() stops decoding early; engine.runtimeStatsText() reports tok/s.
}

Everything here runs exactly that path in worker.js, and gates on a real WebGPU adapter first. No adapter β†’ a labelled needs-WebGPU state, never a canned answer.

References