Perplexity: Measuring a Model's Uncertainty
Perplexity frames a model's uncertainty as the effective number of choices it's considering. For a fair die with six outcomes, the perplexity is 6, reflecting perfect confusion among six options. When evaluating language models, a lower perplexity score indicates a better ability to predict a sequence of text. The footgun is judging the score in a vacuum; a 'good' perplexity is always relative to the task's inherent randomness.
### The mental model Perplexity measures the uncertainty of a probability distribution by telling you the "effective number of choices" it represents. A low perplexity means a model is confident and considering few options for the next outcome. A high perplexity means it's confused and spread thinly across many possibilities. It answers the question: "How many options are you equally confused about?"
### How it works Perplexity is defined as the exponentiation of information entropy. For a discrete distribution with N equally likely outcomes (like a fair die), the probability of each is 1/N, and the perplexity is simply N. - A fair coin has 2 outcomes with 1/2 probability each. Its perplexity is 2. - A fair six-sided die has 6 outcomes with 1/6 probability each. Its perplexity is 6. If a distribution is not uniform (e.g., a loaded die), the perplexity will be lower than the total number of outcomes, reflecting the increased predictability.
### When to use it * **To quantify uncertainty**: It provides a single, intuitive number for how hard it is to predict the outcome of a random process. * **To evaluate predictive models**: In machine learning, especially for language models, perplexity is calculated on a test set. A lower score means the model's probability distribution is closer to the empirical distribution of the test data. * **To compare models**: Given the same test data, the model with the lower perplexity is generally considered better at that specific prediction task.
### When NOT to use it * **As an absolute score without context**: A perplexity of 50 might be excellent for a complex task (predicting the next word in a novel) but terrible for a simple one (predicting the next character in "ababab..."). The value is only meaningful relative to the inherent randomness of the problem.
### One canonical example Consider a fair, six-sided die. There are 6 possible outcomes, each with a probability of 1/6. The perplexity of this system is exactly 6. This means that any prediction is as difficult as choosing one option from a set of 6 equally likely choices. If the die were loaded so that '6' appeared 50% of the time, the perplexity would drop significantly below 6, because the outcome is now more predictable and the model is less "perplexed."
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.