recallA retrieval
field guide

Citations and Grounded Answers

Build this skill

Produce passage- and quote-level citations and check them automatically after generation.

Show your sources

When a student reads "You can take up to 10 days of medical leave", should she believe it? If the answer ends with "[1] Academic Regulations 2026, Section 4, page 11", she can check it in seconds. A citation is a pointer from a statement in the answer to the source that supports it. Citations are one of the main advantages of RAG over a model answering from memory, and they serve three groups of people.

  • Users can verify an answer before acting on it, which matters for fees, deadlines and rules.
  • Owners of the knowledge base can see which documents are actually being used, and which ones produce wrong answers.
  • Developers can check automatically whether each claim is supported, which is the basis of most evaluation of RAG answers.

Levels of citation

Citations can be more or less precise:

Level Example Strength
Document "Source: Academic Regulations 2026" Easy, but the reader must search a 42-page PDF
Passage "[1] Regulations 2026, §4, p. 11" Points to the exact chunk; the common choice
Quote "[1] “More than 10 days needs approval from the Dean of Academics.”" Shows the exact supporting words; easiest to verify

Passage-level citations are the usual default. Quote-level citations are valuable where mistakes are costly, such as legal, medical or financial answers, because they make it obvious whether the source really says what the answer claims.

How citations are produced

The usual method is simple: number the sources in the prompt, and instruct the model to put the number of the supporting source after each claim. Because the system knows which document, section and page each number refers to, it can turn "[1]" into a clickable link to the exact place in the original document.

Number thesources[1] §4 p.11,[2] §4 p.12Ask forcitations“cite as [n]”Model writesclaims + [n]Checkevery [n]exists andsupportsRender links[1] → page 11

The system, not the model, owns the mapping from citation numbers to real documents.

Some systems ask the model for structured output instead of free text: for example, a list of sentences, each with the IDs of its sources and an exact supporting quote. Structured output is easier to check automatically and to display neatly.

Citations can be wrong too

A citation is only useful if it is correct. Models make several kinds of citation mistakes:

  • citing a source that does not exist (for example "[4]" when only three were given);
  • citing a real source that does not actually support the claim;
  • giving a claim no citation at all;
  • citing correctly but stating the fact wrongly, such as writing "12 days" while citing a source that says 10.

So a good system checks citations after generation. The simplest checks are mechanical: every number refers to a real source, and every sentence has at least one. Deeper checks compare each claim with its cited passage, either by looking for the key words and numbers, or by asking a second model whether the passage supports the claim.

The program below performs the mechanical checks and a simple number check on an answer.

python · runs in your browser

Expected output:

text
NUMBER MISMATCH : You can take up to 12 days of medical leave in a semester [1].
OK              : Anything beyond that needs the Dean of Academics [2].
UNKNOWN SOURCE  : You must also pay a processing fee of Rs 200 [3].
NO CITATION     : Leave is counted towards attendance.
Line What it does
re.split(r"(?<=\.)\s+", ...) Splits the answer into sentences, so each claim is checked separately.
re.findall(r"\[(\d+)\]", sentence) Pulls out the citation numbers, such as the 1 in [1].
missing = [n for n in cited if n not in sources] Catches a citation to a source that was never provided.
bad = [x for x in numbers if x not in cited_text] Catches a number in the claim that does not appear in the cited passage.

Four sentences, four different outcomes: a wrong number that the citation exposes, a correctly supported claim, a citation to a source that was never given, and a claim with no citation at all.

Practise checking an answer

Below, an assistant answered a question about hostel rules using two retrieved passages. Click every sentence whose citation does not actually support it.

A cited answer that cannot be verified is worse than an uncited one, because it looks trustworthy. Checking citations, and showing users the exact passage behind each one, is what makes grounded answers genuinely trustworthy.

Follow your curiosity.

↑ ↓ to explore · Enter to open · Escape to close