Skip to main content

Citations: closing the loop

Module 4 · Lesson 4 · 6 min read

TL;DR

Retrieval gives the model the right facts; citations let the user verify them. The model marks each fact with [N] pointing at the chunk it used, and the UI turns those markers into clickable pills that open the exact source text. Citations are how "the agent said so" becomes "here's the paragraph it pulled it from."

Why citations matter

A grounded answer is only trustworthy if you can check it. RAG already put the real chunks in the prompt (retrieve → augment); citations complete the loop by letting the reader trace each claim back to its source. Without them, a RAG answer looks exactly like a confident hallucination — you have no way to tell them apart.

How the [N] markers work

It's a small contract, end to end:

  1. The numbered context. Retrieved chunks enter the prompt as a numbered block ([1], [2], … from the top-K lesson).
  2. The model cites. We instruct it to mark each fact with the chunk it used — [1] for one, [1,2] for several.
  3. The API parses the markers out of the answer text before returning it.
  4. The UI renders pills. Each [N] becomes a clickable pill; clicking opens a drawer with the chunk's text, its source filename, and the similarity score that put it in front of the model.

Each [N] in the answer maps back to the numbered chunk it came from, so the reader can open the exact source.

Try it

That click-through is the whole point: it's the difference between "the agent said so" and "the agent said so, and here's the paragraph in the handbook it pulled the answer from." Once you ship the M4 lab, your real billing handbook becomes that kind of checkable source.

Common mistake

Trusting that a citation exists means the answer is grounded. A [2] that opens a chunk about an unrelated topic is a red flag — the model cited a chunk it didn't actually use, or retrieval surfaced the wrong chunk. That's the checkpoint: a mismatched citation means don't trust the answer, and it usually points to a retrieval problem (wrong K, wrong search mode, bad chunking) upstream. Citations don't just build user trust — they're your debugging tool.

Key takeaways

Key takeaways

  • Citations let users verify each fact against its source chunk.
  • The model emits [N] markers; the API parses them; the UI renders clickable pills.
  • A pill opens the chunk text, source file, and similarity score.
  • A citation that doesn't match its claim signals a retrieval bug — and a distrust-worthy answer.
Go deeper: citations as an evaluation signal

Citations aren't only a UI nicety — they're a measurable quality signal you'll lean on in the Evals module (M7):

  • Groundedness / faithfulness. Does every claim trace to a retrieved chunk that actually supports it? A judge (human or LLM) can check answer-vs-cited-chunk and score how faithful the answer is to its sources.
  • Citation precision and recall. Did the model cite chunks it did use (precision) and cite all the chunks it used (recall)? Both are checkable because the markers are structured.
  • Catching silent retrieval failures. An answer with no citations, or citations to low-similarity chunks, flags that retrieval probably missed — even when the prose sounds confident.

Because the [N] markers are machine-readable, you can automate these checks across a whole eval dataset rather than spot-reading answers. Grounding you can measure is grounding you can improve — which is exactly what M7 is about.

Build this in AI Fluens Studio

Reading is step one. Open Studio and build a working agent end-to-end — every concept in this course is something you ship and run for real.

Open AI Fluens Studio