Skip to content

fix(ragas): score 0 when AnswerCorrectness classification is empty - #245

Open
Yuriy H (jurayh) wants to merge 1 commit into
braintrustdata:mainfrom
jurayh:fix/answer-correctness-empty-classification
Open

Yuriy H (jurayh) wants to merge 1 commit into
braintrustdata:mainfrom
jurayh:fix/answer-correctness-empty-classification

Conversation

@jurayh

Copy link
Copy Markdown

AnswerCorrectness computes its factuality F1 as tp / (tp + 0.5 * (fp + fn)) with no guard. When the judge classifies nothing, returning empty TP, FP, and FN lists, the denominator is 0. Python raises ZeroDivisionError and aborts the eval. TypeScript returns NaN, which serializes to null and reads as a skipped score.

An empty classification is reachable in practice. It only takes an answer with no checkable claims, like a refusal, or a judge response with all three buckets empty.

This returns 0 when the denominator is 0, in both ports. That matches the existing guard in ContextRecall in the same file, which scores 0 when there are no statements to attribute. Regression tests cover the empty case in Python and TypeScript, with the normal cases unchanged.

No existing issue for this one. Happy to file one first if you prefer.

compute_f1_score divided tp by tp + 0.5 * (fp + fn) unguarded. When the
judge classifies nothing (empty TP, FP, and FN), Python raised
ZeroDivisionError and TypeScript returned NaN, which serializes to null
and reads as a skipped score. Return 0 when the denominator is 0,
matching the guard in ContextRecall. Adds regression tests in both
ports.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant