Citations and Grounding

Phase 9 · Document 08 · RAG Prev: 07 — Context Packing · Up: Phase 9 Index

Table of Contents

  1. Why This Matters
  2. Core Concept
  3. Mental Model
  4. Hitchhiker's Guide
  5. Warmup Readings
  6. Deep Readings and External References
  7. Key Terms
  8. Important Facts
  9. Observations from Real Systems
  10. Common Misconceptions
  11. Engineering Decision Framework
  12. Hands-On Lab
  13. Verification Questions
  14. Takeaways
  15. Artifact Checklist

1. Why This Matters

This is the generation stage of RAG and the one that makes RAG trustworthy: grounding (answer only from the retrieved context, not the model's parametric memory) and citations (point each claim back to its source). Without grounding, RAG still hallucinates — confidently inventing facts even when good context is present. Without citations, users can't verify answers, which is fatal for legal, medical, support, and enterprise use where a wrong-but-confident answer is worse than none. Grounding + citations are what let a business ship an LLM that "knows our docs" with accountability. And the hard truth: even with perfect retrieval, a weakly-grounded generator will hallucinate — so this stage is non-negotiable, and it must be measured (09).


2. Core Concept

Plain-English primer: answer from the sources, and prove it

The generator's job in RAG is narrow on purpose: synthesize an answer using only the provided context, cite which source supports each claim, and refuse when the context doesn't contain the answer. Two linked ideas:

  • Grounding (faithfulness): every factual claim in the answer is supported by the retrieved chunks — the model isn't drawing on training memory or making things up. An answer is faithful if a reader checking the cited chunks would agree the claim is backed.
  • Citation / attribution: the answer marks which source backs which claim (e.g., [2]policy.pdf p.4), so a human (or an automated checker) can verify.

These are distinct: an answer can be cited but unfaithful (cites a source that doesn't actually say it) or faithful but uncited (correct, but unverifiable). You want both.

How to get grounded, cited answers

1. The grounding system prompt. Instruct the model explicitly:

Answer the question using ONLY the provided sources.
- For every factual claim, cite the supporting source as [N].
- If the sources do not contain the answer, say: "I don't have information about this in the provided documents." Do not use outside knowledge or guess.

This narrows the next-token distribution toward grounded, cited output (what-happens §5). It works with the packing's source markers (07) — the model can only cite [N] if you labeled the chunks [SOURCE N].

2. Refusal / "I don't know" is a feature. A grounded system must be willing to refuse when the context lacks the answer. Punishing "I don't know" pushes the model to hallucinate; rewarding honest refusal is core to trust. Measure refusal-appropriateness, not just answer rate.

3. Citation granularity. Cite at a useful level: source/document, page/section, or — best for verification — the specific quote/span. Span-level grounding (the model quotes or points to the exact sentence) is the gold standard for high-stakes domains.

4. Verify citations (don't trust them). Models can cite a source that doesn't support the claim ("citation hallucination"). A robust pipeline verifies: check that cited chunk IDs exist in the context, and (stronger) run an NLI/entailment or LLM-judge check that the cited chunk actually entails the claim (09). Reject/flag unverifiable claims.

SYSTEM = ("Answer using ONLY the sources. Cite each claim as [N]. "
          "If the answer isn't in the sources, say you don't know. Don't use outside knowledge.")
def answer(question, packed_context):           # packed_context has [SOURCE N] markers [07]
    resp = llm(SYSTEM, f"Sources:\n{packed_context}\n\nQuestion: {question}")
    cited = extract_citations(resp)             # e.g. {2,5}
    verify_citation_ids(cited, packed_context)  # cited IDs must exist
    # stronger: for each claim, check the cited chunk ENTAILS it (NLI / judge) [09]
    return resp

Why grounding fails even with good context

Hallucination-despite-RAG has a few causes you must distinguish (09 is how you tell which):

  • Retrieval miss — the answering chunk wasn't retrieved; the model fills the gap from memory. (Fix retrieval — 05/06; this is the most common cause.)
  • Weak grounding prompt — the model wasn't firmly told to use only the sources / to refuse. (Strengthen the system prompt; add few-shot.)
  • Conflicting/insufficient context — sources disagree or partially answer; the model "resolves" by inventing. (Surface conflict; allow partial/refuse.)
  • Model limitation — some models ground better than others (Phase 5.05); reasoning/instruction-following quality matters.

Grounding is a spectrum of strictness

Trade strictness vs helpfulness to the use case:

  • Strict (legal/medical/compliance): only stated facts, span-level citations, refuse aggressively, verify every claim.
  • Lenient (brainstorming/internal search): use context as grounding but allow synthesis/reasoning on top.

Set the strictness deliberately; the same pipeline serves both with different prompts/verification (Phase 5.07 for structured citation output).


3. Mental Model

   GENERATION = answer using ONLY the packed sources [07] + CITE each claim + REFUSE if absent
     GROUNDING/FAITHFULNESS: every claim is SUPPORTED by a retrieved chunk (no parametric memory)
     CITATION: mark which [SOURCE N] backs which claim → user/automated VERIFICATION

   distinct failures: cited-but-unfaithful  vs  faithful-but-uncited  → want BOTH
   levers: ① grounding SYSTEM PROMPT (only sources, cite [N], refuse) ② "I don't know" is a FEATURE
           ③ citation granularity (doc→page→SPAN) ④ VERIFY citations (IDs exist + NLI/judge entailment) [09]

   hallucination-despite-RAG cause? → retrieval miss (most common) / weak prompt / conflicting ctx / model
   strictness spectrum: STRICT (legal/medical: span cites, verify, refuse) ↔ LENIENT (search/brainstorm)

Mnemonic: answer only from sources, cite each claim, refuse when absent — then verify the citations. Grounding ≠ citation; you want both. Most "hallucination despite RAG" is a retrieval miss.


4. Hitchhiker's Guide

What to look for first: a strong grounding system prompt (only-sources + cite + refuse) and source markers in the packed context (07). Then a citation-verification check.

What to ignore at first: elaborate NLI verification and span-level extraction. Start with "cite [N], refuse if absent" + verify cited IDs exist; add entailment checking when stakes demand.

What misleads beginners:

  • Assuming RAG stops hallucination. It doesn't — a weak grounding prompt or a retrieval miss still produces confident fabrication (00).
  • Trusting citations. Models cite sources that don't support the claim — verify (09).
  • Punishing "I don't know." That trains hallucination — reward honest refusal.
  • No source markers. Then the model can't cite anything (07).
  • Conflating faithful and cited. Measure and require both.

How experts reason: they make the generator answer only from context, cite each claim, and refuse when unsupported; they keep source markers from packing; they verify citations (IDs + entailment) and treat appropriate refusal as success; and they set strictness to the domain. When grounding fails, they first ask "was the right chunk retrieved?" (retrieval) before blaming the prompt.

What matters in production: faithfulness (no hallucination), citation correctness (verified, not just present), appropriate refusal rate, and the latency/cost of any verification step — all tracked in eval (09).

How to debug/verify: for a hallucinated answer, inspect the packed context — was the supporting chunk there? If no → retrieval (05/06). If yes → grounding (strengthen prompt, verify citations, check the model, Phase 5.05). Run faithfulness eval on a labeled set.

Questions to ask: does the prompt enforce only-sources + cite + refuse? are citations verified (entailment)? what citation granularity? what's the appropriate-refusal rate? does the model ground well on our data?

What silently gets expensive/unreliable: unverified citations (false trust), hallucination from weak grounding, suppressed refusals (fabrication), and missing source markers (no verifiability).


5. Warmup Readings

TitleWhy to read itWhat to extractDifficultyTime
07 — Context PackingSource markers enable citations[SOURCE N]Beginner15 min
what-happens §5 — prompt shapes outputWhy the grounding prompt worksconditioningBeginner10 min
09 — RAG EvaluationMeasuring faithfulnessfaithfulness metricIntermediate20 min
Phase 5.05 — RAG ModelsModel grounding qualitygenerator choiceBeginner15 min

6. Deep Readings and External References

TitleURLWhy it mattersRead firstLab connection
Ragas faithfulnesshttps://docs.ragas.io/en/stable/concepts/metrics/Faithfulness/attribution metricsfaithfulness, answer-relevancy09
Anthropic citationshttps://docs.anthropic.com/en/docs/build-with-claude/citationsNative source citationscitation APICitation lab
OpenAI structured outputshttps://platform.openai.com/docs/guides/structured-outputsSchema'd citationsJSON citationsStructured citations
TruLens / groundednesshttps://www.trulens.org/Groundedness evaluationgroundednessVerify lab
"When not to trust LLMs" (self-RAG/CRAG)https://arxiv.org/abs/2310.11511Self-grounding/refusalthe approachRefusal

7. Key Terms

TermSimple meaningTechnical meaningWhy it mattersWhere it appearsHow to use it
GroundingAnswer from sourcesClaims supported by retrieved contextNo hallucinationgenerationEnforce in prompt
FaithfulnessSupported answerClaims entailed by contextTrust metriceval [09]Measure
CitationSource pointer[N] → chunk/sourceVerifiabilityanswerMark + verify
AttributionClaim→source linkWhich source backs which claimAccountabilityanswerSpan-level best
RefusalHonest "don't know"Decline when unsupportedAnti-hallucinationpromptReward it
Citation hallucinationWrong citationCites a non-supporting sourceFalse trustfailureVerify entailment
Citation granularityCite precisiondoc / page / spanVerification easeformatSpan for high-stakes
StrictnessGrounding rigorStrict↔lenientMatch use casepolicySet per domain

8. Important Facts

  • The generator must answer only from context, cite each claim, and refuse when unsupported — grounding + citations make RAG trustworthy.
  • RAG does not stop hallucination by itself — weak grounding or a retrieval miss still fabricates (00).
  • Grounding (faithfulness) ≠ citation — answers can be cited-but-unfaithful or faithful-but-uncited; require both.
  • "I don't know" is a feature — reward appropriate refusal; punishing it trains hallucination.
  • Citations must be verified (IDs exist + the cited chunk entails the claim) — models commit citation hallucination (09).
  • Citation granularity ranges doc → page → span; span-level is best for verification/high-stakes.
  • Source markers from packing (07) are what make [N] citations possible.
  • Most "hallucination despite RAG" is a retrieval miss — check retrieval before the prompt (05/06).

9. Observations from Real Systems

  • Enterprise/legal/medical RAG mandates citations + verification — an unverifiable answer is unusable in those domains (10).
  • Anthropic ships a native Citations feature; OpenAI structured outputs let you return citations as schema'd JSON (Phase 5.07).
  • Ragas faithfulness / TruLens groundedness are the standard ways teams measure whether answers are actually grounded (09).
  • Self-RAG / CRAG-style approaches add self-checking and refusal to reduce ungrounded answers.
  • The recurring trust bug: a confident answer citing [3], where chunk 3 doesn't actually say it — caught only by citation verification.

10. Common Misconceptions

MisconceptionReality
"RAG eliminates hallucination"Only with strong grounding + good retrieval + verification
"If it cites a source, it's correct"Citation hallucination is real — verify entailment
"Always answer"Appropriate refusal is success, not failure
"Citation = faithfulness"Distinct; require both
"Cite the document is enough"Span/page citations are far more verifiable
"Hallucination means a bad model"Usually a retrieval miss — check retrieval first

11. Engineering Decision Framework

GROUND + CITE:
 1. PROMPT: "answer ONLY from sources; cite each claim as [N]; refuse if absent; no outside knowledge."
 2. MARKERS: packed context must have [SOURCE N] tags [07] (else no citations possible).
 3. REFUSAL: allow + reward honest "I don't know"; measure refusal-appropriateness, not just answer rate.
 4. GRANULARITY: doc → page → SPAN; use span/page for high-stakes (legal/medical).
 5. VERIFY: cited IDs exist; (stronger) NLI/judge that cited chunk ENTAILS the claim → flag/reject if not. [09]
 6. STRICTNESS: set strict (verify all, refuse aggressively) ↔ lenient (allow synthesis) per domain.
 7. WHEN UNFAITHFUL: was the chunk retrieved? NO→retrieval [05/06]; YES→prompt/model [5.05].
Use caseStrictness / approach
Legal / medical / complianceStrict: span citations, verify every claim, refuse
Customer supportModerate: cite source/page, verify, allow "contact us"
Internal search / brainstormLenient: ground + cite, allow synthesis
High-stakes automationStrict + structured (JSON) citations [5.07]

12. Hands-On Lab

Goal

Build a grounded, cited generator and verify its citations — then prove RAG can still hallucinate without strong grounding.

Prerequisites

  • The packed context from 07 (with [SOURCE N] markers); a generation model; ~10 labeled questions including some unanswerable from the corpus.

Steps

  1. Grounded generation: use the §2 grounding system prompt; generate answers with [N] citations for the labeled questions.
  2. Refusal test: include questions whose answer is not in the corpus; confirm the model refuses ("I don't have information…") rather than fabricating. Count appropriate refusals.
  3. Weak-prompt contrast: rerun with a weak prompt ("Use the context to answer") and show it hallucinates / uses outside knowledge on the unanswerable questions — demonstrating grounding is the prompt's job, not RAG's by default.
  4. Citation verification: parse cited [N]; (a) assert each cited ID exists in the context; (b) for each claim, run an entailment check (an LLM-judge or NLI model: "does chunk N support this claim?") and flag unsupported claims (citation hallucination).
  5. Faithfulness score: compute a simple faithfulness rate (supported claims / total claims) across the set, and compare strong vs weak prompt (09).
  6. Retrieval-vs-grounding split: for any hallucination, check whether the supporting chunk was in the context — bucket the failure as retrieval vs grounding.

Expected output

Grounded, cited answers; an appropriate-refusal count; a strong-vs-weak-prompt faithfulness comparison; and a citation-verification pass flagging any citation hallucinations.

Debugging tips

  • Model still hallucinates with the strong prompt → the supporting chunk wasn't retrieved (retrieval, 05/06) or the model grounds poorly (Phase 5.05).
  • Citations point to wrong chunks → citation hallucination; add/strengthen entailment verification.

Extension task

Return citations as structured JSON (claim → source span) via structured outputs (Phase 5.07) and render clickable source spans.

Production extension

Add an automated faithfulness + citation-verification gate to the response path (flag/withhold unverifiable answers), tuned to the domain's strictness (10, 09).

What to measure

Faithfulness rate (strong vs weak prompt); appropriate-refusal rate; citation-verification pass rate (entailment); retrieval-vs-grounding failure split.

Deliverables

  • A grounded, cited generator + a refusal demonstration.
  • A strong-vs-weak prompt faithfulness comparison.
  • A citation-verification check (IDs + entailment) flagging hallucinated citations.

13. Verification Questions

Basic

  1. What's the difference between grounding/faithfulness and citation?
  2. Why is "I don't know" a feature, not a failure?
  3. What is citation hallucination, and how do you catch it?

Applied 4. Write a grounding system prompt and explain each instruction. 5. Choose citation granularity and verification strictness for (a) legal, (b) internal search.

Debugging 6. RAG hallucinates despite a strong grounding prompt. What's the most likely cause, and how do you confirm? 7. Answers cite sources that don't support them. Fix?

System design 8. Design a generation + verification stage that guarantees verifiable, grounded answers for a compliance use case.

Startup / product 9. Why are citations + grounding often the difference between a demo and a sellable enterprise RAG product?


14. Takeaways

  1. Ground (answer only from context) + cite (point each claim to its source) + refuse (when absent) — this makes RAG trustworthy.
  2. RAG alone doesn't stop hallucination — it takes a strong grounding prompt, good retrieval, and verification.
  3. Faithfulness ≠ citation — require both; verify citations (IDs + entailment), don't trust them.
  4. Reward appropriate refusal; choose citation granularity (span best for high-stakes) and strictness by domain.
  5. Most hallucination-despite-RAG is a retrieval miss — check retrieval before the prompt (05/06).

15. Artifact Checklist

  • A grounded, cited generator (only-sources + cite + refuse).
  • A refusal demonstration on unanswerable questions.
  • A strong-vs-weak prompt faithfulness comparison.
  • A citation-verification check (IDs + entailment) flagging hallucinated citations.
  • A strictness/granularity policy chosen for your domain.

Up: Phase 9 Index · Next: 09 — RAG Evaluation