Citations and Grounding
Phase 9 · Document 08 · RAG Prev: 07 — Context Packing · Up: Phase 9 Index
Table of Contents
- Why This Matters
- Core Concept
- Mental Model
- Hitchhiker's Guide
- Warmup Readings
- Deep Readings and External References
- Key Terms
- Important Facts
- Observations from Real Systems
- Common Misconceptions
- Engineering Decision Framework
- Hands-On Lab
- Verification Questions
- Takeaways
- 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
| Title | Why to read it | What to extract | Difficulty | Time |
|---|---|---|---|---|
| 07 — Context Packing | Source markers enable citations | [SOURCE N] | Beginner | 15 min |
| what-happens §5 — prompt shapes output | Why the grounding prompt works | conditioning | Beginner | 10 min |
| 09 — RAG Evaluation | Measuring faithfulness | faithfulness metric | Intermediate | 20 min |
| Phase 5.05 — RAG Models | Model grounding quality | generator choice | Beginner | 15 min |
6. Deep Readings and External References
| Title | URL | Why it matters | Read first | Lab connection |
|---|---|---|---|---|
| Ragas faithfulness | https://docs.ragas.io/en/stable/concepts/metrics/ | Faithfulness/attribution metrics | faithfulness, answer-relevancy | 09 |
| Anthropic citations | https://docs.anthropic.com/en/docs/build-with-claude/citations | Native source citations | citation API | Citation lab |
| OpenAI structured outputs | https://platform.openai.com/docs/guides/structured-outputs | Schema'd citations | JSON citations | Structured citations |
| TruLens / groundedness | https://www.trulens.org/ | Groundedness evaluation | groundedness | Verify lab |
| "When not to trust LLMs" (self-RAG/CRAG) | https://arxiv.org/abs/2310.11511 | Self-grounding/refusal | the approach | Refusal |
7. Key Terms
| Term | Simple meaning | Technical meaning | Why it matters | Where it appears | How to use it |
|---|---|---|---|---|---|
| Grounding | Answer from sources | Claims supported by retrieved context | No hallucination | generation | Enforce in prompt |
| Faithfulness | Supported answer | Claims entailed by context | Trust metric | eval [09] | Measure |
| Citation | Source pointer | [N] → chunk/source | Verifiability | answer | Mark + verify |
| Attribution | Claim→source link | Which source backs which claim | Accountability | answer | Span-level best |
| Refusal | Honest "don't know" | Decline when unsupported | Anti-hallucination | prompt | Reward it |
| Citation hallucination | Wrong citation | Cites a non-supporting source | False trust | failure | Verify entailment |
| Citation granularity | Cite precision | doc / page / span | Verification ease | format | Span for high-stakes |
| Strictness | Grounding rigor | Strict↔lenient | Match use case | policy | Set 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
| Misconception | Reality |
|---|---|
| "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 case | Strictness / approach |
|---|---|
| Legal / medical / compliance | Strict: span citations, verify every claim, refuse |
| Customer support | Moderate: cite source/page, verify, allow "contact us" |
| Internal search / brainstorm | Lenient: ground + cite, allow synthesis |
| High-stakes automation | Strict + 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
- Grounded generation: use the §2 grounding system prompt; generate answers with
[N]citations for the labeled questions. - 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.
- 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.
- 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). - Faithfulness score: compute a simple faithfulness rate (supported claims / total claims) across the set, and compare strong vs weak prompt (09).
- 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
- What's the difference between grounding/faithfulness and citation?
- Why is "I don't know" a feature, not a failure?
- 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
- Ground (answer only from context) + cite (point each claim to its source) + refuse (when absent) — this makes RAG trustworthy.
- RAG alone doesn't stop hallucination — it takes a strong grounding prompt, good retrieval, and verification.
- Faithfulness ≠ citation — require both; verify citations (IDs + entailment), don't trust them.
- Reward appropriate refusal; choose citation granularity (span best for high-stakes) and strictness by domain.
- 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