Token sequence perplexity calculator
Compute the geometric-mean perplexity of a supplied sequence of token probabilities under a language model.
How to use this calculator
Compute the geometric-mean perplexity of a supplied sequence of token probabilities under a language model.
- Enter Assigned probabilities of observed tokens. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
How the Token sequence perplexity calculator works
Compute the geometric-mean perplexity of a supplied sequence of token probabilities under a language model.
Inputs and units
- Assigned probabilities of observed tokens: Comma-separated model probabilities assigned to observed tokens; each must be greater than zero and at most one.
Formula and method
perplexity = exp(−(1/N) Σ ln pᵢ)
Worked example
For probabilities 0.5, 0.25, and 0.125, the geometric mean probability is (0.5×0.25×0.125)^(1/3) ≈ 0.25, so perplexity = 1/0.25 = 4.
Interpreting the result
Lower perplexity means the listed tokens received higher average probability under this sequence. It is meaningful for comparisons only when tokenization and evaluation data are consistent.
Assumptions and limits
Each probability must be in (0,1]; the entries are treated as observed-token probabilities. This does not assess semantic quality, and values from different tokenizers or datasets are not directly comparable.
Sources and method
- Defines language-model perplexity as exponentiated mean negative log likelihood over tokens; tokenizer context matters. Hugging Face Transformers: perplexity
Frequently asked questions
Why does perplexity use a geometric mean?
Sequence probabilities multiply, so averaging their logarithms gives a numerically stable per-token log loss; exponentiating yields the inverse geometric mean probability.
Can a zero probability be entered?
No. Its logarithm is undefined and it implies unbounded perplexity; every listed probability must be positive and at most one.
How do I use the Token sequence perplexity calculator?
Enter Assigned probabilities of observed tokens. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Token sequence perplexity?
For probabilities 0.5, 0.25, and 0.125, the geometric mean probability is (0.5×0.25×0.125)^(1/3) ≈ 0.25, so perplexity = 1/0.25 = 4.
What does the Token sequence perplexity calculator calculate?
Compute the geometric-mean perplexity of a supplied sequence of token probabilities under a language model.
See the calculation methodology.