RAG evaluation: a faithful answer can still be wrong
RAG 评测
Separate retrieval, factuality, grounding, citations and abstention with explicit finite labels.
rag-evaluationA perfectly cited answer from last year’s notice
The current fictional museum notice says Orion opens Tuesday. An older notice says Monday. A system retrieves the older notice, repeats Monday accurately and cites it correctly. It is faithful to its context and factually wrong under the current reference. Another system guesses Tuesday while retrieving only a Lyra notice: correct answer, unsupported evidence.
RAG evaluation must distinguish where success or failure occurred. Retrieval relevance, evidence sufficiency, answer correctness, faithfulness, citation support and appropriate abstention ask different questions. RAGAS v1 decomposes context-grounded answers into statements and asks an LLM to verify their support. ARES trains separate judges for context relevance, answer faithfulness and answer relevance, then uses labeled data with prediction-powered inference to estimate system quality. Neither makes a model judgment identical to truth. RAGAS, physical PDF 3 ARES, physical PDF 3–4
Before choosing an automated judge, write a small set of explicit examples with independently specified sources and expected outcomes. A manual answer-and-evidence review is a useful baseline. A single aggregate score can conceal the reason the next release regressed.
Keep the denominators visible
For a query with a nonempty relevant document set R, retrieval recall is:
This requires relevance labels; an unjudged document is not necessarily irrelevant. Relevance is also weaker than sufficiency: one document can be on topic while omitting a necessary condition.
Let A contain distinct atomic answer claims. Faithfulness asks which follow from the supplied context C:
The entailment symbol means “supports this claim,” not “contains the same substring.” Negation, dates and conditions matter. RAGAS approximates this decision with generated statements and an LLM verifier. That introduces errors both when decomposing an answer and when judging support. RAGAS
Factual correctness uses an independently established reference T:
Our finite example implements T as a set of authored true proposition IDs. This measures the correctness of stated claims, not answer completeness. A system saying one safe but unhelpful fact can score well while failing to answer the question; track answer relevance and completeness separately.
Let L be claim–citation pairs and Lplus the supported pairs. Citation precision and coverage have different denominators:
An answer may be supported somewhere in the context but cite the wrong passage. Conversely, every provided citation may be valid while many claims have no citation. Empty denominators return None in this example, rather than awarding an empty answer a perfect score. Abstention is evaluated as a separate decision.
For an illustrative independent Bernoulli sample with n decisions, success fraction phat and normal critical value z, a Wilson interval is:
It follows by solving the normal score-test inequality for the unknown probability. This approximate interval is not a guarantee for correlated queries, shifted traffic or biased judges. Our five deliberately chosen counterexamples are not a random sample and receive no such confidence interval. The separate 8-of-10 calculation only demonstrates the formula.
Five cases that a single score would confuse
Run the standalone Python 3.12 program; it uses only the standard library. Evidence sets, truth labels and answer claims are manually specified by the author in an invented world. Set membership is a complete oracle only for this finite fixture. There is no natural-language parser, model judge, RAGAS API call or ARES training run.
"""Explicit finite proposition annotations; no automatic natural-language judge."""
import json
import math
# Evidence and truth are deliberately independent annotations in an invented world.
EVIDENCE = {'new': {'orion_tuesday', 'orion_noon'}, 'old': {'orion_monday'}, 'lyra': {'lyra_friday'}}
TRUTH = {'orion_tuesday', 'orion_noon', 'lyra_friday'}
def score(retrieved, claims, citations, relevant, should_answer=True):
if len(set(retrieved)) != len(retrieved) or len(set(claims)) != len(claims):
raise ValueError('unique evidence and atomic claims required')
if set(retrieved)-EVIDENCE.keys() or set(relevant)-EVIDENCE.keys():
raise ValueError('unknown source')
if set(citations)-set(claims):
raise ValueError('citation assigned to absent claim')
if any(set(ids)-set(retrieved) for ids in citations.values()):
raise ValueError('citation must refer to retrieved evidence')
supported = set().union(*(EVIDENCE[d] for d in retrieved))
total = len(claims)
cited = [(c,d) for c in claims for d in citations.get(c,[])]
valid = [(c,d) for c,d in cited if c in EVIDENCE[d]]
return dict(recall=len(set(retrieved)&set(relevant))/len(relevant) if relevant else None,
faithfulness=sum(c in supported for c in claims)/total if total else None,
correctness=sum(c in TRUTH for c in claims)/total if total else None,
citation_precision=len(valid)/len(cited) if cited else None,
citation_coverage=len(set(c for c,d in valid))/total if total else None,
answered=bool(claims), appropriate_decision=(bool(claims)==should_answer))
def wilson(successes, n, z=1.96):
if not isinstance(n,int) or not isinstance(successes,int) or not 0 <= successes <= n or n == 0 or not math.isfinite(z) or z <= 0:
raise ValueError('positive n and valid count required')
p = successes/n; den = 1+z*z/n
center = (p+z*z/(2*n))/den
radius = z*math.sqrt(p*(1-p)/n+z*z/(4*n*n))/den
return [center-radius,center+radius]
def demo():
cases = [
('grounded',['new'],['orion_tuesday'],{'orion_tuesday':['new']},['new'],True),
('stale',['old'],['orion_monday'],{'orion_monday':['old']},['new'],True),
('unsupported',['lyra'],['orion_tuesday'],{'orion_tuesday':['lyra']},['new'],True),
('mixed',['new'],['orion_tuesday','orion_monday'],{'orion_tuesday':['new'],'orion_monday':['new']},['new'],True),
('abstain',[],[],{},[],False)]
return dict(cases=[dict(name=name,**score(*args)) for name,*args in cases],
illustrative_wilson=wilson(8,10), interval_scope='hypothetical iid Bernoulli sample; not the five designed cases')
if __name__ == '__main__':
print(json.dumps(demo(), allow_nan=False))
The grounded case has faithfulness and correctness 1. The stale case has faithfulness 1 and correctness 0. The unsupported guess reverses that pair. The mixed answer has both scores 0.5. The appropriate abstention has no claims, so claim-level ratios are undefined, while its decision is marked appropriate. A separate test retrieves both notices but attaches the wrong citation, demonstrating why context support and citation support must be checked independently.
The hypothetical 8-of-10 Wilson interval is approximately [0.4902,0.9433] with z=1.96. Reporting only “80%” hides how little that small sample establishes. It would be incorrect to attach this interval to the five designed cases or to a set of unchecked model labels and call it a population guarantee.
For this finite set representation, scoring work is proportional to the evidence propositions, claims and citation pairs inspected. General natural-language evaluation has extra statement-extraction and inference costs; the program does not estimate them. Preserve per-query outputs so a failure can be traced back to the retrieved source and exact claim.
Calibrate a judge before trusting its ranking
ARES uses synthetic data to prepare judges and a human-annotated validation set in its evaluation workflow. Its prediction-powered inference step corrects aggregate estimates using labeled evidence; it is not the same as putting a confidence interval around raw judge outputs. This example implements neither ARES’s classifiers nor PPI. ARES
Hold out evaluation queries from prompt tuning, retriever training and synthetic-example selection. Compare systems on the same queries and inspect paired changes; overlapping marginal intervals alone do not answer whether a paired improvement is reliable. Repeated questions about the same source may be correlated, so sampling and uncertainty calculations must reflect that structure.
Test outdated evidence, contradictions, missing evidence, answerable and unanswerable questions, and citations that point to the wrong span. Report coverage, abstention errors, latency and cost alongside answer scores. Set acceptance thresholds according to the application’s error costs; the museum fixture cannot establish a threshold for another domain.
Name the failure before choosing a metric
- Explain. Why can faithfulness be 1 while correctness is 0? Answer: An answer can accurately repeat a stale or false source. Faithfulness uses the supplied context; correctness uses an independent reference appropriate to the question’s time and scope.
- Calculate. An answer has two claims, one supported and true, one unsupported and false. Both cite the same source, which supports only the first. What scores result? Answer: Faithfulness, correctness, citation precision and citation coverage are all 0.5 in the stated finite setup. This numerical coincidence does not make the metrics equivalent.
- Modify. Return no claims when evidence is missing. Should faithfulness become 1? Answer: No. The denominator is zero, so it remains undefined here. Evaluate whether abstention was appropriate using a separate answerability label.
- Investigate. How would you validate a new model judge? Answer: Compare its decisions with independently reviewed labels across the intended query and failure types, measure systematic disagreements, and keep calibration data separate from the final comparison. Report the sampling assumptions and the judge version.
Automated evaluation still needs an evidence chain
RAGAS v1 makes statement-level faithfulness operational through prompting; ARES adds trained judges and statistical correction with labels. These are specific versions and workflows, not claims about every later package API. Read RAG for the pipeline and confidence intervals for uncertainty. The five cases here are original diagnostic tests, not a benchmark score for either framework.
Make a prediction, then check
An answer repeats an outdated source accurately. Which pair is possible?
Learning objectives
- Locate failures at the appropriate stage instead of collapsing them into one score.
- Run the original example, explain its counterexample and identify the untested deployment assumptions.
Prerequisites & connections
Explore related knowledge →References
- RAGAS: Automated Evaluation of Retrieval Augmented Generation — arXiv v1
Shahul Es; Jithin James; Luis Espinosa-Anke; Steven Schockaert · 2023 - ARES: An Automated Evaluation Framework for Retrieval-Augmented Generation Systems — arXiv v1
Jon Saad-Falcon; Omar Khattab; Christopher Potts; Matei Zaharia · 2023
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-20 · Single AI author. Recorded source scopes (some exact source objects reused from earlier checks): Read PDF 1 identity and 3: faithfulness statement extraction/verification, answer relevance and context relevance introduction. No judge calls or score reproduction. Read PDF 1 identity, 3–4: synthetic positives/negatives, three classifiers, annotated validation set and PPI correction. No trained judges or PPI reproduction. 5 paired equations and four explained exercises. Checked finite independent truth/support labels, stale and unsupported answers, wrong citations, abstention and Wilson endpoints. The interval is not applied to designed cases. No LLM judge or PPI reproduction.
- Checked finite independent truth/support labels, stale and unsupported answers, wrong citations, abstention and Wilson endpoints. The interval is not applied to designed cases. No LLM judge or PPI reproduction.
- Four computed SVG variants per topic;12 numeric/geometry tests and42 responsive cases passed. Fourteen selected final captures directly viewed. Full article acceptance recorded separately.
Source locations checked:
- RAGAS: Automated Evaluation of Retrieval Augmented Generation — arXiv v1 · Read PDF 1 identity and 3: faithfulness statement extraction/verification, answer relevance and context relevance introduction. No judge calls or score reproduction.
- ARES: An Automated Evaluation Framework for Retrieval-Augmented Generation Systems — arXiv v1 · Read PDF 1 identity, 3–4: synthetic positives/negatives, three classifiers, annotated validation set and PPI correction. No trained judges or PPI reproduction.
Related topics