Citations in RAG answers: how to make every sentence traceable to a source

Pranjul Rathour
Pranjul Rathour

Originally published at https://pranjulrathour.scult.in/blog/citations-in-rag-answers. That copy is the canonical version and gets updates first.

An answer without a source is an opinion with good grammar. The reason RAG.NextUpgrad streams citation-grounded answers is not decoration; it is what lets a user check the system in ten seconds instead of trusting it blindly. Citations are the difference between a demo and a tool people rely on.

Give every chunk a stable identity

At ingest, assign each chunk an identifier that encodes document, page and position. The prompt presents chunks with these identifiers, and the model is instructed to reference them inline. Because the identifiers are yours, you can resolve a marker back to a document title, a page number and the exact passage — and render it as a clickable citation.

Pranjul Rathour, GenAI engineer, Kanpur
Pranjul Rathour, GenAI engineer, Kanpur

Inline markers beat a footer list

A list of sources at the bottom tells the reader something was used, not what. Sentence-level markers — "the limit is five requests per second [2]" — attach each claim to its evidence. The OCR & Speech Workspace uses page-level citations for scanned books, which is what makes a 400-page PDF usable: the reader jumps to page 214 rather than searching.

Verify the citations, not just the answer

  1. Check that every marker resolves to a chunk that was actually in the prompt. Models occasionally invent [7] when only five chunks existed.
  2. Check that the cited chunk supports the sentence it is attached to — an entailment pass, by rubric or by a judge model.
  3. Strip any sentence that has no supporting chunk, or flag it visibly. Silent unsupported sentences are how trust erodes.

Streaming and citations together

Streaming complicates citations because markers arrive mid-sentence. The pattern that works: stream the text as it comes, resolve markers client-side against a citation map sent before the first token, and render the source panel progressively. Users get speed and traceability at once.

In a packed college auditorium
In a packed college auditorium

If you are building a RAG project for a portfolio, citations are the feature that makes a reviewer lean forward. They show you understand that the model is a writer, and the documents are the authority.

From my carousels
7 Levels of RAG Apps
7 Levels of RAG Apps, slide 17 Levels of RAG Apps, slide 2
7 Levels of RAG Apps, slide 37 Levels of RAG Apps, slide 4
Full carousel on Instagram and LinkedIn.
Pranjul Rathour
Pranjul Rathour
GenAI engineer, Kanpur · 3x first-prize hackathon winner · campus mentor
I ship production RAG pipelines, fine-tune LLMs and build agentic AI products end to end. I lead engineering at SCULT INDIA for a 14-member team and have mentored 200+ students through TechVerse Enclave.
Open to: GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges.
On stage, at hackathons and on campus
Pranjul Rathour
Pranjul Rathour
On the mic
On the mic
Presenting to a room
Presenting to a room

Comments

Popular posts from this blog

Forming a hackathon team: roles, skills and the mistake most teams make

Hello from Kanpur: what I build, and what I'll write about here

I built 15 free tools, 1,211 prompts and a 50,000-skill library — here's what's inside tools.scult.in