All problems
NLI Entailment Logits
Problem
Compute NLI entailment logits. Build pair features as the element-wise product of premise and hypothesis, then for each class row return dot(row, features) + bias[class].
class_vectors has one row per class and bias has one entry per class, both returned in input order.
Hint
The interaction features are products; each class is then a linear layer over them.
Test cases
case 1
in: [[1,0],[1,1],[[1,0],[0,1],[0.5,0.5]],[0.1,-0.1,0]]
expected: [1.1,-0.1,0.5]
case 2
in: [[0.5,0.5],[0.5,0.5],[[1,1]],[0]]
expected: [0.5]
case 3
in: [[1,2],[0,0],[[1,1],[1,-1]],[0,0]]
expected: [0,0]
case 4
in: [[],[],[[1]],[0.5]]
expected: [0.5]
Starter codePython
def nli_entailment_logits(premise, hypothesis, class_vectors, bias):
# Your code here
pass4 test cases · run your code against them in the editor