All problems
Length Normalization Exponent Effect
Problem
Compare two beam hypotheses after length normalization with exponent alpha. Each hypothesis is a (score, length) pair, and a non-positive length is used as-is without normalization.
Normalized score is score / (length ** alpha) when length is positive. Return 'a' or 'b' for the higher normalized score, or 'tie'.
Hint
For negative log scores, dividing by a longer length makes the score less negative.
Test cases
case 1
in: [-2,10,-1.5,1,1]
expected: "a"
case 2
in: [-2,10,-1.5,1,0]
expected: "b"
case 3
in: [-1,2,-2,4,1]
expected: "tie"
case 4
in: [-0.5,2,-2,4,1]
expected: "a"
case 5
in: [-1,0,-2,4,1]
expected: "b"
Starter codePython
def length_norm_exponent_effect(score_a, length_a, score_b, length_b, alpha):
# Your code here
pass5 test cases · run your code against them in the editor