All problems
Repetition Penalty Apply
Problem
The repetition penalty divides positive logits by the penalty and multiplies negative logits by it, pushing repeated tokens down either way.
Given the logits and the penalty > 0, return the adjusted logits.
Hint
The penalty acts in the direction that lowers the token.
Test cases
case 1
in: [[1,-1],2]
expected: [0.5,-2]
case 2
in: [[0,0.5],1.5]
expected: [0,0.3333333333333333]
case 3
in: [[2,-2],1]
expected: [2,-2]
Starter codePython
def repetition_penalty_apply(logits, penalty):
# Your code here
pass3 test cases · run your code against them in the editor