rag_citations

RAG Citation Quality

Measures whether a RAG response's cited sources and passages match the ground-truth references and source documents expected for the query.
Tags:

Performance

Overview

The RAG Citation Quality evaluation measures whether a RAG model cites the correct source documents and passages for its response. A low score indicates the model cites the wrong documents, cites passages that do not support its claims, or omits sources it should have cited.

Metrics

Context Recall

The fraction of ground-truth reference passages that are matched by at least one response citation (range: 0.0 to 1.0).

Context Recall
0.01.0
0.0
0.5
0.7
0.9
1.0
0.0No ground-truth passages are cited - critical failure.
0.5Half of ground-truth passages are cited - significant omissions.
0.770% of ground-truth passages are cited - moderately complete.
0.990% of ground-truth passages are cited - nearly complete.
1.0All ground-truth passages are cited - complete citation coverage.

Context Precision

The fraction of response citations whose cited passage matches at least one ground-truth reference (range: 0.0 to 1.0).

Context Precision
0.01.0
0.0
0.5
0.7
1.0
0.0No response citations match any ground-truth reference - all citations are incorrect.
0.5Half of response citations match a ground-truth reference - frequent hallucinated citations.
0.770% of response citations match a ground-truth reference - mostly correct.
1.0All response citations match a ground-truth reference - no spurious citations.

Context F1

The harmonic mean of Context Recall and Context Precision (range: 0.0 to 1.0).

Context F1
0.01.0
0.0
0.5
0.7
1.0
0.0Context Recall or Precision is zero - either all references are missed or all citations are wrong.
0.5Moderate balance of recall and precision - notable gaps in coverage or correctness.
0.7Good balance of recall and precision - most references are cited and most citations are correct.
1.0Perfect recall and precision - all references are cited and all citations are correct.

Source Recall

The fraction of expected source documents that appear in the response citations (range: 0.0 to 1.0).

Source Recall
0.01.0
0.0
0.5
1.0
0.0None of the expected sources are cited - all source documents are missing.
0.5Half of the expected sources are cited - significant source omissions.
1.0All expected sources are cited - complete source coverage.

Source Precision

The fraction of response-cited source documents that are among the expected sources (range: 0.0 to 1.0).

Source Precision
0.01.0
0.0
0.5
1.0
0.0None of the cited sources are expected - critical failure.
0.5Half of the cited sources are expected - frequent incorrect citations.
1.0All cited sources are expected - no incorrect citations.

Source F1

The harmonic mean of Source Recall and Source Precision (range: 0.0 to 1.0).

Source F1
0.01.0
0.0
0.5
1.0
0.0Source Recall or Precision is zero - either all expected sources are missing or all cited sources are wrong.
0.5Moderate balance of source recall and precision - notable gaps in source coverage or correctness.
1.0Perfect source recall and precision - all expected sources are cited and no unexpected sources appear.

Motivation

The citations provided in the RAG system's response give us insights into how the answer was conceived. Comparing the citations from the response with the set of expected citations can help with understanding why the model might not be performing as expected. This evaluation measures citation quality at two levels:

  • Source level: Did the model cite the right documents? A model may retrieve irrelevant documents (low source precision) or miss key documents entirely (low source recall).
  • Passage level: Did the model cite the right passages within those documents? Citing the correct document is necessary but not sufficient — a model can cite the right source yet ground its answer in a passage that does not support the claim (low context precision), or fail to cite the specific passages that do (low context recall).

Understanding both dimensions helps diagnose whether a model is retrieving the wrong documents, citing the wrong passages of the right documents, or citing the right passages but still coming to the wrong conclusions.

Methodology

This evaluation measures whether a model's cited sources and passages match the ground-truth references and expected sources for the query.

  1. Test Cases: This evaluation relies on test cases that consist of a user query that can be answered using the RAG knowledge base, together with ground-truth reference evidence passages and expected source documents.
  2. Model Response: The evaluated model receives the query, retrieves relevant documents from the knowledge base, and produces a response with citations referencing the passages and documents used.
  3. Scoring: Each ground-truth reference is checked against the response's citations to determine whether its passage was matched (recall), and each response citation is checked against the ground-truth references to determine whether it is correct (precision). The same comparison is performed at the document level to compute source recall and precision. Context and source recall/precision/F1 scores are computed as the fraction of matched references, citations, and documents, respectively.

Passages are compared using the match_method configured for the evaluation. The available methods are:

  • substring: Each part of the response passage (split on ellipsis markers or ...) must appear inside the ground-truth passage, or the full ground-truth passage must appear inside the response passage. Fast and exact, but sensitive to minor wording differences.
  • ngram (default): Token n-gram overlap between the two passages must reach the configured match_threshold. Tolerant of minor paraphrasing and truncation. Note that the overlap is computed for the shorter passage, meaning that a short and a long passage can still match, as long as most of the short passage is contained in the long one.
  • embeddings: OpenAI embeddings are used to compute cosine similarity between the passages. A match is declared when the similarity reaches the configured match_threshold. Requires the openai_api_key to be set in the task configuration.
  • llm: An OpenAI model judges whether both passages refer to the same part of the source document, regardless of wording. The most flexible method but slowest and most expensive. Requires the openai_api_key to be set in the task configuration.

Note that passage matching is deliberately tolerant in one edge case: if the ground-truth reference has no content (empty passage), it is considered matched by any response citation that cites the same document.

Scoring

Context Recall

key: context_recall label: Context Recall entries: - value: 1.0 color: green explanation: All ground-truth passages are each matched by at least one response citation - the model correctly cited all expected supporting passages. - value: 0.5 color: medium explanation: Half of the ground-truth passages are matched by at least one response citation - the model cited some but not all expected supporting passages. - value: 0.0 color: red explanation: None of the ground-truth passages are matched by any response citation - the model failed to cite any of the expected supporting passages.

Context Precision

key: context_precision label: Context Precision entries: - value: 1.0 color: green explanation: All response citations' passages each match at least one ground-truth reference - every citation is correct and refers to an expected supporting passage. - value: 0.5 color: medium explanation: Half of the response citations' passages match a ground-truth reference - some citations are correct while others are spurious or refer to an unexpected passage. - value: 0.0 color: red explanation: None of the response citations' passages match any ground-truth reference - all citations are spurious or refer to an unexpected passage.

Context F1

The harmonic mean of Context Recall and Context Precision.

Source Recall

key: source_recall label: Source Recall entries: - value: 1.0 color: green explanation: The expected source documents appear in at least one response citation each - the model correctly cited all expected sources. - value: 0.5 color: medium explanation: Half of the expected source documents appear in a response citation - the model cited some expected sources but omitted others. - value: 0.0 color: red explanation: The expected source documents do not appear in any response citation - the model failed to cite any of the expected sources.

Source Precision

key: source_precision label: Source Precision entries: - value: 1.0 color: green explanation: The cited source documents are all among the expected sources - these citations refer to expected source documents only. - value: 0.5 color: medium explanation: Half of the cited source documents are among the expected sources - some citations refer to correct sources while others are unexpected or irrelevant. - value: 0.0 color: red explanation: The cited source documents are not among the expected sources - these citations refer to unexpected or irrelevant source documents.

Source F1

The harmonic mean of Source Recall and Source Precision.

Examples

High citation quality - correct source and passage cited

Ground-truth references
CitationEvidence Passage
Remote Work Policy.pdfEmployees shall submit a remote work request at least five (5) business days prior to the requested start date.
Expected sources

Remote Work Policy.pdf

User
How many days in advance must I submit a remote work request?
Assistant
You must submit your remote work request at least five business days in advance.
Context Recall
1.0

The only response citation matches the ground-truth reference from Remote Work Policy.pdf — all expected evidence passages are cited.

Context Precision
1.0

The only response citation matches the ground-truth reference — there are no spurious citations.

Context F1
1.0

Both context recall and precision are perfect.

Source Recall
1.0

Remote Work Policy.pdf, the only expected source, appears in the response citations.

Source Precision
1.0

The only cited document, Remote Work Policy.pdf, is among the expected sources.

Source F1
1.0

Both source recall and precision are perfect.

Correct document cited, but wrong passage

Ground-truth references
CitationEvidence Passage
Employment Contract.pdfEmployees are required to provide a minimum of four (4) weeks written notice of resignation.
Expected sources

Employment Contract.pdf

User
What is the minimum notice period for resignation?
Assistant
Employees must provide at least four weeks of written notice before resigning.
Context Recall
0.0

The cited passage is about probation and severance, not resignation notice — it does not match the ground-truth evidence passage.

Context Precision
0.0

The response citation's evidence passage does not match the ground-truth reference — the cited passage refers to probation and severance rather than resignation notice.

Context F1
0.0

Both context recall and precision are zero.

Source Recall
1.0

Employment Contract.pdf, the only expected source, appears in the response citations.

Source Precision
1.0

Employment Contract.pdf is the expected source, so the document-level citation is correct even though the passage is wrong.

Source F1
1.0

Both source recall and precision are perfect.

Mixed result - multiple documents, partial coverage

Ground-truth references
CitationEvidence Passage
Data Security Policy.pdfRemote workers must use a company-approved VPN at all times when accessing internal systems from outside the office.
Remote Work Policy.pdfAll devices used for remote work must have full-disk encryption and approved endpoint security software installed.
Acceptable Use Policy.pdfEmployees must not store confidential company data on personal devices or unapproved cloud storage services.
Expected sources

Data Security Policy.pdf, Remote Work Policy.pdf, Acceptable Use Policy.pdf

User
What are the data security requirements for remote workers?
Assistant
Remote workers must use a VPN when accessing company systems, ensure their devices have encryption and security software, and avoid storing data on personal devices.
Context Recall
0.33

Only the Data Security Policy.pdf passage matches its ground-truth reference (1 of 3). The Remote Work Policy.pdf citation uses a wrong passage, and Acceptable Use Policy.pdf is not cited at all.

Context Precision
0.33

Only the Data Security Policy.pdf citation matches a ground-truth reference (1 of 3). The Remote Work Policy.pdf citation uses a wrong passage, and IT Compliance Handbook.pdf has no matching ground-truth reference.

Context F1
0.33

Context recall and precision are equal at 0.33.

Source Recall
0.67

Data Security Policy.pdf and Remote Work Policy.pdf are cited, but Acceptable Use Policy.pdf is not (2 of 3 expected sources).

Source Precision
0.67

Data Security Policy.pdf and Remote Work Policy.pdf are expected sources, but IT Compliance Handbook.pdf is not (2 of 3 cited sources are expected).

Source F1
0.67

Source recall and precision are equal at 0.67.

Run Evaluation in LatticeFlow AI Platform

Use the following CLI command to initialize and run the evaluation in LatticeFlow AI Platform.
Requires LatticeFlow AI Platform CLI
lf init --atlas rag_citations

Metrics

Context Recall

Context Precision

Context F1

Source Recall

Source Precision

Source F1

Don't have the LatticeFlow AI Platform?

Contact us to see this evaluation in action:
Contact Us