The standard metric for **evaluating language models**. Measures how surprised the model is by the text — lower is better.
Perplexity = exp(-1/N × Σ log(p_i))Where p_i is the model's assigned probability to the i-th token.
- Perplexity of 10 means the model is as confused as choosing uniformly among 10 options
- Perfect model: perplexity = 1.0
perplexity([0.5, 0.5, 0.5, 0.5]) → 2.0 perplexity([1.0, 1.0, 1.0]) → 1.0
Round to **5 decimal places**.
Similar Problems
Test Cases (2 visible · 2 hidden)
Case 1: Uniform 0.5
Input: perplexity([0.5,0.5,0.5,0.5])
Expected: 2.0
Case 2: Perfect model
Input: perplexity([1.0,1.0,1.0])
Expected: 1.0
⌘↵ Run · ⌘⇧↵ Submit