fix(core): return invalid results for empty Faithfulness/Relevancy evaluator inputs #24303
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 388 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.357
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #24303"
general
weight: 0.35
its-amann
Description
FaithfulnessEvaluatorandRelevancyEvaluatortreated empty inputs as ordinary scored results: withcontexts=[""]orresponse="", the input reached the judge LLM and could come back as a passing score of 1.0, whilecontexts=[]returned score 0.0 / passing=False without being marked invalid — indistinguishable from a genuinely judged failure for consumers that ignore the feedback text.This PR gives both evaluators one documented contract for empty inputs, following the suggestion from the issue reporter in #24275:
Noneinputs are unchanged: they raiseValueError.EvaluationResultwithinvalid_result=True, aninvalid_reason, andpassing/scoreleft asNone, so an empty row can neither be read as a judged pass or fail nor stop a batch run.Implementation: a shared
empty_input_invalid_reasonhelper inevaluation/base.py, with the contract spelled out in its docstring, checked by both evaluators right after their existingNoneguards — before any index is built or the judge is called. Contexts that mix empty and non-empty strings are still judged as before.Disclosure: this change was prepared with AI assistance (code drafting and test scaffolding), as invited by the "How to Use AI when Contributing" section of CONTRIBUTING.md. I reviewed the full diff, reproduced the original behaviour and verified the fix locally, and I take responsibility for the change.
Fixes #24275
New Package?
Did I fill in the
tool.llamahubsection in thepyproject.tomland provide a detailed README.md for my new integration or package?Version Bump?
Did I bump the version in the
pyproject.tomlfile of the package I am updating? (Except for thellama-index-corepackage)Type of Change
How Has This Been Tested?
New tests in
llama-index-core/tests/evaluation/test_faithfulness_evaluator.pyandtest_relevancy_evaluator.pyuse a counting stub LLM to assert that empty inputs produce zero judge calls and an invalid result withpassing/scoreleft asNone, thatNoneinputs still raiseValueError, and that mixed or valid inputs are judged normally. The fulltests/evaluation/suite passes locally (61 passed), andruff check/ruff formatare clean on the changed files.Suggested Checklist:
uv run make format; uv run make lintto appease the lint gods