Perplexity Calculator

Enter per-token probabilities or a cross-entropy loss value to compute language model perplexity and understand model quality.

Input

Example: GPT output token probabilities from a log-softmax layer (converted to linear scale).

Quick examples

Enter probabilities or a loss value, then click Calculate.

Summary

Enter per-token probabilities or a cross-entropy loss value to compute language model perplexity and understand model quality.

How it works

  1. Choose an input mode: enter per-token probabilities (one per line) or a single cross-entropy loss value.
  2. For per-token mode, the tool computes the average negative log-likelihood: H = -1/N * sum(log(p_i)).
  3. For cross-entropy mode, the value is used directly as H.
  4. Perplexity is then PP = exp(H). Lower perplexity means the model assigns higher probability to the correct tokens.
  5. The result panel shows perplexity, cross-entropy (nats and bits), and an interpretation of the score.

Use cases

  • Evaluate and compare language model quality on a held-out test set.
  • Convert a reported cross-entropy loss (e.g., from PyTorch training logs) into the more interpretable perplexity metric.
  • Verify perplexity calculations by hand when debugging NLP training pipelines.
  • Understand how individual token probabilities contribute to overall model perplexity.
  • Quickly sanity-check whether a reported perplexity figure is plausible given the token probabilities.
  • Learn the relationship between cross-entropy, bits-per-character, and perplexity.

Frequently Asked Questions

Last updated: 2026-07-22 · Reviewed by Nham Vu