Skip to content

How an LLM Predicts the Next Word: An Interactive Visualization

An LLM writes by predicting one token at a time, the next word or piece of a word, and then starting over with the longer text. This interactive visualization shows that loop in a real model: Qwen3.5-2B, with 1.88 billion parameters, continues the sentence "The dog ran across the". The picture replays recorded runs of the model. Press Play to watch it write, or take the Tour for an explanation of each part and each step.

Open full screen

The Seven Steps of One Token

Every token the model writes takes one pass through the same seven steps.

  1. Input. The whole text so far enters the model as token IDs. The model works with these numbers, never with letters, and it can take in 262,144 tokens at once: its context window.
  2. Lookup. Each ID is replaced by its token's 2,048 numbers from the vocabulary. Like coordinates on a map, they give the token its place in the model's meaning space.
  3. Layers. 24 layers compute one after the other. Each moves the point of the last token a little and looks back at the whole input while doing so, which is called attention. In the end the point lies among the tokens that could come next.
  4. Temperature. The layers end in a score for every token in the vocabulary. The temperature turns these scores into probabilities: below 1 it widens the favourite's lead, above 1 it gives the others a better chance.
  5. Draw. The next token is drawn at random, weighted by these probabilities. That is why an LLM can answer the same question differently each time.
  6. Output. The drawn token is appended to the text. It is the only thing a pass produces.
  7. Again. What the pass computed inside is discarded. The next pass reads the whole text again, now one token longer.

The purple parts of the picture were fixed in training and are the same for every text; the orange parts change with the text being written. The temperature slider switches between three recorded runs, at T = 0.5, 1.0 and 1.5, so you can watch the same sentence continue differently.

More interactive tools and videos: AI Visualizations.