Citations
Ground answers in retrieved spans with verifiable quotes and source links.
In plain words
The answer says which document each fact came from, so you can click and see it for yourself.
Think of it like…
Footnotes in a research paper: each statement points to a source you can open. A paper with footnotes that don't say what's claimed is more misleading than one with no footnotes, so a good editor checks them.
Where you’ve seen it
A policy Q&A tool gives each retrieved chunk an id (D14-p3, D22-p1…) and instructs: "Answer using only the sources. After each sentence add [id]. Include the exact supporting quote." A post-processor checks that every cited id was in the prompt, that each quote appears verbatim in that chunk, and runs a small entailment check that the sentence is supported. Answers failing checks are regenerated or returned with a warning; unsupported-claim rate on review data drops from 11 to 3 percent.
Words you’ll hear
- Inline citation
- A marker such as [D14-p3] attached to the sentence it supports.
- Span grounding
- Pointing to the exact quote or character range that supports a claim.
- Citation precision / recall
- Share of cited sources that truly support the claim / share of claims that are cited.
- Entailment check
- Verifying that the cited text logically supports the sentence.
Visual diagram
Theory & deep dive
How to get reliable citations
Give each retrieved chunk a short stable id plus metadata (title, URL, page, section, version) in the prompt, instruct the model to answer only from the sources, and return structured output such as {"claims": [{"text": ..., "source_id": ..., "quote": ...}]}. Requiring a verbatim quote makes verification mechanical: check that the quote is a substring of the cited chunk, and the id was actually in the prompt. Some providers offer native citation features where the API returns spans or document indexes alongside the text, which tends to be more reliable than free-text markers.
Granularity matters: cite per sentence or per claim, not once at the end, and allow multiple sources per claim. Provide an explicit "not found" path, because models forced to cite will sometimes cite something irrelevant. Keep the answer formatting simple enough that citation parsing doesn't break (consistent markers, no citations inside code blocks).
{"answer": [{"text": "Contractors are not eligible for paid parental leave.", "sources": [{"id": "D14-p3", "quote": "Parental leave applies to full-time employees only."}]}]} The quote can be checked against chunk D14-p3 with a substring match.
Verifying support and presenting sources
Three checks, from cheap to costly. Existence: the cited id was in the prompt. Quote match: the quoted text appears (after whitespace normalisation) in that chunk. Support: the sentence is entailed by the quote or chunk, tested with an NLI model or a small LLM judge. Failed claims can be dropped, regenerated with feedback, or shown with a warning. Measure citation precision (cited sources that truly support the claim) and recall (claims that have a supporting citation) on labelled samples, since a high citation rate with low precision is dangerous.
In the UI, link each citation to the source document at the right page and highlight the quoted span; show document title, date and version so users can judge currency; and make "view all sources" easy. Keep stable links: version documents, and if a source is deleted or changed, mark the citation stale. Remember permissions: citations must only reference documents the user may access. For long answers, grouping citations by paragraph with expandable evidence keeps the reading experience clean.
On 200 answers with 1,100 claims: 96% of claims have a citation (recall), but only 88% of citations actually support the claim (precision). The 12% gap is where the verifier and prompt changes should focus.
How it works, step by step
Step 1 of 41. Label chunks with stable ids
Number each retrieved chunk and include title, page, section and version metadata.
- Ids
- short and stable
When to use it & trade-offs
What it is
Citations in a RAG answer tie each claim to the retrieved passage that supports it, as a source link, a document and page, or a verbatim quote, so users can check the answer and so your system can verify it automatically. Approaches: ask the model to cite chunk ids inline, to quote spans from the context, or use native citation features offered by some providers. The key engineering step is verifying that each citation exists and genuinely supports the claim, because models can cite confidently and wrongly.
Why it matters: Citations turn a plausible paragraph into something auditable. In legal, medical, finance and enterprise settings, users won't trust an answer they can't check, and reviewers need to trace errors to a source. Citations also reduce hallucination by forcing the model to anchor on retrieved text, and give you a measurable quality signal (citation precision and recall). But a fake or irrelevant citation is worse than none, since it adds false credibility.
When to reach for it
- Policy, legal and medical-adjacent assistants
- Research and analyst tools
- Any answer a user may need to verify
When to avoid or be careful
- Citations that were never verified
- One source list for a whole answer
- Linking to unversioned documents that can change
Ways to cite sources
Strengths: Mechanically verifiable; precise.
Watch out: Longer outputs; needs structured parsing.
Strengths: API returns spans; less parsing risk.
Watch out: Provider-specific; limited control.
Strengths: Simple.
Watch out: Doesn't show which claim came from which source.
Interview signals & numbers to know
When this topic comes up
- “How do we make answers trustworthy?”
- “The model cited a source that doesn't say that”
- “How would you measure citation quality?”
- Span grounding
- Audit trails
Benchmarks & rules of thumb
- 88% vs 96%
- citation precision vs recall in the example
- 11% → 3%
- unsupported-claim rate after verification
- 3 checks
- existence, quote match, support
Common mistakes & follow-ups
Common interview mistakes
- Trusting any [id] the model emits, including ids that were never in the prompt.
- Showing a citation link to a document the user isn't permitted to open.
- Accepting paraphrased quotes that can't be string-matched, so verification is impossible.
Likely interviewer follow-ups
- How would you verify that a citation supports a claim?
- What is citation precision and recall?
- How should citations be shown in the UI?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Citations with generative AI interview Q&A and hands-on practice.