NATURAL LANGUAGE PROCESSING · INTERVIEW QUESTION
What is perplexity and how is it used to evaluate language models?
🟡 intermediate · Language Modeling
Hint: Think about how 'surprised' the model is by the test data.
Answer
Perplexity measures how well a language model predicts a test set: PPL = exp(-1/N · Σ log ). It represents the average number of equally likely choices the model is considering at each step. Lower perplexity = better model. A perplexity of 1 means perfect prediction; perplexity of V (vocabulary size) means random guessing. Usage:
Interview reasoning
-
Comparing language models on the same dataset.
-
Monitoring training progress.
-
GPT-3 achieved ~20 PPL on test sets.
Limitations:
- Only measures next-token prediction, not generation quality
- Doesn't capture factuality or reasoning
- Not comparable across different tokenizers/vocabularies
- Doesn't correlate well with human preference scores.
For LLM evaluation, downstream task performance and human eval are more meaningful than perplexity alone.
Automatic generation metrics measure proxies with specific reference assumptions. Perplexity exponentiates average negative log probability over the model's tokenization; semantic metrics compare generated and reference meaning, while translation quality also needs adequacy and fluency checks. Scores are not interchangeable across tokenizers or evaluation tasks.
Worked example. Average token negative log likelihood ln(4) gives perplexity 4; tokenization changes the units being averaged.
Validation
Use consistent tokenization and datasets, critical-entity tests, semantic and human assessment, and confidence intervals over independent examples.
Common pitfalls
Lower perplexity does not guarantee factuality or useful task behavior. One reference cannot represent every valid translation or summary.