Assembling the prompt
Structure it as [system instructions + grounding rules] → [retrieved chunks, clearly delimited and labeled with source IDs] → [user question]. Distinguish the retrieved context from the question so the model knows what it's allowed to cite.
Grounding: the instruction layer
The primary lever against hallucination is an explicit instruction: "Answer only from the provided context. If the context doesn't contain the answer, say you don't know." Pair it with an abstention path — when retrieval returns nothing above a relevance threshold, the system should refuse or ask a clarifying question, not answer from parametric memory. A system that always answers will confidently hallucinate on out-of-corpus queries.
Citations
Require a source ID for each claim (e.g. [doc_3]). Best-in-class is provider-native citation (Anthropic Citations API, OpenAI file-search annotations) that returns verifiable spans — because free-text citations the model writes itself can be fabricated.
Lost in the Middle
A key result (Liu et al., 2023): LLM accuracy is highest when the relevant info is at the beginning or end of the context and degrades in the middle — a U-shaped curve that worsens as context grows. Practical rule: place the most relevant chunks first and last, not buried in the middle. Reranking helps by keeping the set small and ordered by relevance.
The signature failure: parametric override
Even with the correct chunks in the prompt, models sometimes answer from pre-trained memory — producing outdated or wrong answers that look grounded. Causes: weak instructions, key context buried in the middle, retrieved text conflicting with strong priors, or too much noise.
Mitigations: (1) a strong "use only the context" instruction plus an abstention clause; (2) put key chunks first/last; (3) fewer, higher-precision chunks (rerank) to reduce distraction — more context is not always better; (4) require inline citations so unsupported claims become visible; (5) a faithfulness verification pass that flags claims not entailed by the context (see Chapter 5).