Intermediate

RAG and Knowledge Grounding

Retrieval-Augmented Generation is the most powerful architectural intervention against hallucination: it shifts the model from trying to recall facts to reading and citing facts. This lesson explains how it works, where it still fails, and how to measure faithfulness.

✍️ AI School Editorial Team · Lilly Tech Systems 📅 Published Jul 23, 2026 · Reviewed Jul 23, 2026

Why RAG Reduces Hallucination

From Lesson 3: hallucination often occurs because the model does not have the correct fact in its parametric knowledge, so it generates a plausible-sounding token sequence instead. RAG addresses this at the root: rather than asking the model to recall a fact from training, it supplies the fact directly in the context window, then asks the model to read and synthesize what it was given.

This shifts the problem from "recall from uncertain training memory" to "read and faithfully report from a document you have in front of you." The latter is a task LLMs perform far more reliably than the former.

Task structureHallucination sourceRAG effect
Open-domain Q&A (no RAG)Model recall from training dataN/A
Closed-domain Q&A with RAGFaithfulness to retrieved chunkShifts problem; reduces factual hallucination significantly
Reasoning tasksLogic errorsMinimal effect; reasoning hallucination is not a retrieval problem
💡
RAG is not a complete hallucination solution. It addresses hallucination caused by missing parametric knowledge, but not hallucination caused by reasoning errors, calibration failures, or the model drifting from the retrieved content. Combine RAG with the prompting techniques from Lesson 5 and the monitoring from Lesson 7.

The Retrieval-Faithfulness Tension

Even with retrieved context in the window, models can still hallucinate. This is the retrieval-faithfulness problem: the model was supplied with the correct information but generated output that does not faithfully represent it. This happens for several reasons:

  • Lost-in-the-middle effect: If the relevant chunk is buried in the middle of a long context, the model may under-attend to it. (See Lesson 3.)
  • Parametric override: When the retrieved document conflicts with what the model "knows" from training, the model sometimes favors its parametric knowledge over the context. This is more common when the document says something surprising or counter-intuitive.
  • Synthesis errors: When asked to synthesize across multiple retrieved chunks, models may blend or confuse information from different chunks, producing a hallucinated synthesis.
  • Incomplete retrieval: If the retrieval step does not surface the right chunk, the model answers without the needed fact, and may hallucinate to fill the gap rather than acknowledging the limit.

Chunking Strategies for Faithfulness

The way you split documents into chunks has a direct effect on hallucination rate in RAG systems. Poorly chunked documents create retrieval gaps and synthesis problems.

  1. Semantic chunking over fixed-size chunking. Splitting at sentence or paragraph boundaries preserves context that fixed-character splits break. A fact that is spread across two 512-character chunks will not be retrieved as a unit; split at the boundary of the relevant fact, not at a character count.
  2. Overlap windows. Adding a 10-20% overlap between adjacent chunks ensures that facts near chunk boundaries appear in at least one complete chunk. Without overlap, boundary facts are the most likely to be missed by retrieval.
  3. Hierarchical chunking. For long documents, maintain both a document-level summary chunk and paragraph-level detail chunks. Use the summary for relevance routing, the detail chunks for faithful answer generation.
  4. Metadata tagging. Add source document name, section header, and page number to each chunk. Require the model to cite chunk metadata in its answer. This makes faithfulness auditable.

Citation-Forcing Patterns

The strongest RAG anti-hallucination prompt pattern is citation forcing: require the model to cite the specific chunk that supports each claim in its answer. Uncited claims are flagged as potentially hallucinated.

📚
Citation-forcing system prompt:
"You will be given retrieved document chunks labeled [Source 1], [Source 2], etc. Answer the user's question using only information from these chunks. For every claim you make, cite the source in brackets immediately after the claim, e.g. 'The effective date is January 1, 2026 [Source 2].' If no source supports a claim, do not make it. If the sources do not contain enough information to answer the question, say so explicitly."

This pattern achieves three things: it forces attribution, it creates an auditable output, and it gives the model a clear instruction for what to do when it lacks information.

Faithfulness Evaluation Metrics

Faithfulness evaluation measures how well the model's output is supported by the retrieved context. The field has converged on a set of metrics for this assessment:

MetricWhat it measuresHow to compute
FaithfulnessFraction of claims in the answer that are supported by the retrieved contextDecompose answer into claims; check each against context (manually or with LLM-as-judge)
Answer relevanceWhether the answer addresses the question (not accuracy, just relevance)LLM-as-judge: "Does this answer the question?"
Context recallWhether the retrieved chunks contain the information needed to answerCompare answer to known reference; check if supporting facts were in retrieved chunks
Context precisionHow much of the retrieved context was relevant (not noise)Fraction of retrieved chunks that contributed to the answer
Faithfulness is the most direct hallucination metric for RAG. Start there. A faithfulness score below 0.8 (i.e., more than 20% of claims not supported by context) indicates a RAG system that is still generating significant hallucination despite retrieval. The most common fixes: improve chunking, add citation-forcing to the prompt, and use a grounding prompt from Lesson 5.

When RAG Still Does Not Help

RAG is not a universal solution. Three categories of hallucination are largely unaffected by retrieval:

  • Reasoning hallucinations: RAG provides facts, not reasoning. If the model makes a logical error with the correctly-retrieved facts, RAG cannot prevent it. Use chain-of-thought prompting (Lesson 5) for reasoning tasks.
  • Synthesis hallucinations: When the answer requires combining information from many chunks, the synthesis step itself can introduce errors. Keep synthesis tasks narrow: fewer sources, more focused questions.
  • Out-of-distribution queries: If the user's question is not well-served by any retrieved chunk, the model may answer from parametric memory rather than acknowledging the retrieval gap. Add explicit "no relevant information found" handling to your RAG pipeline.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.