fix(nli): return 1.0 for empty claims in score_faithfulness#208
Conversation
Align EvidenceFinder.score_faithfulness() with the Faithfulness metric wrapper: an empty claims list is vacuously faithful (score 1.0), not unfaithful (score 0.0). Fixes OpenAgentHQ#76
|
/oc review pr |
Code Review:
|
| File | Lines |
|---|---|
openagent_eval/metrics/nli/evidence_finder.py:119 |
0.0 → 1.0 |
tests/unit/test_metrics/test_nli.py:206 |
assert score == 0.0 → assert score == 1.0 |
Verdict: Approved ✅
Why: An empty set of claims is vacuously faithful — no claims can be unfaithful. Both the Faithfulness wrapper (in generation/) and now the raw NLI module agree on this semantics. The fix is minimal, correct, and well-tested.
Risk: Low. No downstream code depends on the old 0.0 return — the Faithfulness wrapper already short-circuited with 1.0 before calling this method.
No issues found.
|
🎉 Congratulations @syf2211! Your pull request has been successfully merged into main. 🚀 Thank you for contributing to OpenAgentHQ and helping improve the project. We truly appreciate your contribution and hope to see you back with more amazing PRs! Happy Open Sourcing! ❤️ |

Description
Align
EvidenceFinder.score_faithfulness()with theFaithfulnessmetric wrapper: when the claims list is empty, return a score of1.0(vacuously faithful) instead of0.0.Type of Change
Related Issues
Fixes #76
How Has This Been Tested?
pytest tests/unit/test_metrics/test_nli.py)ruff checkon changed files — pre-existing warnings only)uv run mypy openagent_eval/)Test output
Checklist
Additional Notes
The
Faithfulnessmetric already short-circuits on empty extracted claims and returnsscore=1.0before callingscore_faithfulness(). This fix ensures direct callers ofEvidenceFinder.score_faithfulness([], contexts)get the same semantics.Summary: One-line behavioral fix + corresponding unit test assertion update.
Motivation: Inconsistent API — direct NLI module usage returned
0.0for empty claims while the Faithfulness wrapper returned1.0.Changes:
evidence_finder.py:return 0.0, []→return 1.0, []for empty claimstest_nli.py: updatetest_score_faithfulness_empty_claimsexpectationRisk: Low — only affects direct
score_faithfulness([])callers; no existing code depends on the old0.0behavior.