All problems
Length-Normalized Sequence Log Prob
Problem
Return the length-normalized log-probability of every sequence, i.e. the mean token log-probability of that sequence. An empty sequence contributes 0.0, and an empty batch returns [].
Hint
Length normalization is what lets you compare log-probabilities across different sequence lengths.
Test cases
case 1
in: [[[-1,-2],[0],[]]]
expected: [-1.5,0,0]
case 2
in: [[[-0.5,-0.5,-0.5]]]
expected: [-0.5]
case 3
in: [[[]]]
expected: [0]
Starter codePython
def mean_sequence_logps(sequences):
# Your code here
pass3 test cases · run your code against them in the editor