Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-262

Hallucination Rate from NLI Scores

Problem

Compute the hallucination rate from per-claim entailment scores. A claim is hallucinated when its score is strictly below threshold.

Return the fraction of scores below threshold, or 0.0 when scores is empty.

Hint

Compare strictly with threshold; a score equal to it counts as grounded.

Test cases

case 1
in: [[0.9,0.4,0.8],0.5]
expected: 0.3333333333333333
case 2
in: [[],0.5]
expected: 0
case 3
in: [[0.1,0.2],0.3]
expected: 1
case 4
in: [[0.5],0.5]
expected: 0
case 5
in: [[0.3,0.7,0.2,0.6],0.5]
expected: 0.5
Starter codePython
def hallucination_rate(scores, threshold):
    # Your code here
    pass

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