← All models

text-generation Β· code assistant Β· WebLLM (MLC) Β· WebGPU Β· ~880 MB

Qwen2.5-Coder β€” a coding model that runs on your GPU

Qwen2.5-Coder-1.5B is a code-specialised instruct model from Alibaba β€” trained on ~5.5 trillion tokens of code and code-adjacent text β€” and it runs entirely in your browser, compiled to WebGPU by MLC's WebLLM engine. Unlike a general chat model, it's tuned for programming: write a function from a comment, complete code, generate tests, regex or SQL, and explain snippets β€” with syntax-highlighted streaming, tokens per second, and the exact prompt template on show. Nothing is uploaded, there's no API bill, and it works offline once cached. WebLLM is WebGPU-only, so it needs a real GPU.

At a glance

ModelQwen/Qwen2.5-Coder-1.5B-Instruct
MLC buildQwen2.5-Coder-1.5B-Instruct-q4f16_1-MLC (verified present in WebLLM's prebuiltAppConfig)
RuntimeWebLLM / MLC β€” not Transformers.js. Weights are precompiled to WebGPU shaders.
Tasktext-generation (instruction-tuned for code)
Params / dtype1.5B Β· q4f16_1 (4-bit weights, fp16 compute)
BackendWebGPU only β€” no WASM fallback. Gated on a real GPU adapter (~1.6 GB VRAM).
Download~880 MB, cached after first load
Context window4096 tokens (MLC prebuilt config; base model supports 32k)
LicenseApache-2.0
Web APIsWebGPU, Web Workers, ES module imports

Run it β€” code assistant

The model's code streams here, syntax-highlighted.

See inside

A coding model is just an LLM whose training leaned hard on source code, so the same two phases apply: it prefills your prompt (fast, parallel β€” this is time-to-first-token) then decodes the completion one token at a time (the part you watch stream). The numbers below are measured live on your GPU. The panel also shows the exact chat-message array sent to the model β€” including the instruction wrapper this page builds around your input β€” so there's no mystery about what the model actually saw.

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

Exact chat messages sent to the model (last run)

Run something to see the messages array that WebLLM receives.

Why it matters

A code model small enough to run in a tab, but tuned for programming, turns "AI code assistance" into a client-side primitive β€” private by construction, free to run, and available offline once the weights are cached. No snippet you paste ever leaves the device.

Use cases

Basics

Write a function from a one-line comment β€” the fundamental codegen move.

Practical

Ship-it tasks: unit tests, a regex, a SQL query, or explain a snippet.

Wild

Refactor code, or translate a function from one language to another.

Multi-model

Coder writes the code β†’ Llama-3.2-1B explains it for a non-programmer.

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. There's nothing code-specific in the API β€” you wrap the user's snippet in an instruction and let the code-tuned weights do the rest. 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 completion
} else {
  const engine = await createEngine({
    model: "Qwen2.5-Coder-1.5B-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 coding assistant. Reply with a single fenced code block." },
    { role: "user",   content: "Language: python\n# return the nth Fibonacci number" },
  ];

  const full = await streamChat(
    engine,
    { messages, temperature: 0.2, top_p: 0.95, max_tokens: 512 },
    (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 completion.

References