esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

What Are Log-Probabilities, and How Can You Use Them?

What log-probabilities are, how to read them as a confidence score, and where they mislead, explained simply for your AI interview.

In short

A log-probability is the logarithm of the chance a model gave a token: values near 0 mean likely, and very negative values mean unlikely. It shows how confident the model is, which can help you route shaky answers to a person, but it does not show whether the answer is right.

10 min readIntermediateOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A log-probability is the logarithm of the chance the model gave a word piece. Closer to zero means more likely. In a claims tool, I would use them to send shaky answers to a person. They show how sure the model is. They don't tell me whether it is right, so I would check them against labelled cases before I trust a threshold.

What are log-probabilities, in plain words?

A language model writes one token at a time. Before it picks one, it gives every possible token a chance, a number from 0 to 1. A likely token might get 0.92, a rare one 0.02, and most candidates get almost nothing.

A log-probability is the logarithm of that chance. Logs keep tiny numbers easy to handle, and they turn multiplying chances into adding. A chance of 0.92 gives a log-probability of about -0.08. A chance of 0.02 gives about -3.9. Here log means the natural logarithm, base e, which is the one exp undoes. To turn one back into a chance, you use the exponential, written exp in code.

Think of a senior claims officer who rates each file as almost certainly genuine, maybe, or unlikely. A model does the same for every next word, only with exact numbers. Those numbers are the log-probabilities.

Key words

Chance (probability)
A number from 0 to 1 for how likely something is. 1 means certain.
Logarithm (log)
The power a fixed base needs to reach a number. Here the base is e (about 2.718), which is why exp undoes it.
Log-probability
The logarithm of a token's chance. It is zero or negative, and closer to zero means more likely.
Perplexity
One score for how well a model predicts a text. Lower is better, and it comes from log-probabilities.

How do you read a log-probability?

A log-probability is always zero or below, because a chance can't be more than 1. Zero means 100 percent. The more negative the number, the less likely the token was.

  • Near 0

    -0.08 is about 92%

    The model strongly preferred this token.

  • Middle

    -2.8 is about 6%

    A possible choice, but the model doubted it.

  • Far down

    -3.9 is about 2%

    Unlikely. The model would rarely write this token.

Adding logs multiplies chances. Add the log-probabilities of every token in an answer, then take the exponential, and you get the chance of the whole answer. That is the joint probability.

  • “A higher log probability means the token is more likely to be generated.”

    Google Cloud, Vertex AI

  • “Otherwise, the value -9999.0 is used to signify that the token is very unlikely.”

    OpenAI API reference

Some APIs return them when you ask. On Google Cloud's Vertex AI, a setting called responseLogprobs turns them on. OpenAI's chat API returns them for each output token, with a short list of the most likely alternatives at each position. Open models you run yourself can return raw prediction scores for each step too, for example the output_scores option in Hugging Face transformers. Those scores are not always log-probabilities, so check what your library returns.

How can you use log-probabilities in a product?

  • Confidence routing

    Send low-confidence answers to a person. The claims example below does exactly this.

  • Scoring and ranking

    Compare candidate answers by their joint or average log-probability, and keep the best one.

  • Evaluation

    Perplexity on a fixed set of texts shows how well a model predicts them. Use it to compare versions of your own model.

  • Highlighting

    Mark the words the model was unsure about, so a reviewer checks those first.

  • Autocomplete

    Decide when to suggest the next word, based on how likely the model thinks it is.

From a logprob to a claim decision

Claim note

water damage, filed 3 days late

Model

returns a logprob per token

Chance per label

approve

logprob -0.08 = 92%

review

logprob -2.81 = 6%

reject

logprob -3.91 = 2%

Top chance 95% or more?

your code sets the route

Auto-pay

only at 95% or more

Officer checks

a person reads the file

  1. 1The claim note goes to the model.
  2. 2The model returns logprobs, which turn into a chance for each label.
  3. 3Your code reads the top label's chance.
  4. 4Yes: 95% or more, so the claim is paid automatically.
  5. 5No: the claim goes to a claims officer, who checks it.
The model gives a chance for each label. Your code reads only the top one, and pays automatically at 95% or more. Anything lower goes to a claims officer.

What don't log-probabilities tell you?

  • High confidence can still be wrong

    The number reflects the model's own guess. Check it against labelled cases before you rely on it.

  • A label can span several tokens

    A label like approve may split into more than one token. Then the first token's chance is only part of the label's chance. Add up the tokens of each label before you route.

  • You only see the top few

    OpenAI's API lists up to the top 20 tokens at each position, not the whole vocabulary. Any other token gets the value -9999.0, which means very unlikely. Other APIs may differ.

  • Perplexity depends on the tokenizer

    Compare perplexity only between models that share a tokenizer and a test text.

  • Support varies

    Not every API returns log-probabilities, and each provider has its own switch. Check the docs before you design around them.

How would you route uncertain claims to a person?

The rule is simple. Auto-pay only when the top label has a chance of 95 percent or more, and send the rest to a person. The code below uses made-up numbers. It reads the first token's log-probabilities, then scores a four-token answer.

Python
# A claims triage model must answer "approve", "review" or "reject".
# The API gives a logprob per token. Each label is one token here (a shortcut).
import math

LABEL_LOGPROBS = {"approve": -0.0834, "review": -2.8134, "reject": -3.9120}
AUTO_PAY_MIN = 0.95  # below this, a claims officer checks first


def to_chance(logprob):
    return math.exp(logprob)  # undoes the log: chance = e to the power of logprob


print("Chance per label:")
for label, lp in LABEL_LOGPROBS.items():
    print(f"  {label:<8}{to_chance(lp):6.1%}")

best = max(LABEL_LOGPROBS, key=LABEL_LOGPROBS.get)
chance = to_chance(LABEL_LOGPROBS[best])
route = "auto-pay" if chance >= AUTO_PAY_MIN else "officer review"
print(f"Top label: {best} at {chance:.1%}, so: {route}")

# A four-token answer, one logprob per token.
tokens = ["Approve", ",", " policy", " active"]
token_logprobs = [-0.083, -0.012, -0.410, -0.205]
total = sum(token_logprobs)
average = total / len(token_logprobs)
print("Answer:", "".join(tokens))
print(f"Joint chance of this answer: {to_chance(total):.1%}")
print(f"Average logprob per token: {average:.3f}")
print(f"Perplexity: {math.exp(-average):.2f}")

Output

Chance per label:
  approve  92.0%
  review    6.0%
  reject    2.0%
Top label: approve at 92.0%, so: officer review
Answer: Approve, policy active
Joint chance of this answer: 49.2%
Average logprob per token: -0.177
Perplexity: 1.19

The joint chance of that answer is 49.2 percent, and its perplexity is 1.19. A perplexity that low means the model found these tokens easy to predict. The demo treats each label as one token, which is a shortcut to check first.

Tip

Before you set the 95 percent line, test it on a few hundred labelled claims. Pick the line where wrong auto-pays stay rare enough for the business to accept.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: the logarithm of a token's chance, zero or below.
  • How to read it: 0 is certain, and the more negative, the less likely.
  • Adding them gives the chance of a whole answer, and averaging compares answers.
  • Uses: confidence routing, ranking answers, perplexity for evaluation, highlighting.
  • Limits: high confidence can be wrong, labels can span tokens, tokenizers differ.
  • A threshold set on labelled cases before it ships.

Common traps

  • Trap"A logprob of -3 means the model is 3 percent sure."

    BetterIt means about 5 percent. Use the exponential: e to the power of -3 is about 0.05.

  • Trap"High logprob means the answer is correct."

    BetterIt means the model was confident. Only labelled data tells you whether the answer is right.

  • Trap"Perplexity is comparable across any two models."

    BetterOnly with the same tokenizer and test text. Otherwise the two numbers measure different things.

Can you spot the bug?

Spot the bug

A teammate wrote these lines. Which one would route claims wrongly?

Quick check

A model gives the label reject a log-probability of -3.9. What is its chance, roughly?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q021What is perplexity?11 min
  2. Q022What are logits, and what does softmax do?11 min
  3. Q010What does temperature control?10 min
  4. Q023What is a hallucination, and why does it happen?11 min
  5. Q012What is top-p (nucleus) sampling?10 min
  6. Q039What are frequency and presence penalties?9 min

Last updated on 27 November 2026

Building a claims or triage tool that routes on model confidence?

I design and build AI products and agents, including the interface and the system behind them. Book a short call and tell me what decisions the model makes and what happens when it is unsure.