RAG & Retrieval·Question 28 of 100Intermediate

How do you make a RAG system produce trustworthy citations?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Citations are a chain of custody: every claim in the answer should trace to a retrieved chunk the user can inspect. Getting them trustworthy takes work at three layers.

Full worked answer

Citations are a chain of custody: every claim in the answer should trace to a retrieved chunk the user can inspect. Getting them trustworthy takes work at three layers.

Prompt/format layer: assign each retrieved chunk a stable ID and require inline markers - "Answer using only the provided sources; after each claim, cite like [1][3]". Structure the context so chunk boundaries and IDs are unambiguous (XML-ish tags work well). Instruct the model to say "I don't know" when sources don't cover the question - and test that it actually does, because models default to helpfulness over honesty.

Verification layer - the step that separates production systems from demos, because models fabricate citations (citing [7] when 5 chunks were provided) and mis-cite (real claim, wrong source): (a) mechanically validate that every cited ID exists in the provided set - free; (b) check attribution - does the cited chunk actually support the sentence? Options range from cheap (string/spans overlap heuristics) to standard (an NLI or small-LLM entailment check per claim-citation pair) to strict (drop or flag unsupported sentences). Anthropic's Citations API is worth naming: the model emits answers with spans mechanically tied to provided source extracts, moving attribution from prompt-hoping into the decoding/API contract.

UX layer: citations must resolve to something inspectable - deep-link to the exact page/section, show the quoted span on hover. A citation to "document.pdf" is theatre; a highlighted paragraph builds actual trust. This also creates your feedback loop: users clicking citations and reporting mismatches is free evaluation data.

Design details that bite: cite at the chunk or span level, not document level (attribution precision is the point); handle multi-source claims; and decide policy for unsupported-but-true parametric knowledge - most enterprise deployments choose "if you can't cite it, don't say it," accepting lower answer coverage for auditability. Measure with citation precision (cited chunk supports the claim) and citation recall (claims that have citations) on your golden set.

What a good answer covers

  • Citations are a chain of custody
  • Getting them trustworthy takes work at three layers
  • Prompt/format layer: assign each retrieved chunk a stable ID and require inline markers - "Answer using…
  • Structure the context so chunk boundaries and IDs are unambiguous (XML-ish tags work well)
  • Instruct the model to say "I don't know" when sources don't cover the question - and test that it…

Key terms: Prompt/format layer · Verification layer · UX layer · chunk or span level

Interviewer follow-ups to expect

  1. How do you catch a correct claim with the wrong citation attached?

  2. What's the latency/cost of per-claim entailment checking and how would you reduce it?

  3. Would you ever let the model answer from parametric knowledge without a citation?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep