Quantifying reliance on external information over parametric knowledge during Retrieval Augmented Generation (RAG) using mechanistic analysis

Reshmi Ghosh, Rahul Seetharaman, Hitesh Wadhwa, Somyaa Aggarwal, Samyadeep Basu, Soundararajan Srinivasan, Wenlong Zhao, Shreyas Chaudhari, Ehsan Aghazadeh

TL;DR

When language models answer questions using Retrieval-Augmented Generation (RAG), do they recall facts from memory or read them from the prompt? Using mechanistic interpretability techniques, this paper reveals that models take a dramatic "shortcut": they almost entirely bypass their internal parametric memory to pull answers directly from the provided external context.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) is one of the most common ways to ground language models in proprietary or up-to-date facts. However, it has remained unclear under the hood whether models actually combine retrieved context with their pre-trained parametric knowledge or simply ignore their internal memory when context is provided. This paper mechanistically inspects the internal representations and attention pathways of models to determine how they choose between internal knowledge and external context.

Methods

The authors apply three mechanistic probing techniques across a standard prompt (vanilla non-RAG) versus an augmented prompt (RAG setting):

  1. Causal Tracing (Causal Mediation Analysis): Measures the Average Indirect Effect (AIE) of hidden states. By running clean, corrupted, and activation-patched runs, this identifies which token activations causally restore the correct answer.
  2. Attention Contributions: Computes the norm of attention weights ($\|a_{i, T}^{(\ell)}\|$) from specific positions (e.g., subject tokens vs. context tokens) directed toward the last token position ($T$), tracing which inputs enrich the final residual stream used for next-token generation.
  3. Attention Knockouts: Artificially disables communication between specific token positions by setting attention scores between positions $i$ and $j$ to $-\infty$, measuring how sharply prediction probability degrades when an edge is severed.

Datasets

  • Knowns 1000 dataset: A benchmark of 1,209 factual prompts (originally introduced by Meng et al., 2022a) used to evaluate factual recall.
  • Synthetically Augmented RAG Dataset: The authors augmented the 1,209 factual prompts with context generated by GPT-4. Synthetic generation was used to control paragraph length and ensure precise placement of the target subject and attribute/object tokens.
  • Models Evaluated: LLaMA-2 (7B) and Phi-2 (2.7B).

Key Insights and Ideas

  • The "Shortcut" Effect: Rather than synthesizing retrieved context with internal priors, transformers treat the provided context as an information highway, routing facts directly into the final decoding position.
  • Suppression of Parametric Pathways: In standard factual recall, the Last Subject Token (LST) acts as the critical trigger that pulls facts from internal weights (MLP layers). In the RAG setting, the causal importance of this token collapses.
  • Bypassing the Query Subject: Attention knockouts show that the model no longer relies on passing information from the question's subject token to the final generation token when an external context containing the answer is present.

Key Results

  • Plummeting Causal Influence (AIE): Adding RAG context leads to a ~10× decrease in the Average Indirect Effect of the Last Subject Token for LLaMA-2, and a ~35× decrease for Phi-2, showing a steep drop in dependence on parametric memory.
  • Shift in Attention Weight:
  • Mean attention contributions from the query's Subject Token (ST) to the Last Token (LT) dropped by ~1.6× in LLaMA-2 and ~7× in Phi-2 when external context was supplied.
  • Meanwhile, attention contributions from context answer tokens to the LT surged significantly.
  • Insensitivity to Subject Knockouts:
  • In vanilla non-RAG, severing attention from the Subject Token to the Last Token slashed the probability of the correct answer by 20% (LLaMA-2) and 25% (Phi-2).
  • In the RAG setting, the exact same knockout resulted in less than a 5% drop, demonstrating that the parametric recall circuit is barely active.

Limitations and Future Work

  • Model Scale: Experiments were restricted to relatively small open-source models ($\le 7\text{B}$ parameters); the authors plan to evaluate larger models ($>13\text{B}$).
  • Synthetic Context vs. Real RAG Pipelines: Contexts were generated via GPT-4 under controlled conditions rather than retrieved through an end-to-end vector search/retrieval pipeline.
  • Context Length & Positional Bias: The study did not test longer context windows or evaluate how structural phenomena like the "lost in the middle" (primacy/recency) bias affect this shortcut mechanism.

Summary updated

BibTeX
@inproceedings{ghosh2024quantifying,
  author = {Reshmi Ghosh and Rahul Seetharaman and Hitesh Wadhwa and Somyaa Aggarwal and Samyadeep Basu and Soundararajan Srinivasan and Wenlong Zhao and Shreyas Chaudhari and Ehsan Aghazadeh},
  title = {{Quantifying reliance on external information over parametric knowledge during Retrieval Augmented Generation (RAG) using mechanistic analysis}},
  booktitle = {BlackBoxNLP @ EMNLP},
  year = {2024},
  url = {https://openreview.net/forum?id=PCi5h5PJNw},
}

Loading related content...

Figure