Topic 4 of 5 · 4 min read
Watching token probabilities live
Goal: Read a log-probability view and tell a confident token from an uncertain one in a model's answer.
Log probabilities, or logprobs, show how sure the model was about each token it wrote, so you can see where it was confident and where it was nearly guessing.
Check yourself · 1 of 3
What do log probabilities show for a token in a model's answer?
Why it matters
You normally see only the final text. Logprobs let you look under it. They show the top choice at each step and the close runners-up. This makes the loop from the first topic visible, and it gives you a way to find the weak spots in an answer, such as a number or a name where the model was torn between options.
How to read them
A log probability is a probability written on a log scale. You do not need the maths. Three rules are enough:
- A value near 0 means the model was very sure. A logprob of -0.01 is about 99% likely.
- A more negative value means less sure. -0.7 is about 50%. -2.3 is about 10%.
- Compare the winner with the runners-up. If the top token has 95% and the next has 2%, it was a clear call. If the top has 38% and the next has 35%, it was a coin toss, and a rerun may give a different word.
Where to see them: OpenAI's API can return logprobs and the top alternatives for each token. Some playgrounds and open-weight tools, such as local model runners, show them too. Many chat apps, including the standard ChatGPT, Claude and Gemini chat windows, do not show them.
A worked read
Prompt: "The first person on the Moon was Neil". Model output with the top choices:
| Token | Chance | Next-best choices |
|---|---|---|
| Arm | 99% | Alden 0.3% |
| strong | 100% | (none worth noting) |
| in | 51% | on 44% |
"Arm" and "strong" were near-certain. The word after is a near toss-up between "in" and "on". Neither changes the facts, so it is harmless. If the uncertain token had been a date, you would want to check it.
For engineers, a request in the OpenAI Python SDK looks like this:
resp = client.chat.completions.create(
model="your-model",
messages=[{"role": "user", "content": "The capital of Australia is"}],
max_tokens=3,
logprobs=True,
top_logprobs=3,
)
for t in resp.choices[0].logprobs.content:
print(t.token, t.logprob)
What goes wrong
- Treating a high probability as proof. A model can be 99% sure of a wrong fact it learned wrongly.
- Treating a low probability as an error. A choice between two good words is not a mistake.
- Expecting every tool to offer logprobs. Many do not, and some models hide them.
Examples
Spot the weak token
A model writes: "The invoice is due on 14 March."
Logprobs show "14" at 41% with "15" at 38%, and "March" at 98%. The month is firm; the day is a near coin-flip.
That tells you to check the day in the original invoice, and that the model likely guessed because the date was not in its input.
Compare two tokens
Top choices for the next token after "Paris is the capital of":
- "France": 97%
- "the": 1%
- "a": 0.5%
The model is nearly certain. Compare with "The best restaurant in Lyon is", where the top token might be 6% and many others sit close behind. Both can produce fluent text; only one is a confident prediction.
Key points
- Logprobs show the probability the model gave each token it wrote, plus the close alternatives.
- A value near 0 means the model was very sure, and a more negative value means it was less sure.
- The gap between the top token and the runner-up tells you whether it was a clear call or a toss-up.
- Low confidence on a number, name or date is a good place to start your own checking.
- High confidence is not proof of truth, since a model can be sure and still wrong.
Common mistakes
- Reading 99% as "verified" rather than "the model is very sure".
- Reading a low score on a harmless word as a sign of a factual error.
- Looking for logprobs in a chat app that does not provide them.
- Comparing probabilities between different models as if they were on the same scale.
Check yourself · 2 of 3
At one step, the top token has a 52% chance and the runner-up has 47%. What does that tell you?
Check yourself · 3 of 3
Logprobs show "2019" had a 97% chance in a reply about when a product launched. Which conclusion is best?
Practice items, not counted towards your mastery.
Start here
- 3Blue1Brown: Large Language Models explained briefly (opens in a new tab)VideoFree
A short illustrated lesson (video and text) showing a model assigning a probability to every possible next word, then picking one.
- 3Blue1Brown: Transformers, the tech behind LLMs (opens in a new tab)VideoFree
A longer illustrated lesson on how a chat model turns text into a probability list for the next token and samples from it, again and again.
- LLM Visualization (Brendan Bycroft) (opens in a new tab)ToolFree
An interactive 3D model that shows a small GPT turning tokens into next-token probabilities.
More for this topic
- Using logprobs (OpenAI Cookbook) (opens in a new tab)ArticleFree
Worked examples of reading token log probabilities from an API response.