Skip to content
DeepForgeby svx
All problems

Logit Bias Application

Problem

Apply per-index logit biases and return the new logits.

For each k add biases[k] to logits[indices[k]] and return a new list; the original must not be modified. Empty index lists return a copy of the logits.

Hint

Bias vectors let you steer generation without retraining the model.

Test cases

case 1
in: [[1,2],[1],[5]]
expected: [1,7]
case 2
in: [[0,0],[0,1],[-1,1]]
expected: [-1,1]
case 3
in: [[],[],[]]
expected: []
Starter codePython
def apply_logit_bias(logits, indices, biases):
    # Your code here
    pass

3 test cases · run your code against them in the editor