โ† All models

text-generation ยท text ยท WebAssembly ยท ~676 MB (q4)

MobileLLM-R1 360M โ€” a reasoning model that runs on your CPU

MobileLLM-R1 is Meta's 2025 on-device reasoning family โ€” sub-billion-parameter models post-trained on math, code, and science to reason step by step on a phone. This page runs the 360M checkpoint entirely in your browser via Transformers.js on the universal WebAssembly/CPU path โ€” no GPU required. Give it a problem and watch it think inside <think> tags, then answer โ€” all streamed on your device. No API key, no server, nothing uploaded.

A different family from the other small LLMs here (Qwen, Llama, Gemma, SmolLM, Phi, ERNIE): MobileLLM-R1 uses Meta's compact llama4_text architecture (deep-and-thin with grouped-query attention). It is a reasoning model for math/code, not a general chatbot โ€” steer it with problems, not trivia. At 360M in 4-bit it is small, so expect small-model reasoning: often right, sometimes confidently wrong.

At a glance

Modelonnx-community/MobileLLM-R1-360M-ONNX (ONNX build of facebook/MobileLLM-R1-360M)
Tasktext-generation (causal LM, reasoning post-trained)
ArchitectureMeta MobileLLM-R1 โ€” a compact decoder-only transformer (model_type: llama4_text), 15 layers, 1024 hidden, GQA (16/4 heads), 128k Llama-4 vocab, ~360M params
Params / dtype~360M ยท q4 (4-bit) on WASM (onnx/model_q4.onnx)
BackendWebAssembly (CPU) โ€” no WebGPU required. This is the verified path; expect a few tokens/sec on a laptop CPU.
RuntimeTransformers.js 3.7.5 (shared pin โ€” the llama4_text class is already registered; no version-pin needed)
Download~676 MB (q4, WASM), cached after first load
SpecialtyMath, code, and science reasoning โ€” emits a <think> reasoning trace, then the final answer (often in \boxed{โ€ฆ})
LicenseFAIR Non-Commercial Research License โ€” research / educational use only
Web APIsWebAssembly, Web Workers, ES module imports

Run it

Heads up: the first load transfers ~676 MB (4-bit weights), then it's cached. This is a reasoning model โ€” it will "think out loud" before answering, so give it enough max-tokens to finish. On a CPU it streams at a few tokens per second.

assistantThe model auto-loads when it's already cached; otherwise click Download once. Then give me a problem โ€” a bit of arithmetic, a small coding task, or a logic puzzle โ€” and I'll reason through it step by step, on your device.
Sampling controls

See inside โ€” the next-token distribution

An LLM never "picks a word" โ€” every step it produces a probability over all 128,256 tokens in its vocabulary, and the sampler chooses one. Below is the exact templated prompt the model receives (Llama-4 chat markup), and โ€” from one real forward pass over the current conversation โ€” the actual top candidates for the very next token, with their probabilities. This is the real distribution, computed on your device, not a mock-up.

Constructed chat template

Load the model and click "Show next-token distribution".

Top candidates for the next token

The bars appear here.

Why it matters

MobileLLM-R1 is a bet that reasoning โ€” not just fluent chat โ€” can fit in a sub-billion model that runs on the device in your pocket. Because it is small and CPU-friendly, it makes step-by-step problem solving a local primitive: no GPU, no API bill, no data leaving the machine, and it works offline once cached.

Use cases

Basics

Give it a problem and watch it reason step by step, streaming on your device.

Practical

A step-by-step math & unit helper that shows its working and boxes the answer.

Wild

Watch it think: the reasoning trace and answer split into two panes as it streams.

Multi-model

Grounded reasoning: an embedding model retrieves facts, MobileLLM-R1 reasons over them.

How the API works

It's the standard Transformers.js text-generation pipeline โ€” pass a messages array (the pipeline applies MobileLLM-R1's Llama-4 chat template), a TextStreamer for token-by-token output, and your sampling settings:

import { pipeline, TextStreamer } from "@huggingface/transformers"; // v3.7.5

// Universal WASM/CPU path โ€” no WebGPU needed. 4-bit weights (~676 MB, cached once).
const generator = await pipeline(
  "text-generation", "onnx-community/MobileLLM-R1-360M-ONNX",
  { device: "wasm", dtype: "q4" },
);

const messages = [
  { role: "system", content: "Think step by step, then give the final answer." },
  { role: "user", content: "What is 17 * 24? Work it out step by step." },
];

const streamer = new TextStreamer(generator.tokenizer,
  { skip_prompt: true, skip_special_tokens: true, callback_function: (t) => append(t) });

await generator(messages, {
  max_new_tokens: 320, do_sample: true, temperature: 0.6, top_p: 0.9, streamer,
});
// โ†’ "<think> 17 * 24 = 17 * 20 + 17 * 4 = 340 + 68 = 408 </think> The answer is \boxed{408}."

The "see inside" panel runs one raw forward pass โ€” generator.model(generator.tokenizer(prompt)) โ€” reads the last position's logits, softmaxes them, and shows the real top-k. Everything runs in a Web Worker so generation never blocks the page; the loader auto-inits an already-cached copy and never silently re-downloads.

References