What Are Logits? How LLMs Choose the Next Token
A language model writes one token at a time. Step through a single prediction, from the prompt to the raw scores to the token it picks.
When you ask a model “What is the capital of France?”, it doesn’t look up an answer. It gives a score to every token it could write next, turns those scores into probabilities, and picks one. Then it does the same thing again with that token added to the context.
- ▶ Play runs it for you
- The orange button goes step by step
- Tap underlined words for a definition
- Input tokens
- Transformer model
- Output logits
- Softmax
- Selected token
What is the capital of France?
Decoding. This demo uses greedy selection and always takes the most likely token. Real systems often sample from the distribution, shaped by temperature and other settings, so a less likely token can be chosen.
Tokenization. Each word here is one token to keep things readable. Real tokenizers often split words into pieces, so unbelievable might become un believ able.
Vocabulary. Only four candidates are shown. A real model scores every token in a vocabulary, and softmax runs over all of them. Here it runs over these four.
How an LLM turns logits into the next token
- Tokens. The prompt is split into tokens, the units the model reads and writes. Real tokenizers often split words into smaller pieces.
- Logits. The model produces one raw score per candidate token. Logits are not probabilities. They can be negative, and only their relative size matters.
- Softmax. Softmax turns the logits into probabilities that add up to 100%. With logits of 3.0, 1.0, 0.5 and −0.5, Paris ends up at 80.2%.
- Selection. One token is chosen and added to the context, and the loop repeats until the model produces an end token.
Why logits matter for AI safety research
The part that matters for safety research is step 3. The model assigns a probability to every possible continuation, not only to the one it ends up writing. That means you can ask how likely any particular sentence is, even one the model never writes. The next explainer shows how researchers do that.