← All models

text-generation · reasoning model · WebLLM (MLC) · WebGPU · ~4.5 GB

DeepSeek-R1-Distill — watch a model reason before it answers

DeepSeek-R1-Distill-Llama-8B is a reasoning model: distilled from DeepSeek-R1, it's trained to think out loud — emitting a full chain of thought wrapped in <think>…</think> before it commits to a final answer. It runs entirely in your browser, compiled to WebGPU by MLC's WebLLM engine. This page does the thing that makes an R1 model special: it separates the reasoning trace from the answer — the thinking goes in a collapsible panel, the answer stands on its own — and counts reasoning tokens vs answer tokens live. Nothing is uploaded. WebLLM is WebGPU-only, so it needs a real GPU with enough VRAM.

At a glance

Modeldeepseek-ai/DeepSeek-R1-Distill-Llama-8B
MLC buildDeepSeek-R1-Distill-Llama-8B-q4f16_1-MLC (verified present in WebLLM's prebuiltAppConfig)
RuntimeWebLLM / MLC — not Transformers.js. Weights are precompiled to WebGPU shaders.
Tasktext-generation (reasoning / chain-of-thought)
Params / dtype8B · q4f16_1 (4-bit weights, fp16 compute)
BackendWebGPU only — no WASM fallback. Gated on a real GPU adapter (~5 GB VRAM).
Download~4.5 GB, cached after first load
Reasoning formatEmits <think>…</think> then the answer (the chat template opens the block)
Context window4096 tokens (MLC prebuilt config)
LicenseMIT (base: Llama-3.1 community license)
Web APIsWebGPU, Web Workers, ES module imports, <details>

Run it — reason then answer

The final answer appears here, separate from the reasoning above.

See inside

A reasoning model spends most of its tokens thinking, then a few on the answer — and that split is the whole story. The reasoning trace is parsed out of the raw stream by finding the </think> boundary: everything before it (minus a leading <think>) is reasoning; everything after is the answer. The counters below are measured live, so you can see how much compute the model spent reasoning versus answering, and how long it took before the answer (not just the first token) started.

reasoning tokens (est.)
–
answer tokens (est.)
–
decode speed
–
time to first token
–
time to first answer token
–
total time
–

Exact chat messages sent to the model (last turn)

Ask something to see the messages array that WebLLM receives.

Why it matters

Reasoning models trade tokens for reliability: by working a hard problem out in the open before answering, they get maths, logic, and multi-step tasks right far more often than a model that blurts a single guess. Running one on WebLLM makes that a private, client-side primitive — and because the reasoning is visible, you can audit how the model reached its answer, not just take the answer on faith.

Use cases

Basics

A maths / logic puzzle, with the model's working shown separately from the answer.

Practical

Step-by-step problem solving and debugging-reasoning over a snippet or scenario.

Wild

Watch it reason through a lateral-thinking riddle or plan a multi-step task.

Multi-model

R1 plans the approach → Qwen2.5-Coder writes the code that implements it.

How the API works

WebLLM gives you an OpenAI-shaped chat API backed by a WebGPU engine. The reasoning is not a special API feature — it's in the text the model generates. You stream the completion as normal, then split the stream on the </think> boundary to separate reasoning from answer. This page uses the shared helpers in lib/webllm.js plus a small splitThink() parser, all inside a Web Worker so the UI stays responsive:

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

if (!(await webGPUAdapterAvailable())) {
  showNeedsWebGPU();          // never a faked reasoning trace
} else {
  const engine = await createEngine({
    model: "DeepSeek-R1-Distill-Llama-8B-q4f16_1-MLC",
    onProgress: (p) => setProgress(p.text, p.progress),   // ~4.5 GB, cached after first load
  });

  // R1-distill: keep the system prompt minimal; the model reasons on its own.
  const messages = [{ role: "user", content: "How many times do a clock's hands overlap in 24 hours?" }];

  let acc = "";
  await streamChat(engine, { messages, temperature: 0.6, max_tokens: 1024 }, (delta) => {
    acc += delta;
    const { reasoning, answer, thinking } = splitThink(acc);
    renderReasoning(reasoning, thinking);   // collapsible 
panel renderAnswer(answer); // shown distinctly once arrives }); }

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 reasoning trace.

References