Enterprise knowledge · Research feature

Study Reveals How LLMs Decide to Cite Sources in RAG Systems

Researchers identify a distributed network of model components that drive citation decisions in retrieval-augmented generation systems using Llama-3.1-8B-Instruct.

Adapted from research by Ian van Dort, Maria Heuss.

arXiv preprint revision · 2026-09-19 · Attribution & reuse
In this article
Editorial illustration of stacked plates.

Editor’s introduction

The study examines how the Llama-3.1-8B-Instruct model determines whether to include inline citations when answering factoid questions. Using activation patching on the PopQA dataset, researchers found that citation behavior arises from a distributed ‘attributional ensemble’ across multiple attention heads and MLP layers, not a single dedicated module. This ensemble relies on shallow heuristics, such as entity co-reference matching, to evaluate source relevance. The findings show that selectively amplifying or attenuating specific components improves citation accuracy—correcting over 90% of missed citations and eliminating 69% of spurious ones—without affecting answer quality. The results suggest a disconnect between the model’s citation output and its internal reasoning process, indicating that citations may not reliably reflect actual source use. Evidence from the HotpotQA benchmark shows modest gains, but the same components influence citation behavior across datasets, implying the mechanism is broadly applicable.

Introduction

Large Language Models (LLMs) are increasingly deployed in high-stakes domains, from medical question answering to legal research and educational tools. These systems promise to democratize access to specialized knowledge that was previously available only to experts or those with substantial resources. However, LLMs are prone to “hallucinations”: plausible but factually incorrect outputs. When a lawyer relies on a fabricated case citation or a clinician acts on incorrect medical information, the consequences can be severe.

Retrieval-Augmented Generation (RAG) addresses this by grounding model outputs in external documents and providing citations. The appeal is straightforward: users can verify claims against sources. Yet this verification promise matters most for communities that rely on AI as a primary information source but lack expertise to independently assess the underlying documents. If citations are merely cosmetic—appended after the fact rather than genuinely driving the answer—then RAG systems risk creating a false sense of security that could deepen information disparities rather than close them.

The problem is that citation correctness (does the source factually support the claim?) does not guarantee citation faithfulness (did the model actually use the source to generate the claim?). Consider a medical RAG system asked about drug interactions. If the model recalls the answer from training data and then attaches a citation to a document that happens to confirm it, the citation is correct but unfaithful. Worse, research shows that explanations, even misleading ones, increase user trust in AI outputs. In dense, technical domains where users cannot easily verify sources themselves, unfaithful citations lend misinformation an air of credibility.

Citation Faithfulness as a Property of Trustworthy Attribution. We define citation faithfulness as a citation occurring only when the model’s internal computation genuinely used the cited document to construct the answer. The challenge is that faithfulness is not observable from input-output behavior alone. A model can produce identical text whether it retrieved information from a document or hallucinated from memory. To assess faithfulness, we must look inside the model.

Towards Understanding Citations with Mechanistic Interpretability. This paper uses mechanistic interpretability to reverse-engineer how Llama-3.1-8B-Instruct decides whether to emit an inline citation in a RAG context. Instead of treating the model as a black box, we use activation patching to identify which internal components (specific attention heads and MLP layers) influence citation behavior. We then test whether these components can be manipulated: inducing citations and suppressing spurious ones.

Why does this matter? If citations are generated by shallow heuristics (e.g., matching entity names between document and question) rather than through genuine engagement with document content during answer construction, then current RAG systems offer only an illusion of verifiability. Understanding the mechanism is the first step toward building evaluation frameworks that can distinguish faithful from unfaithful attribution—critical for deploying AI systems that communities with limited technical resources can actually trust.

Large language models (LLMs) often “hallucinate”, producing factually incorrect information. To attempt to overcome these issues, RAG helps LLMs by retrieving relevant documents from external knowledge bases, and using those documents to draft better outputs. It does this by coupling a retriever, which identifies relevant documents or data, with a generator, typically an LLM, to produce outputs grounded in external knowledge, often providing inline citations to enhance verifiability and user trust. This approach can enhance the accuracy and credibility of the generated output, especially for tasks which require extensive up-to-date or domain-specific knowledge. However, the presence of a citation does not guarantee trustworthiness. A critical, unverified assumption is that these citations are faithful: that is, the cited document had a genuine causal influence on the generation of the corresponding statement. A model might generate an answer from its parametric memory and append a citation that is merely plausible or correct, but not causally responsible, creating a misleading facade of credibility. This distinction is vital in high-stakes domains like law and medicine, where unfaithful citations could lead to misplaced trust in incorrect information. In this work we build on the definition of citation faithfulness from, but take a step towards approaching the problem by understanding how the model generates citations.

External, Output-Based Methods

The most common approach uses external models to evaluate the relationship between the generated text and the source after generation is complete. These methods often frame the task as Natural Language Inference (NLI), checking if the source text (premise) entails the generated claim (hypothesis). While useful for measuring citation correctness, these post-hoc methods cannot assess faithfulness, as they have no access to the model’s internal generation process. They answer “Could this source support the claim?” not “Did this source cause the claim?”.

Generation-Integrated Self-Citation

To streamline attribution, models can be prompted or fine-tuned to generate citations inline with the answer. This approach is used by many state-of-the-art RAG systems and is the focus of our investigation. While this integrates attribution into the generation process, it does not guarantee faithfulness. As prior work on self-explanations has shown, a model’s stated rationale for its output does not necessarily align with its true computational process.

Mechanistic and Perturbation-Based Methods

A smaller body of work has sought to establish a more causal link between source and output by analyzing model internals. Techniques like gradient-based saliency, Jensen-Shannon Divergence, hidden-state analysis and perturbation analyses identify which parts of the context most influence the final output. These methods offer a stronger claim to faithfulness but are often computationally expensive, require full model access, rely on coarse sentence-level ablations that can miss nuanced influences, and have not yet been used to map the full, end-to-end mechanism of how a citation decision is made.

Methodology

We designed a minimal, controlled experimental pipeline to study when and why a RAG-style model emits inline citations. To avoid confounds from a full retrieval stack, each example is run twice with the same prompt: once with a relevant supporting document and once with an irrelevant (distractor) document. Comparing these two conditions isolates behaviour driven by the supplied context.

Dataset and model

We base our experiments on a citation-focused adaptation of PopQA. PopQA’s short, single-fact questions and clear answers make automated correctness checks straightforward. For each question we generate (i) a short supporting document that contains the answer and (ii) a distractor document. Distractors were created by randomly sampling structure-matched factual sentences that mirror subject/object token lengths and relation type. This preserves token-level structure, enabling precise component-level comparisons.

Component-level evaluation via activation patching

To locate internal components associated with citation behaviour we perform activation patching between the relevant and distractor runs. Activation patching replaces selected intermediate activations in one run with activations from the other and measures the resulting change in the model’s preference for starting a citation. We operationalise this preference as the logit difference between the citation-initiating token (the token for the character ” [”) and the sentence-final token ”.”.

Results and Discussion

For clarity, we show denoising where it highlights components that positively contribute to citation (clean into corrupted), and we show noising where it highlights components that are necessary (corrupted into clean). In practice both modalities tell a consistent story, though noising typically produces larger-magnitude effects due to the mechanism’s conjunctive dependencies.

Core Structural Pattern: A Distributed Attributional Ensemble

We find that the decision to cite is governed not by a single “citation head” but by a distributed and fragile attributional ensemble of many attention heads and MLPs, where “fragile” means that small corruptions at many sites strongly reduce citation, while single clean patches rarely fully induce it. As shown in Figures 1 and 2, these components’ contributions accumulate across model depth in a process that is easily disrupted (via noising) but difficult to induce (via denoising), consistent with an AND-like dependency structure where multiple conditions must be met.

Late Decision Assembly

The final answer token position aggregates upstream signals, visible as a cluster of effects at the final answer tokens in Figures 1 and 2a. Late-layer MLPs (e.g., layer 16) and selective attention heads (including a decisive late head such as L24H13) increase the logit of the citation marker over a competing termination token (‘.’). Due to the logit-difference metric’s binary framing, we cannot always disambiguate whether components promote citation or suppress sentence termination, an inherent interpretive limitation.

Apparent Reasoning vs. Internal Mechanism

A key finding is the potential disconnect between the model’s output, which may appear to be the result of careful reasoning, and its internal computational pathway. An observer seeing a factually correct answer followed by a citation might assume a logical sequence: the model found the fact in the source, generated the answer from it, and therefore cited it. Our work mechanistically demonstrates that this is not necessarily the case. The citation can be generated by a separate, heuristic-based process that runs in parallel to answer generation. This suggests that LLM outputs can create a misleading narrative of their own reasoning, a critical insight for assessing the reliability of AI systems. A model can generate the appearance of faithfulness while its internal mechanics follow a different logic, a phenomenon also observed in previous work on chain-of-thought reasoning. Auditing the final output is not enough; we must audit the computational pathway that produced it.

RAG and Trustworthy Attribution

The promise of RAG systems, particularly in high-stakes domains, hinges on their ability to provide verifiably grounded answers. Our investigation into the mechanics of inline citation reveals insights into the trustworthiness of this attribution method by examining the model’s internal mechanisms against a strict definition of faithfulness.

Theory of Change

RAG systems promise unprecedented capabilities in making complex information more accessible, through features like simplified language and conversational explanations. Their use in applications of societal decision-making processes, ranging from healthcare and legal systems to education, seemingly enables people that might traditionally have had little access to specialized information, to inform themselves on these topics.

Yet, for AI systems to truly serve all of society, not just privileged groups with technical resources, we must ensure they are trustworthy and contain accurate information. Citations promise a way to decide whether or not to trust the generated information with the possibility to verify it. Yet, unfaithful citations may disproportionately impact communities that rely on AI systems as primary information sources but lack the resources or expertise to independently verify citations. This dynamic could deepen existing information disparities. Moreover, misleading citations can actually enhance user trust in incorrect AI responses, as explanations, even unfaithful ones, tend to increase perceived credibility, creating a concerning form of AI-enabled misinformation that may be particularly difficult to detect and correct.

With this work we aim to take one step towards understanding and evaluating the citation generation in large language model, which we argue is essential for building trustworthy RAG systems. We see this work as a first stepping stone to an understanding of the internal process that leads to generating citations, which we hope will eventually lead to an evaluation framework that helps to identify trustworthy citation behavior.

Future work will need to investigate how mechanistic insights into the model predictions can be used to evaluate citation faithfulness in practice. Critics of mechanistic interpretability note that beyond scientific curiosity, not much practical impact has been derived from insights in the field.Another common criticism of explainable AI, which holds for our work as well is that techniques and findings are often built by, as well as, for engineers, without much consideration for the end user. For our findings to have real world impact, next steps should investigate how the knowledge about the model components that are responsible for generating citations can be used to infer citation faithfulness.

Another limitation of our work is the open question of generalizability of our findings to other datasets, models and scenarios. Only if the insights of our work generalize, will it be possible to infer a reliable evaluation framework in the ever changing landscape of models and applications.

Lastly we want to highlight the possible negative externalities of misuse of our research in in an adversarial setting. The knowledge about what input triggers a citation or which model components need to be activated to generate a citation, might be used to insert unfaithful citations that promote certain statements. This misuse of gained insight into model behavior unfortunately is an intrinsic downside of any interpretability research, and we hope that advantages will outweight those risks.

Conclusion

In this study, we used mechanistic interpretability to reverse-engineer how Llama-3.1-8B-Instruct decides whether to emit inline citations in a RAG context. Through systematic activation patching, we identified internal components which causally drive citation behavior and tested whether manipulating them could correct citation failures. We found that citation generation is implemented by a distributed “attributional ensemble” of attention heads and MLPs that operates through conjunctive checks rather than a single specialized module. This ensemble relies heavily on shallow heuristics, particularly entity co-reference matching between document and question, rather than deep semantic integration during answer construction.

We argue that this suggests that inline citations can create an illusion of verifiability even when answers are not genuinely grounded in sources. This work can be seen as a first step towards making these failure modes mechanistically legible and toward an evaluation frameworks that can distinguish faithful from unfaithful attribution.

Our study has important limitations: we analyzed a single 8B model in a controlled, single-document setting; activation patching localizes components but not directed information pathways; and we did not directly map the answer-generation circuit to test mechanistic overlap with citation generation.

Future work should refine the ensemble into a complete directed circuit via path patching, explicitly map and compare the answer-generation and citation circuits to operationalize mechanistic faithfulness, and replicate across model architectures, scales, and RAG-finetuned systems to assess whether these mechanisms are universal or model-specific.