Perplexity is the standard metric for evaluating language models. It measures how "surprised" a model is by a sequence of tokens. A lower perplexity means the model assigns higher probability to the observed sequence, indicating better predictions.
Given a list of probability distributions (one per position) and the actual token indices, compute the perplexity of the sequence.
Return perplexity as a positive float rounded to four decimals.
Input: prob_distributions = [[0.5, 0.5], [0.5, 0.5]], actual_tokens = [0, 1]
Output: 2.0
Explanation: Both observed tokens have probability 0.5, so exponentiating the mean negative log probability gives 2.
Input: prob_distributions = [[1, 0], [0, 1]], actual_tokens = [0, 1]
Output: 1.0
Read the observed-token probability from each row before taking its logarithm.
Negate the mean log probability, exponentiate it, and round the result.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Perplexity is the standard metric for evaluating language models. It measures how "surprised" a model is by a sequence of tokens. A lower perplexity means the model assigns higher probability to the observed sequence, indicating better predictions.
Given a list of probability distributions (one per position) and the actual token indices, compute the perplexity of the sequence.
Return perplexity as a positive float rounded to four decimals.
Input: prob_distributions = [[0.5, 0.5], [0.5, 0.5]], actual_tokens = [0, 1]
Output: 2.0
Explanation: Both observed tokens have probability 0.5, so exponentiating the mean negative log probability gives 2.
Input: prob_distributions = [[1, 0], [0, 1]], actual_tokens = [0, 1]
Output: 1.0
Read the observed-token probability from each row before taking its logarithm.
Negate the mean log probability, exponentiate it, and round the result.
Sign in to take notes on this problem
Accepts: array
Accepts: array