Lesson 19 / 29
Grounding With Retrieved Documents
Supply facts from search instead of relying on model memory.
Give it the source
For factual or company-specific answers, retrieve relevant passages (search or RAG) and place them in the prompt with numbered IDs. Instruct: "Answer only from the context. Cite the ID for each claim. If the context does not contain the answer, say so." This reduces hallucination, supports citations and keeps knowledge up to date without retraining. Keep only the few most relevant passages, since extra text adds cost and distraction, and treat the retrieved text as data, not instructions.
A grounded prompt
Numbered passages let the model cite. Illustrative; not run here.
Answer ONLY from the passages. Cite like [1]. If not answerable, reply "Not in the documents."
[1] Employees get 24 days of paid leave per year.
[2] Unused leave up to 5 days can be carried over.
Question: How many days can I carry over?
Answer:Retrieve fewer, better passages
Three highly relevant passages usually beat ten loosely related ones, which add cost and distraction.
Quick check: Why tell the model to say so when the context lacks the answer?
- To change the language
- To lengthen replies
- To skip retrieval
- To prevent confident guessing
Answer
To prevent confident guessing — An allowed "not found" answer discourages invention.