Token likelihood audit
Enter one target-token probability or negative log-likelihood per prediction. These are values for observed targets at different positions, not a probability distribution across a vocabulary. No model is loaded.
Empty means include every target. Otherwise supply exactly one mask entry per token: 0 excludes its loss and count; 1 includes it within the selected prefix.
Blue bars are counted; gray bars are excluded by the mask or prefix. Rose bars marked ! have infinite loss and are not drawn to the finite scale. Zero loss has a one-pixel baseline marker. The table supplies exact numerical alternatives.
On narrow screens, focus the table and scroll horizontally to read both loss units.
| Token | Input value | Mask | In prefix | Counted | Loss (nats) | Loss (bits) |
|---|
Full precision calculation
This direct numerical instrument has no animation or inference timer. Supplied probabilities are illustrative or user-provided, not verified benchmark measurements.
Evaluation context: Hugging Face: Perplexity of fixed-length models.
Start from observed target tokens
This instrument audits the arithmetic of an evaluation that has already produced target-token probabilities. Each array position is a different prediction, conditioned on whatever context was used upstream. Values need not sum to one: they are not competing vocabulary entries from a single prediction. The calculator does not tokenize text, load a language model or certify an evaluation dataset. The negative natural logarithm of each probability is its loss in nats. Divide by the natural logarithm of two to express the same loss in bits. Perplexity is the exponential of the mean loss in nats, equivalently two raised to the mean loss in bits.
Use each input deliberately
Input interpretation selects target probabilities between zero and one, losses in nats, or losses in bits. Switching this selector reinterprets the numbers already present; it does not convert the editor values. Token values accepts a JSON array of one through 256 finite numbers. Loss modes accept nonnegative values up to one million per token. Inclusion mask is optional: leave it empty to include every supplied target, or enter exactly one zero or one for each array entry. Zero removes that target from both the accumulated loss and the denominator. Inspect prefix length selects the first one through all supplied positions; only unmasked positions in that prefix contribute. Editing Token values returns inspection to the full new array. Other edits preserve the current prefix when valid. Reset defaults restores probabilities, the four original values, the empty mask and the full prefix.
Reproduce the exact calculation
The default probabilities [0.5,0.25,0.125,1] correspond to losses [1,2,3,0] in bits. Their mean is 1.5 bits and perplexity is 2 raised to 1.5, approximately 2.828427. Select losses in bits and enter [1,2,3,0] to reproduce that same result. In probability mode, enter [0.5,0.25] and inspect the first token: perplexity is two. Include both and perplexity becomes the square root of eight. It is not the arithmetic average of the individual perplexities two and four. For a corpus split into unequal batches, concatenate the per-token losses or weight each batch mean by its actual counted tokens; averaging batch means equally would change the result. This page reports its counted-token denominator explicitly.
Distinguish exclusion, infinity and overflow
Enter probabilities [0,0.25]. Counting both makes loss and perplexity infinite because the first observed target was assigned exactly zero probability. No hidden epsilon makes that impossible event finite. Set the mask to [0,1] and the remaining target gives perplexity four. Set it to [0,0] and both mean loss and perplexity are undefined because there are no counted targets. A masked zero probability never contaminates the sum through zero times infinity. In nats mode, a single loss of 1000 remains finite while its exponential exceeds the numeric range of JavaScript; the page labels this overflow separately from an exactly impossible target. Invalid JSON, out-of-range values and mismatched masks clear the chart and table instead of leaving stale evidence.
Read the evidence within its limits
The table lists each supplied value, mask, prefix membership, counted status and both loss units. Blue bars show included finite losses, gray bars show exclusions, and rose exclamation marks identify included infinite losses outside the finite vertical scale. Full precision calculation exposes the model result; Infinity is serialized as a string so it is not silently replaced by a null value. An undefined aggregate is represented by null. All calculations use JavaScript double precision and displayed text is rounded. Extremely small probabilities can already have underflowed before reaching this calculator; supply finite log losses when available. Compare reported perplexities only with aligned dataset, tokenization, context and target-counting conventions. Padding, overlap-only context and initial targets must be masked according to the upstream evaluator. This mask changes aggregation only; it cannot reconstruct missing context or recompute model probabilities. Lower perplexity alone is not proof of factuality, reasoning ability or downstream usefulness.