induwara.lk
induwara.lkAI · Developer

AI Logprob to Probability Calculator (Token Confidence)

Paste a logprob, a list, or a raw OpenAI logprobs response and read the probability, per-token confidence %, the joint sequence probability and perplexity. Natural-log by default, runs in your browser, no API key — sources cited below.

By Induwara AshinsanaUpdated Jul 9, 2026
Logprob → probability
Log base
OpenAI, Azure, vLLM default

A valid logprob is 0 or negative. Paste one value straight from your API response.

Try
Probability
99.99%
Probability (0–1)
0.99990
Confidence band
Very high
Formulas: p = base^logprob · PPL = base^(−mean logprob).

How it works

A language model doesn't emit a token “confidence” directly — it emits a log probability. Enable logprobs on the OpenAI, Azure OpenAI, vLLM, or llama.cpp APIs and each generated token comes back with a number like -0.0004 or -2.31. These are in natural log (base e), confirmed in the OpenAI API reference. This tool turns them back into numbers you can reason about.

  1. Single probability. The probability of a token is p = e^logprob, and its percentage is p × 100. A logprob of 0 means 100%; a very negative logprob means a probability near 0%. (OpenAI Cookbook, “Using logprobs”.)
  2. Validity guard.A real probability can't exceed 1, so any logprob > 0 is impossible. The tool flags it and clamps the display to 100% instead of showing a nonsense value.
  3. Sequence log-probability. For an N-token output, sum the logprobs: L = Σ logprobᵢ.
  4. Joint probability. The probability of the whole output is P = e^L = ∏ pᵢ — the product of the per-token probabilities, from the chain rule used by autoregressive decoders. Long outputs multiply many sub-1 values, so their joint probability is small by nature.
  5. Average and geometric mean. The mean logprob is L̄ = L / N, and the geometric-mean per-token probability is e^L̄ — a length-independent confidence figure.
  6. Perplexity. PPL = e^(−L̄) = P^(−1/N): the effective number of equally-likely tokens the model was choosing between. 1.0 is perfect certainty; higher means more uncertainty. (Jurafsky & Martin, SLP3, Ch. 3.) The calculator derives it two independent ways and confirms they match.
  7. Top alternatives. When your response includes top_logprobs, each candidate is converted with the same formula and sorted. These are the top-k only, so they don't sum to 100%.

The confidence bands (Very high ≥ 90%, High ≥ 70%, Medium ≥ 40%, Low ≥ 15%, Very low below 15%) are a reading aid layered on top of the exact math — a heuristic to skim a long output, not an official or calibrated metric. The underlying probability and perplexity numbers are the ground truth.

Worked examples

Single token — the −ln 10 identity

  1. Input: logprob = -2.302585 (natural log)
  2. p = e^(-2.302585) = 0.10000
  3. Percentage = 0.10000 × 100 = 10.00%
  4. Band: Very low (below 15%)
  5. Check: -ln(10) = -2.302585, so this must be exactly 10% ✓

Four-token answer — “The capital … Paris.”

  1. Logprobs: [-0.01, -0.22, -1.60, -0.05], threshold 50%
  2. Per-token: 99.00%, 80.25%, 20.19%, 95.12%
  3. Lowest-confidence token = “Paris” at 20.19% (badged, below 50%)
  4. Sum L = -1.88 → joint P = e^(-1.88) = 0.15259 → sequence confidence 15.26%
  5. Mean logprob L̄ = -0.47 → perplexity = e^(0.47) = 1.600
  6. Cross-check: P^(-1/4) = 0.15259^(-0.25) = 1.600 ✓

Edge case — an impossible positive logprob

  1. Input: logprob = 0.5 (a sign mistake, perhaps)
  2. e^(0.5) = 1.6487 → probability 164.87%, which is impossible
  3. The tool clamps the display to 100% and shows a warning
  4. Fix: logprobs are always ≤ 0; re-check the sign of your value

Frequently asked questions

Sources & references

Formulas on this page were last cross-checked against these sources on 2026-07-09. Perplexity is verified two ways (exp(−mean logprob) and P^(−1/N)) inside the calculator.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.