Decoding & Sampling

logprobs and confidence

Every token the model emits comes with a probability, and its logarithm — the logprob — is a compact way to read how sure the model was at that step. A logprob near zero means the model was almost certain; a very negative one means it was surprised by its own choice. Many APIs can return these numbers, often alongside the top alternatives it considered, giving you a peek behind the curtain of a single decoded sequence.

People use logprobs as a cheap confidence signal: average them over a span to flag shaky answers, score multiple-choice options by the probability of each letter, or detect hallucinations where the model commits to a specific name or number with low conviction. The crucial caveat is that confidence is not correctness. A model can be fluently, high-probability wrong, because the numbers reflect how typical the text is, not whether it is true. Treat logprobs as a useful hint, never as a guarantee.

\text{logprob}(t) = \log p(t \mid \text{context})

The log of a token's probability; closer to 0 means more confident, more negative means more surprised.

Also called
token log-probabilities