Sub topic 12
Citation accuracy: do cited passages support the claims?
This chapter assumes you can read Python and know how claim-level faithfulness scoring works. You should also be comfortable with precision and recall. Many RAG systems attach citations such as [p2] to each statement so users can check the source. Faithfulness tells you whether the context supports the answer. Citation accuracy tells you whether the passage the answer points to supports the claim.
Why faithfulness is not enough
An answer can be fully faithful and still cite badly. Suppose the claim "It covers manufacturing defects" is supported by passage p2, but the answer cites p1. A faithfulness score of 1.0 hides this. A user who clicks p1 finds nothing relevant and loses trust.
Two scores
Citation accuracy is usually split into two numbers, borrowing from precision and recall.
| Metric | Question it answers | Computed over |
|---|---|---|
| Citation precision | Of the citations the answer gives, how many support their claim? | Each (claim, cited passage) pair |
| Citation recall | Of the claims, how many have at least one supporting citation? | Each claim |
Low precision means the answer cites wrongly or pads with irrelevant sources. Low recall means claims go unsourced or are sourced incorrectly.
Implementation
The key rule is that the verifier sees only the cited passage, not the whole context. Otherwise you are measuring faithfulness again. A cited ID that does not exist in the context (a fabricated citation) counts as unsupported.
def citation_scores(claims, passages, is_supported):
"""claims: list of {"text": str, "cited": [passage ids]}
passages: dict mapping passage id -> passage text
is_supported: function (claim_text, passage_text) -> bool
Returns (citation_precision, citation_recall); None where undefined.
"""
pair_hits = 0
pair_total = 0
claims_with_support = 0
for claim in claims:
any_supported = False
for pid in claim["cited"]:
pair_total += 1
passage = passages.get(pid)
if passage is not None and is_supported(claim["text"], passage):
pair_hits += 1
any_supported = True
if any_supported:
claims_with_support += 1
precision = pair_hits / pair_total if pair_total else None
recall = claims_with_support / len(claims) if claims else None
return precision, recall
def toy_judge(claim, passage):
return claim.lower() in passage.lower()
passages = {
"p1": "The warranty lasts 24 months.",
"p2": "It covers manufacturing defects.",
}
claims = [
{"text": "the warranty lasts 24 months", "cited": ["p1"]},
{"text": "it covers manufacturing defects", "cited": ["p1", "p2"]},
{"text": "it covers water damage", "cited": ["p9"]},
]
precision, recall = citation_scores(claims, passages, toy_judge)
print(round(precision, 3), round(recall, 3)) # 0.5 0.667Four pairs are checked. Two are supported, so precision is 0.5. Two of the three claims have a supporting citation, so recall is 0.667.
Common errors
- Checking against the whole context. This turns citation accuracy into faithfulness and hides miscitations.
- Ignoring invalid IDs. Generators sometimes invent
[p9]. Treat these as failures, and consider reporting their rate separately. - Reporting 1.0 for no citations. If an answer cites nothing, precision is undefined. Recall is 0, which is the signal you want.
- Scoring claims that need no citation. Greetings or restatements of the question can drag recall down. Filter them out during claim extraction.
- Trusting a toy judge. Substring matching rejects paraphrases. Use an NLI model or an LLM judge, and validate it against human labels.
Exercise
An answer has 5 claims and 8 (claim, passage) citation pairs. Six pairs are supported, and those six pairs cover 4 distinct claims. What are the citation precision and citation recall?
Show answer
Citation precision is 6/8 = 0.75, because it is computed over pairs. Citation recall is 4/5 = 0.8, because it is computed over claims, and 4 claims have at least one supporting citation.