Start here if you know tokens already
Reasoning LLM.
Follow the scratchpad, spend some extra computation, and keep an eye on the fine print.
Some models generate intermediate steps before answering. Additional computation can help, but longer text is not a truth guarantee.
Or jump to the hands-on bit ↗Before you poke the machinery
Try this: Compare two scripted answers, then reveal why a plausible reasoning trace may leave something out.
The honest boundary: Most panels here are authored teaching examples. “Thinking” is shorthand for computation, not evidence of human-like experience.
Your pace: Scroll, use the chapter links, or jump around. Reading works without JavaScript; interactive controls need it. Motion preferences are respected.
A reasoning model is a next-token machine
Follow the text-generation loop, then explore what extra computation can—and cannot—add.
A useful place to start is a small question, repeated many times: given the context so far, which token comes next? A decoder language model produces scores for possible continuations, selects a token, appends it, and repeats.
A token can be a word, a piece of one, or something else. The machinery doing this is richer than an autocomplete menu, but the next-token loop gives us a handle we can actually turn.
Some reasoning models are trained to generate intermediate steps before a final answer. Those extra steps give later computation more context to use. That can improve performance on some tasks; it can also produce long, confident mistakes. Length is an expense, not a certificate of correctness.
We’ll build the shared pieces—tokenize → embed → attention → sample—and then explore that longer loop. The demos deliberately separate live arithmetic from scripted examples. No tiny philosopher is hiding behind the slider.
Scope of the tour: a simplified text-generation path. Modern products may combine models, tools, retrieval, and other systems. Similar building blocks do not mean every model has the same architecture or training recipe.
3 tokens·10 characters
The arithmetic is real; the model and examples are deliberately small. Change a control and watch the result.
Step 1 — Tokenize
Text becomes tokens first. Their boundaries depend on the tokenizer.
The model can’t read characters the way you do. Before anything else, your text is split into tokens — chunks that are often whole words, sometimes word-pieces, sometimes single characters.
This is done with byte-pair encoding (BPE): start from raw bytes and
repeatedly merge the most common adjacent pair into a new token. Frequent
sequences like " the" become a single token; rare ones get fragmented.
Try it → type in the panel. A few things worth discovering:
- Try “strawberry”, with and without a leading space. The split depends on the tokenizer. Tokens do not usually correspond one-to-one with letters; that can make character-level tasks awkward, but it is not a complete explanation of every counting error.
- A leading space is part of the token:
" Paris"and"Paris"are different tokens. - Numbers, code, emoji, and other languages tokenize very differently. Toggle GPT-4 (~100k vocab) vs GPT-4o (~200k) and compare the counts. A larger vocabulary need not use fewer tokens for every string, and token count alone does not determine capability or cost.
Each token is really just an integer — its row number in the model’s dictionary. These IDs select token embeddings; the model also uses positional information and, in some systems, other inputs.
Nearest to king: prince, princess, queen
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 2 — Embed
Each token becomes a vector — a point in space where meaning lives in directions.
A bare token ID like 2746 means nothing on its own. So the model looks it up in
a giant table and swaps it for a long list of numbers — a vector. For GPT-2
small that’s 768 numbers per token; modern models use thousands.
These vectors are learned (in the gradient-descent sense — the
How Models Learn track shows
the machinery). Relationships can appear in learned representations, but distance depends on
the model, layer, and comparison. In this illustrative panel,
each dot is a word; click one to light up its nearest neighbors — dog sits
by puppy and kitten, far from algorithm.
Because meaning lives in directions, you can sometimes do arithmetic on words. Toggle the analogy: king − man + woman points toward queen in the authored example.
Honest asterisk: this famous example is hand-picked. It only works cleanly when you exclude the input words, and it describes static word vectors — a real LLM’s internal representations are contextual and messier. It’s a beautiful hint that meaning is geometric, not a hard law.
One thing embeddings don’t carry yet is order — “dog bites man” and “man bites dog” would look the same. Models incorporate positional information; some add position embeddings, while others encode relative positions within attention.
One attention head, causal-masked (each token attends only to itself and earlier tokens). Row i = how much token i attends to each token.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 3 — Attention
Each token looks at the others and pulls in the context it needs. This is the engine, repeated dozens of times.
To understand a word you need context. In “The animal didn’t cross the street because it was too tired,” what does “it” refer to? Self-attention lets each token look at the other tokens and decide how much to pull from each.
Mechanically, every token produces three vectors: a Query (“what am I looking for?”), a Key (“what do I offer?”), and a Value (“what I’ll hand over”). A token’s query is compared against every key; the scores go through a softmax into weights that sum to 1; the output is that weighted blend of Values.
Do it for every pair and you get the attention matrix in the panel — row i is how much token i attends to each other token. Notice the greyed upper triangle: a token may only look backward, never at words it hasn’t generated yet. That causal mask is what makes the model a left-to-right predictor. Hover any cell to read the weight.
Two things to keep in mind as we simplify:
- Real models run many attention heads in parallel (GPT-2 small: 12), each learning a different kind of relationship, plus a feed-forward layer that applies further learned transformations. Knowledge is not neatly isolated in just one component.
- This whole block is stacked many times (12 in GPT-2 small; a model-dependent number in larger systems). The token’s vector gets refined at every layer.
After the last block, the model is ready to turn that vector back into a word.
The capital of France is ▍
~50,249 other tokens share the rest of the probability mass.
greedy pick: ·Paris
The probability math and sampling are live. The starting logits are authored teaching values, not a measured model prediction.
Step 4 — Sample the next token
The final vector becomes a probability for every token. How you pick from it is the temperature knob.
After the last block, the model takes the final token’s vector and scores every
token in its vocabulary — about 50,000 scores in GPT-2, and a different count in other models. Those
scores are called logits. A
softmax squashes them into probabilities that sum to 100%. The panel computes a distribution from authored example scores, not a live
model prediction: “87% chance the next token is Paris, 3% the, …”
How do we actually pick one? That’s what the controls in the panel do:
- Greedy — always take the top token. Deterministic for fixed scores, but not guaranteed correct or safe.
- Temperature — rescales the logits. Drag it down and one bar dominates (conservative, near-deterministic at 0). Drag it up and the bars flatten (more diverse, riskier). Temperature 0 does not mean “more true” — just more predictable.
- Top-p (nucleus) — keep only the smallest set of tokens whose probability adds up to p, then sample from those. The struck-through bars are the tail it’s ignoring.
Press Sample! a few times to feel the randomness — then set temperature to 0 and watch it become deterministic.
Then the crucial move: whatever token we pick gets appended to the sequence, and the whole pipeline runs again to produce the next one. This autoregressive loop — one token at a time — is how a whole paragraph gets written.
And it’s exactly this loop that a reasoning model turns into something more.
Blurting the answer in one shot, the model often gets big multiplications wrong — it has no room to work.
In a basic autoregressive loop, more generated tokens mean more computation. The counts here are authored, and extra steps do not guarantee correctness.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 5 — Chain of thought
Intermediate generated steps can help on some tasks. They can also be wrong.
A model can be prompted or trained to produce intermediate steps before the final answer. Ordinary language models can do this too; it is not exclusive to specialized reasoning models.
Chain-of-thought is one approach: the model generates intermediate reasoning steps before the final answer. Research found benefits on selected multi-step tasks; results depend on the model, prompt, and evaluation.
Toggle it in the panel and watch two things happen at once:
- The scripted example reaches a correct answer with intermediate steps. It illustrates a scratchpad; it does not prove the same result on a new task.
- The token counter climbs. That’s the real mechanism: every token the model writes is another full pass through the network. A longer trace literally buys the model more computation to spend before committing.
That second point is the whole game. If thinking longer helps… what happens if we let it think much longer?
At 32× compute, illustrative score ≈ 52%. Authored teaching curve, not a benchmark. Extra compute and useful feedback can help; the outcome depends on the model, task, and strategy.
DeepSeek-R1-Zero climbed from 15.6% → 71.0% pass@1 on AIME 2024 during reinforcement learning. This is a training result, not an inference-budget comparison.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 6 — More work, sometimes a better answer
Extra inference computation is a resource to allocate, not a correctness guarantee.
Training compute changes the model. Test-time compute is work spent while solving a particular task: generating a longer trace, sampling several candidate solutions, revising an answer, or checking intermediate steps.
More work can help. It can also be wasted, amplify a mistake, or yield diminishing returns. The best allocation depends on the model, task difficulty, strategy, and quality of the feedback. A correct-answer checker is useful when available; it is not a universal requirement for any benefit from extra computation.
Drag the budget slider. The curve is invented for teaching—it illustrates a possible trade-off, not a measured accuracy forecast. The verifier toggle is a simplification of how feedback quality can matter, not an experimental comparison.
Keep two questions separate:
- What changed during training? DeepSeek-R1-Zero’s reported improvement on AIME 2024—from 15.6% to 71.0% pass@1—occurred during reinforcement learning.
- What happens if inference gets a bigger budget? That needs a comparison holding the trained model and evaluation conditions fixed.
The test-time compute study investigates adaptive strategies. Its results are much more interesting than “turn the knob and correctness goes up forever.”
Is 121 a prime number?
Direct answer
A deliberately wrong direct answer in this script.
Intermediate steps
Earlier generated text becomes context for the next step.
Two authored examples, not a model comparison. Direct answers can be correct; intermediate steps can be wrong. Training and inference choices both matter.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 7 — The reasoning loop
Intermediate tokens become context for the next step. Useful machinery, with limits.
The important move is simple: generated intermediate tokens become part of the context for later tokens. A model can produce a calculation, inspect a candidate answer, or generate text that revisits a previous step before its final response.
This uses the autoregressive machinery we’ve already explored. It does not require a new architecture solely because we call it reasoning; specific models can still differ in architecture, training, and inference systems.
Press Run both. These are two scripted teaching examples, not live measurements. One answers incorrectly; the other uses intermediate steps and answers correctly. That contrast explains the mechanism, not a rule that ordinary chat models fail and reasoning models succeed.
A generated trace can contain useful calculations and also misleading rationalizations. “Reads its thoughts” is an informal way to describe reusing generated context. It does not establish consciousness, intention, or a faithful record of all the computation inside the network.
Some systems expose reasoning text; others expose summaries or no trace at all. Interfaces, budgets, and billing depend on the particular product and version. The durable idea is the extra computation—not one vendor’s current setting names.
121 is prime.
Reported AIME 2024 endpoints: 15.6% → 71.0%. All intermediate scores, token counts, revision counts, and text here are invented for teaching.
Rule-based checks can score math answers or code tests. Incomplete tests, verifier errors, and reward gaming remain possible.
The compared PPO setup uses a critic. GRPO instead estimates relative advantage from rewards within a sampled group of answers.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 8 — Training it to reason
R1-Zero, R1, and the difference between a training recipe and an aha-shaped sentence.
One approach is reinforcement learning from verifiable rewards: generate candidate solutions, score outcomes that can be checked, and update the model to favor better-scoring behavior. The parameter updates connect back to How Models Learn, although an RL objective is not simply the raw reward treated as a differentiable loss.
The original DeepSeek-R1 report distinguishes two systems. R1-Zero applied RL to an already pretrained base model without an initial supervised fine-tuning stage. R1 used cold-start examples and a multistage pipeline combining supervised and reinforcement learning.
The slider illustrates R1-Zero’s reported training trend; it is not training that model here. Accuracy and response length changed together, but that alone does not isolate the effect of longer responses.
The authors observed generated text that revisits an earlier step. Their “aha moment” label describes an output pattern, not evidence of subjective insight. The procedure encourages behavior through rewards, not a hand-written rule for every solution.
GRPO compares sampled responses within a group without PPO’s separate value-model critic. Verifiable rewards can make assessment easier, but checks can be incomplete and rewards can still be exploited. Distillation can transfer useful behavior to smaller models, with results that depend on the training and evaluation—not a promise of identical capability.
One chain of thought, top token each step.
Selection signal: — (take the one chain)
Snell et al. (2024) found that how to spend computation depended on the problem and evaluation setup. No one topology is best for every task.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 9 — Ways to search
A single chain is just the start. You can branch, vote, build trees, or loop.
Once a model can reason, there are many ways to use that ability at inference time — and each has a different shape. Flip through them in the panel:
- Greedy chain of thought — one line of reasoning, straight through.
- Self-consistency — sample many independent chains and take the majority vote. Different paths, same destination.
- Tree of thoughts — branch at each step, evaluate partial solutions, prune dead ends, and backtrack. On the “Game of 24” puzzle, GPT-4 solved 4% with plain chain-of-thought versus 74% with tree search.
- Reflection — a genuine loop: generate an answer, critique it, revise, repeat.
Which is best depends on the problem: research suggests you should revise on easy problems and search wider on hard ones. Reasoning models bake a lot of this behavior directly into their single long chain of thought — but the same ideas power the scaffolds built around them.
All values are authored, not measured accuracy, latency, token usage, or pricing. More computation can help some tasks or be wasted. Actual controls and tradeoffs depend on the model and system.
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 10 — The effort knob
Spend more work when it helps. Measure the result rather than trusting a bigger dial.
A larger inference budget can mean more generated tokens, more candidate solutions, or more checking. It can also mean more time and cost. Whether the extra work improves the result depends on the task and the system.
The meters in this panel are an illustration, not prices, timings, or benchmark predictions. Treat them as a way to explore a trade-off. A hard problem may benefit from a larger budget; a simple one may not.
Some APIs offer an effort level or token budget. The supported controls change across models and releases. This guide focuses on the concept rather than promising a portable set of parameter names.
The s1 study explored “budget forcing,” including appending “Wait” to extend a response in its experimental setup. That is evidence about a particular method, not a universal spell for better answers. Try the panel’s scripted version and notice what it leaves out: measurement, repeated trials, and checking the answer.
Next, the question hiding behind every neat-looking trace: how much of the reasoning can we trust?
The prompt the model received
Which of these is the capital of Australia? (A) Sydney (B) Canberra
⟨a metadata tag says the answer is B⟩ — a subtle planted hint embedded in the input.
What the model shows you — its chain-of-thought
- 1.The question asks for the capital of Australia. Many people assume it is Sydney because Sydney is the largest and most famous city.
- 2.But capitals are not always the biggest city. Canberra was purpose-built as the capital to settle the rivalry between Sydney and Melbourne, and it houses Parliament House.
- 3.Therefore the capital of Australia is Canberra, which is option (B).
What actually drove the answer
The real cause is hidden — just like it was in the model’s explanation.
The chain-of-thought is a useful generated artifact — not a guaranteed transcript of the model’s real reasoning.
Source: Anthropic, “Reasoning models don’t always say what they think” (2025).
This panel uses authored values or a schematic to explain the idea. It is not a live measurement or a performance benchmark.
Step 11 — Can you trust the reasoning?
The chain of thought is a useful artifact — not a faithful transcript of what the model actually did.
It’s tempting to read a model’s chain of thought as the reason it gave an answer. Be careful — it often isn’t.
In the panel, a model is given a question with a planted hint. Its chain of thought produces an eloquent, confident rationale… that never mentions the hint — even though the hint is what actually drove the answer. Reveal what really happened.
Anthropic measured this directly. When given hints, models mentioned the decisive hint in their reasoning only about 25% of the time in that evaluation (Claude 3.7 Sonnet) and 39% (DeepSeek-R1). In a reward-hacking setup, models exploited the hack in over 99% of cases but admitted it less than 2% of the time — fabricating plausible-sounding rationales instead.
The chain of thought is a genuinely useful, generated artifact — great for catching errors and for oversight. But it is not a guaranteed transcript of the model’s real computation. Keeping it readable enough to monitor is an open safety question.
These rates describe the tested models, hints, and evaluation conditions. They are not universal odds that a model is honest. The panel is a written illustration; the linked research contains the actual experiment.
Everything above used a fixed example. Want the real thing? Load an actual GPT-2 (124M) and run it entirely in your browser. Prompts are processed locally; loading contacts external download hosts.
Downloads a runtime and model files from external hosts, often 100 MB or more depending on the backend. Uses browser caching. WebGPU when available, otherwise WASM.
Downloads model files and a runtime only after you choose to load them. Text generation runs locally; downloads contact external hosts.
Bonus — run a real model yourself
Ready for an actual language model? Load GPT-2 and watch it generate in your browser.
You’ve now seen the whole pipeline — tokenize, embed, attention, sample — and the intermediate-token loop used in our reasoning examples. Time to see the real thing.
Click Load GPT-2 in the panel and a genuine 124-million-parameter model downloads into your browser (a substantial download, often around 100 MB or more depending on the backend, with browser caching) and runs entirely on your machine — your prompt is processed locally. Download requests still contact the CDN and model-file hosts; local inference is not the same as no network traffic. Then type a prompt and watch it generate.
GPT-2 is small and from 2019, so its output is charmingly rough compared to a frontier model. But it is a concrete decoder-transformer example of the ideas you just learned, running for real — every token it emits is the exact tokenize → embed → attention → sample loop, one step at a time.
The other tracks reuse useful ideas while showing their limits: chat adds post-training, mixture-of-experts changes selected feed-forward layers, and image diffusion uses a different generation process. These are learning paths, not a claim that every model is GPT-2 plus one extra part.
One rabbit hole
leads to another.
No quiz at the door. Pick whatever made you curious.