Interview Q&A / AI & Generative AI

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How do you make a RAG system cite its sources?

SHORT ANSWER

Store a source id with every chunk, pass the chunks to the model with labels, and instruct it to cite the labels it used. Then check in code that each cited id was actually retrieved and ideally that the claim is supported by that chunk.

Explain it simply

In an exam, "as per page 42 of the textbook" is more trustworthy than a bare claim. Users trust RAG answers more when they can click through and check.

The mechanics are simple. Each chunk is stored with metadata: document title, page, URL. When building the prompt, label the chunks like [1], [2], [3]. Tell the model to answer only from those chunks and to put the matching label after each statement, or to say that the answer is not found.

Then verify, because models can invent citation numbers or attach a real one to an unsupported claim. In code, reject ids that were never retrieved. For higher assurance, run a check that each cited chunk really supports the sentence. Show the user the source title and link, not just a number.

Example

text
Context:
[1] HR Policy p.4: "Casual leave: 8 days per year."
[2] HR Policy p.9: "Leave must be applied 2 days ahead."

Answer: You get 8 casual leaves a year [1] and should apply 2 days in advance [2].

What to say in the interview

"I attach source metadata to chunks, label them in the prompt, require per-claim citations, and validate that cited ids exist and support the claim. Citations make answers auditable but only help if checked."

Common mistakes

  • Trusting citation numbers produced by the model without checking.

#rag#citations#grounding

Related questions

Practise more AI & Generative AI questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open AI & Generative AI quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.