#3376·deepeval

CitationFaithfulnessMetric: fail out-of-range [N] markers deterministically before the judge call

Author: mikekeror-rgbCreated Sep 27, 2026Updated Sep 27, 2026

Problem

CitationFaithfulnessMetric numbers the passages in retrieval_context as [1], [2], … and asks the LLM judge whether each [N] marker in actual_output points to a passage that supports its claim.

A marker can also point to a passage that doesn't exist, e.g. [7] when there are only 5 passages. That's a fabricated citation, and it's knowable without any LLM call. From reading citation_faithfulness.py, markers don't appear to be validated before the judge runs (apologies if I've missed it), so this case currently:

  • costs a judge call to detect, and
  • depends on the judge noticing, rather than failing deterministically.

Proposal

Before calling the judge, extract the [N] markers from actual_output. If any N is less than 1 or greater than len(retrieval_context), return a score of 0.0 with a reason listing the invalid markers, and skip the judge call. Answers where every marker is in range go to the judge exactly as today.

  • Consistent with the metric's current binary verdict (0.0 / 1.0).
  • Saves a judge call on this failure mode.
  • Gives a precise, deterministic reason instead of a model-written one.

Motivation

I hit fabricated citations while evaluating a legal RAG assistant: the model cited sources that were never in its retrieved context. A deterministic check caught them reliably, and every case was cheap to detect without a judge.

Questions for maintainers

  1. Is this worth adding, and should it be always-on or behind an option?
  2. Any preference on how the reason should be worded?

Happy to open a PR with tests if this sounds useful.