Interactive lab · Large language models

How an LLM answers a question

Watch Qwen2.5-0.5B-Instruct turn a question into tokens, IDs, scores and an answer, one real token at a time, with probabilities captured from the model on a laptop CPU.

By Sandeep Belgavi · Published 2026-10-30

Real values, not a simulation: every token ID and probability below was captured from a real model run. Details are in Where the numbers come from.

1

Your prompt

Plain text goes in. The model never sees letters, only numbers.

2

Tokenizer

Byte-level BPE splits the text into pieces from a fixed vocabulary. ␣ marks a leading space.

3

Token IDs

Each piece becomes its integer ID in the Qwen2.5 vocabulary. Generated tokens (dashed) join the input as they are produced.

The chat template wraps your prompt

4

Transformer

Schematic: 4 of the 24 layers are drawn, and the moving dots show the order of computation, not measured activations. Width 896, 14 query heads sharing 2 key/value heads.

5

Softmax: next-token probabilities

The model scores all 151,936 vocabulary entries. The 8 most likely are shown; the rest of the mass is “other”.

6

Detokenizer

The picked ID is looked up and turned back into bytes, then text.

7

Response

The answer grows one token at a time. Each new token is fed back in for the next step.

What you are watching

Text becomes numbers

The tokenizer cuts the prompt into vocabulary pieces. Common words are one piece; rarer strings such as CASE-1042 or the name Geetha are split into several. Each piece has a fixed integer ID, and those IDs are all the network receives.

One forward pass per token

The first step reads the whole prompt at once (prefill). After that, each step feeds in only the newest token and reuses the keys and values cached from earlier tokens (the KV cache), so the answer is produced strictly left to right.

Scores, then a choice

The last layer gives a score for every one of 151,936 vocabulary entries. Softmax turns the scores into probabilities. This trace uses greedy decoding, so the highest bar is always the one picked.

Temperature changes the odds, not the scores

Dividing the scores by T before softmax sharpens the distribution when T<1 and flattens it when T>1. T=0 means “always take the top token”. Move the slider while a step is shown and watch the bars rescale.

Where the numbers come from

The model's scores were captured once and stored with this page; the softmax at your chosen temperature is recomputed live in your browser from those captured log-probabilities. At T = 1 the bars are the model's own probabilities and “other” is the real remaining mass. At any other temperature only the 8 captured candidates can be rescaled, so they are renormalized among themselves and the tail is shown as not captured. The trace itself was always decoded greedily, so moving the slider does not change the recorded answer: it shows how likely a sampler at that temperature would have been to leave the greedy path at that step, after which the text would differ and was not captured.

The token IDs were produced by the Qwen2.5 tokenizer and checked against the model run: the tokenizer's count of the full templated prompt equals the count Ollama reported, and the generated IDs decode to exactly the text Ollama returned. The chat template adds a default system line and turn markers around your prompt; those tokens are counted in the transformer's input but are folded into the grey “template” chips so the prompt stays readable. The capture script and the raw JSON trace are kept with the site source, not published as part of this page.

Things to try

Views are my own and do not represent any employer, past or present.