All problems
Best Span Selection
Problem
Select the best QA span with a maximum length constraint: maximize start_logits[i] + end_logits[j] over j >= i and j - i + 1 <= max_len.
Return [i, j, score] with the lowest i and then lowest j winning ties, or an empty list when no span is valid.
Hint
Only replace the best on a strictly greater score so ties keep the earliest span.
Test cases
case 1
in: [[0.5,0.1],[0.4,0.2],2]
expected: [0,0,0.9]
case 2
in: [[0,0],[0,0],1]
expected: [0,0,0]
case 3
in: [[1,0,0],[0,0,2],1]
expected: [2,2,2]
case 4
in: [[0,0],[0,0],0]
expected: []
case 5
in: [[],[],2]
expected: []
Starter codePython
def best_span_selection(start_logits, end_logits, max_len):
# Your code here
pass5 test cases · run your code against them in the editor