← All models

text-generation Β· hybrid-reasoning chat LLM Β· Transformers.js (ONNX) Β· WebGPU Β· ~2.1 GB

SmolLM3-3B β€” a hybrid thinking model on Transformers.js

SmolLM3 is Hugging Face's fully-open 3B model, and it can think out loud on demand: flip thinking on and it emits a <think>…</think> chain of reasoning before answering β€” you watch the trace stream live β€” or flip it off for a fast, direct reply. One model, two behaviours, toggled with SmolLM3's /think and /no_think modes (its chat template's enable_thinking switch). Unlike the WebLLM chat pages, this one runs on Transformers.js (the ONNX build), so you also see the exact templated prompt. WebGPU only β€” a ~2.1 GB download, cached after first load.

At a glance

ModelHuggingFaceTB/SmolLM3-3B
ONNX buildHuggingFaceTB/SmolLM3-3B-ONNX (onnx/model_q4f16)
RuntimeTransformers.js (ONNX Runtime Web) β€” not WebLLM. The smollm3 model class ships in @huggingface/transformers 3.7.5.
Tasktext-generation (instruction-tuned, hybrid reasoning)
Params / dtype3B Β· q4f16 (4-bit weights, fp16 compute)
Thinking controlenable_thinking in the chat template β€” the /think Β· /no_think modes. One model, two behaviours.
Chat templateChatML with a real system role, plus a <think> reasoning segment in thinking mode
BackendWebGPU only here β€” a 3B model is impractical on WASM. Gated on a real GPU adapter (~3 GB memory).
Download~2.1 GB, cached after first load
LicenseApache 2.0
Web APIsWebGPU, Web Workers, ES module imports

How it differs from the other chat pages: SmolLM3 is a hybrid reasoning model like Qwen3, but it runs on Transformers.js/ONNX rather than WebLLM β€” a different runtime and a distinct, fully-open SmolLM3 architecture from Hugging Face. It's a much bigger, reasoning-capable successor to the built SmolLM2 360M page.

Run it β€” chat

Heads up: loading transfers ~2.1 GB the first time (then it's cached). Best on a GPU with β‰₯3 GB of memory.

On β€” SmolLM3 will reason in a <think> trace before answering (/think).
The conversation will appear here. Load the model, then say hello.
History is kept in-tab only β€” reloading forgets it.

See inside

A reasoning model spends tokens in two places: the <think> trace (private reasoning you'd normally never see) and the answer. The split below is measured live. Turn thinking off and the reasoning count drops to zero and the reply comes faster β€” thinking trades latency and tokens for better answers on hard prompts. Time-to-first-token is the prefill cost; everything after is decode. Because this runs on Transformers.js, the exact templated prompt (including the /think vs /no_think generation prompt) is shown below.

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

Exact templated prompt SmolLM3 receives (last turn, via the tokenizer's chat template)

Send a message to see the exact prompt string the model receives.

Why it matters

SmolLM3 is a fully-open 3B model β€” open weights, open data recipe β€” with a genuinely useful hybrid reasoner. Running it on Transformers.js puts that on the client: for easy prompts you turn thinking off and get a fast reply; for hard ones β€” multi-step maths, planning, careful extraction β€” you turn it on and the model works through the problem in a visible trace before committing. All private by construction, free to run, and available offline once cached.

Use cases

Basics

A clean streaming chat with the thinking toggle β€” the fundamental loop.

Practical

Reasoned extraction: strict JSON and step-by-step problem solving with the trace on.

Wild

Thinking on vs off β€” the SAME hard prompt run both ways, side by side.

Multi-model

RAG: MiniLM retrieves from a pasted doc, SmolLM3 reasons over the passages.

How the API works

Transformers.js runs the ONNX build through the standard pipeline("text-generation", …) path on the WebGPU backend. SmolLM3's hybrid mode is selected by the chat template's enable_thinking switch, so this page applies the template itself with that flag, then streams the continuation with a TextStreamer, splitting the <think> reasoning from the answer in worker.js:

import { hasWebGPU } from "/lib/webai.js";
import { pipeline, TextStreamer } from "@huggingface/transformers";  // 3.7.5

// A 3B model needs a GPU β€” gate on a real adapter (headless requestAdapter() β†’ null).
if (!(await hasWebGPU())) { showNeedsWebGPU(); }   // never a faked reply
else {
  const gen = await pipeline("text-generation", "HuggingFaceTB/SmolLM3-3B-ONNX",
    { device: "webgpu", dtype: "q4f16", progress_callback: setProgress });

  const messages = [
    { role: "system", content: "You are a concise assistant." },
    { role: "user",   content: "Is 97 prime?" },
  ];
  // enable_thinking picks /think vs /no_think β€” we template it ourselves so it's inspectable.
  const prompt = gen.tokenizer.apply_chat_template(messages,
    { add_generation_prompt: true, tokenize: false, enable_thinking: true });

  const streamer = new TextStreamer(gen.tokenizer, { skip_prompt: true, callback_function: onPiece });
  await gen(prompt, { max_new_tokens: 512, do_sample: true, temperature: 0.6, top_p: 0.95, streamer });
  // worker.js splits the streamed … trace from the answer.
}

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

References