← Back to Pull requests

fix(core): return invalid results for empty Faithfulness/Relevancy evaluator inputs #24303

Open
unknown opened this pull request with 388 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 18, 2026 00:37 UTC
Author

Description

FaithfulnessEvaluator and RelevancyEvaluator treated empty inputs as ordinary scored results: with contexts=[""] or response="", the input reached the judge LLM and could come back as a passing score of 1.0, while contexts=[] 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:

  • None inputs are unchanged: they raise ValueError.

  • Empty inputs — an empty context list, contexts that are all empty strings, or an empty response string — are not judged. The evaluator returns an EvaluationResult with invalid_result=True, an invalid_reason, and passing/score left as None, 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_reason helper in evaluation/base.py, with the contract spelled out in its docstring, checked by both evaluators right after their existing None guards — 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.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes

  • No
  • Version Bump?

    Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes

  • No
  • Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • How Has This Been Tested?

  • I added new unit tests to cover this change
  • New tests in llama-index-core/tests/evaluation/test_faithfulness_evaluator.py and test_relevancy_evaluator.py use a counting stub LLM to assert that empty inputs produce zero judge calls and an invalid result with passing/score left as None, that None inputs still raise ValueError, and that mixed or valid inputs are judged normally. The full tests/evaluation/ suite passes locally (61 passed), and ruff check / ruff format are clean on the changed files.

    Suggested Checklist:

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • I have added Google Colab support for the newly added notebooks.

  • My changes generate no new warnings

  • I have added tests that prove my fix is effective or that my feature works

  • New and existing unit tests pass locally with my changes

  • I ran uv run make format; uv run make lint to appease the lint gods
  • Diff: 388 lines (+291 / -97) across 4 files Reviewer: its-amann Review duration: 14676m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.4% · Safe to merge
    27.4%