Skip to main content

Pattern · Retrieval and RAG

Grounded answers with citations

Make the model answer only from given passages, cite them by id, and refuse when they do not cover the question.

Say it in the interview

I would number the passages, require the answer to cite ids, and check in code that each cited id exists and quoted words appear in it. When the passages do not cover the question, it says so and points to a person or page.

When to use it

  • Answers people act on: policy, legal, medical, finance
  • Users must be able to verify

How it works

  1. Retrieved passages [1]..[5] → Prompt: use only these, cite ids, refuse if not covered
  2. Prompt: use only these, cite ids, refuse if not covered → Answer with [ids]
  3. Answer with [ids] → Checks (ids exist, quotes match, claims supported)

Trade-offs

  • Trust: every claim points to a page
  • More refusals, which users may dislike at first
  • Citation checks add a little latency

Pitfalls interviewers probe

  • Citations the model invents
  • Refusing with no next step for the user

Practise it on these questions

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.