TorchedUp
ProblemsPremium
TorchedUp
PerplexityEasy
ProblemsPremium

Perplexity

Given a list of per-token negative log-likelihoods (natural log), compute the perplexity of a language model's predictions.

Signature: def perplexity(neg_log_likelihoods: list) -> float

Formula: exp(mean(nlls)). Use np.exp and np.mean.

Note: NLLs are assumed to use the natural logarithm (base e).

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○zero NLL → PPL = 1
○mean = 2
○constant NLL🔒 Premium
Advertisement