← All models

text-generation Β· chat LLM Β· WebLLM (MLC) Β· WebGPU Β· ~1 GB

StableLM 2 Zephyr 1.6B β€” Stability AI's tiny chat model on your GPU

A compact, capable chat model from Stability AI, running entirely in your browser. StableLM 2 Zephyr 1.6B is compiled to WebGPU by MLC's WebLLM engine β€” you get streaming tokens, sampling controls, a real system prompt and full conversation history, with nothing uploaded and no API bill. It's a distinct architecture family from the Llama- and Gemma-based chat models here, and like every WebLLM model it needs a real GPU: no WASM fallback.

At a glance

Modelstabilityai/stablelm-2-zephyr-1_6b
MLC buildstablelm-2-zephyr-1_6b-q4f16_1-MLC
RuntimeWebLLM / MLC β€” not Transformers.js. Weights are precompiled to WebGPU shaders.
Tasktext-generation (DPO-tuned chat)
Params / dtype1.6B Β· q4f16_1 (4-bit weights, fp16 compute)
Chat templateZephyr-style <|system|> / <|user|> / <|assistant|> turns β€” a real system role (no folding needed)
BackendWebGPU only β€” no WASM fallback. Gated on a real GPU adapter. ~2 GB GPU memory.
Download~1 GB, cached after first load
Context window4096 tokens (MLC build cap)
LicenseStability AI Community License
Web APIsWebGPU, Web Workers, ES module imports

How it differs from the other chat pages: it's a StableLM architecture (Stability AI), distinct from the Llama-family (Llama 3.2 1B) and Gemma-family (Gemma 2 2B) WebLLM models β€” and at 1.6B it's a sweet spot between the sub-1B Transformers.js chats (Qwen 0.5B) and the heavier ones, with a genuine system role rather than Gemma's folded-in prompt.

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 useful chat model that fits in a ~1 GB download changes what you can ship to the client. StableLM 2 Zephyr on WebLLM makes a conversational model a client-side primitive: private by construction, free to run, and available offline once the weights are cached β€” small enough to reach mid-range laptops and phones, capable enough for real assistant work.

Use cases

Basics

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

Practical

Structured extraction & rewriting: strict JSON and tone-shifting from messy input.

Wild

Persona role-play β€” drop a character into the system prompt and become someone else.

Multi-model

RAG: MiniLM retrieves from a pasted doc, StableLM 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. Because StableLM 2 Zephyr has a real system role, the system prompt is just a system message:

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: "stablelm-2-zephyr-1_6b-q4f16_1-MLC",
    onProgress: (p) => setProgress(p.text, p.progress),   // ~1 GB, cached after first load
  });

  // StableLM 2 Zephyr has a real system role β€” no folding.
  const messages = [
    { role: "system", content: "You are a concise 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