Loading
0x40Lesson 5 of 6

Generate answers grounded in sources

Give the model clear instructions and make evidence visible in its response.

12 min 5-question quiz
By the end of this lesson you can
  • 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

Illustrative Python
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)
Output
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…

Did you like the lesson? 😆👍
Consider a donation to support our work: