Formula

Perplexity

Perplexity is a metric used to evaluate the quality of a language model. It is mathematically defined as the exponential of the average cross-entropy loss over a sequence of nn tokens: exp(1nt=1nlogP(xtxt1,,x1))\exp\left(-\frac{1}{n} \sum_{t=1}^n \log P(x_t \mid x_{t-1}, \ldots, x_1)\right). Conceptually, perplexity represents the reciprocal of the geometric mean of the number of real choices available when deciding the next token. A lower perplexity indicates a better model that predicts the next token with higher accuracy.

0

1

Updated 2026-05-14

Tags

Data Science

D2L

Dive into Deep Learning @ D2L