All problems
Next Sentence Pair Labeling
Problem
Convert a list of IsNext flags into BERT NSP labels: 0 when the second segment truly follows the first (flag True) and 1 when it does not (flag False).
Hint
The label is the inverse of the IsNext flag in this encoding.
Test cases
case 1
in: [[true,false,true]]
expected: [0,1,0]
case 2
in: [[false]]
expected: [1]
case 3
in: [[]]
expected: []
case 4
in: [[true,true]]
expected: [0,0]
Starter codePython
def nsp_labeling(is_next_flags):
# Your code here
pass4 test cases · run your code against them in the editor