Attribution and Citation: Sourcing LLM Outputs › Attribution in RAG Systems

Michael BrenndoerferFebruary 16, 20263 min read
Language AI HandbookAll chapters
Part 56 of 67Hallucination and Factuality
Chapter 433Attribution and Citation: Sourcing LLM Outputs › Attribution in RAG Systems
Reading section 4 of 16 · Attribution in RAG Systems · 3 minSection 4 of 16 · 3 min

Book contents

Section 4 of 16 · 3 min read

Attribution and Citation: Sourcing LLM Outputs › Attribution in RAG SystemsOne section · Sections in this chapter4 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The most common practical setting for attribution is retrieval-augmented generation. As we saw in earlier chapters, RAG systems retrieve relevant documents from a corpus before generating a response, giving the model access to external knowledge that can ground its outputs. Attribution in RAG is the additional requirement that the model indicate which retrieved passages support which parts of its output.

A RAG-with-attribution pipeline has several interconnected stages, each of which affects the quality of the final attribution.

The retrieval stage fetches candidate documents or passages from a knowledge base using a query. This is typically done with a dense retriever like a bi-encoder, a sparse retriever like BM25, or a hybrid of both. The quality of attribution is bounded by the quality of retrieval: if the most relevant passages are not retrieved, the model cannot attribute its claims to them, even if those claims happen to be correct.

The prompt construction stage inserts the retrieved passages into the model's context, usually in a structured format. A common pattern labels each passage with a numeric identifier:

[1] <passage from document A> [2] <passage from document B> [3] <passage from document C> Based on the above passages, answer the following question and cite your sources: ...

The way passages are formatted, ordered, and labeled matters more than it might seem. Models are sensitive to position: passages presented earlier in the context receive more attention and are more likely to be cited. Numbering schemes and delimiters affect how reliably the model refers back to specific passages. Prompt engineering for attribution is an active area of practical development, with significant variation in citation quality across different formatting conventions.

The generation stage produces a response. A well-instructed model should produce text that cites the relevant passage numbers inline, like "According to [2], the population of Brazil reached 215 million in 2022." The instruction-following quality of the model, the length and complexity of the passages, and the difficulty of the query all affect how well the model maintains attribution discipline across the full length of its response.

The attribution verification stage checks whether the citations in the generated text are supported by the cited passages. This is the evaluation step, and it is logically separate from generation. Even a model that produces citations for every claim may produce incorrect ones, and the verification stage catches these errors. For production systems, attribution verification can be done automatically using NLI-based methods and used to trigger re-generation, response filtering, or user warnings when citation quality falls below a threshold.

This pipeline architecture reveals an important design choice. Attribution can be built as a property of the generation model (the model learns to cite during fine-tuning) or as a property of the pipeline (a separate component adds and verifies citations post-generation). The former tends to produce better integrated attribution; the latter is more modular and easier to update independently.