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.
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.
- Single probability. The probability of a token is
p = e^logprob, and its percentage isp × 100. A logprob of 0 means 100%; a very negative logprob means a probability near 0%. (OpenAI Cookbook, “Using logprobs”.) - Validity guard.A real probability can't exceed 1, so any
logprob > 0is impossible. The tool flags it and clamps the display to 100% instead of showing a nonsense value. - Sequence log-probability. For an N-token output, sum the logprobs:
L = Σ logprobᵢ. - 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. - Average and geometric mean. The mean logprob is
L̄ = L / N, and the geometric-mean per-token probability ise^L̄— a length-independent confidence figure. - 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. - 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
Frequently asked questions
Sources & references
- OpenAI API Reference — Chat Completions logprobs / top_logprobs (natural log; response shape)
- OpenAI Cookbook — Using logprobs (probability = exp(logprob))
- Jurafsky & Martin — Speech and Language Processing (3rd ed.), Ch. 3 (perplexity)
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
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.