Generate answers grounded in sources
Give the model clear instructions and make evidence visible in its response.
- Design a prompt that encourages evidence-based answers and useful abstention.
A RAG prompt should distinguish the user question from retrieved source text, ask the model to rely on that evidence, and define what to do when evidence is insufficient. Return citations tied to the retrieved chunks so people can inspect the basis for claims. A citation is useful only if it points to the passage that supports the claim.
A small example
1question = "What is the return window?"
2context = "Returns are accepted within 30 days. [policy#returns]"
3answer = "Returns are accepted within 30 days. [policy#returns]"
4print(answer)Returns are accepted within 30 days. [policy#returns]
Treat retrieved text as data, not as trusted instructions. Ask for a concise response with citations, and allow “I could not find that in the sources” when the evidence does not support an answer. Grounding reduces unsupported claims but does not eliminate them, so check citations and answers.
Key takeaways
Design a prompt that encourages evidence-based answers and useful abstention.
Check that retrieved evidence is relevant, current, and allowed for this user.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…