Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-156

QA Start/End Span Scores

Problem

Rank all valid QA spans. For each start i and end j with j >= i, the span score is start_logits[i] + end_logits[j].

Return [i, j, score] triples sorted by descending score, then ascending i, then ascending j.

Hint

Enumerate every i <= j pair, then sort with the composite key.

Test cases

case 1
in: [[0.5,0.1],[0.4,0.2]]
expected: [[0,0,0.9],[0,1,0.7],[1,1,0.30000000000000004]]
case 2
in: [[1,0],[0,1]]
expected: [[0,1,2],[0,0,1],[1,1,1]]
case 3
in: [[],[]]
expected: []
case 4
in: [[0.5],[]]
expected: []
Starter codePython
def qa_span_scores(start_logits, end_logits):
    # Your code here
    pass

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