On Mechanistic Circuits for Extractive Question-Answering

Samyadeep Basu, Vlad I. Morariu, Zichao Wang, Ryan A. Rossi, Cherry Zhao, Soheil Feizi, Varun Manjunatha

Abstract

Large Language Models (LLMs) often face a conflict between provided context and internal parametric memory, leading to hallucinations in extractive question-answering (QA). This paper identifies the mechanistic circuits—specific sub-graphs of neurons and attention heads—responsible for these behaviors. By isolating these circuits, the authors introduce ATTNATTRIB, a zero-cost data attribution method, and demonstrate a steering technique that improves model faithfulness to context by up to 9%.

Introduction

Extractive QA requires a model to prioritize retrieved documents over its own pre-trained knowledge. When parametric memory overrides the provided context, models hallucinate. While LLMs excel at this task, the underlying mechanisms have remained opaque. This research bridges the gap between theoretical mechanistic interpretability and practical model reliability by mapping the internal circuits used during QA.

Methodology: Circuit Extraction and Attribution

The core of this work involves identifying causal components within the model using Causal Mediation Analysis (CMA) and Path Patching.

Interventional patching process for identifying causal nodes in the model's internal hierarchy.

Circuit Extraction

Researchers compare a "clean" model run (using correct context) against a "corrupted" run (scrambled context). By systematically swapping activations—a process called patching—they identify specific attention heads and MLP layers whose activity is essential for the model to arrive at the correct answer.

ATTNATTRIB and Model Steering

The analysis revealed that a small subset of attention heads acts as "pointers" to the answer. The ATTNATTRIB algorithm leverages these heads to provide precise data attribution during a single forward pass without extra compute. Furthermore, by upweighting the attention values of these "context-faithful" heads, the model can be "steered" to prioritize the document over its internal memory.

Key Insights: Sparsity and Component Roles

The study highlights a stark difference between how models handle context versus memory.

Greedy selection analysis showing the sparsity of context-faithfulness circuits compared to the density of memory-faithfulness circuits across attention and MLP components.
  • Sparse vs. Dense Circuits: The "Context-Faithfulness" circuit is remarkably sparse, relying on only a few key attention heads. Conversely, "Memory-Faithfulness" (recalling training data) is much denser, involving a wide array of components across the model.
  • The Role of MLPs: Multi-Layer Perceptrons (MLPs) are heavily involved in memory recall but are largely irrelevant when the model is being faithful to the provided context.
  • Dedicated Attribution Heads: In models like Vicuna and Llama-3, specific low-entropy attention heads function as dedicated "data attribution engines," pointing directly to the answer span in the context by default.

Results and Evaluation

The researchers evaluated their methods using standard benchmarks (Natural Questions, HotPotQA) and custom probes.

  • Attribution Accuracy: ATTNATTRIB outperformed traditional gradient-based methods and sentence similarity baselines by approximately 20% in F1-score on HotPotQA.
  • Hallucination Reduction: Steering the model via discovered circuits resulted in up to a 9% accuracy improvement in extractive QA, significantly grounding the model's outputs.
  • Cross-Model Scalability: These mechanistic patterns were consistent across various model families, including Vicuna, Llama-3, and Phi-3, and scaled effectively to larger models like Llama-3-70B.

Conclusion and Limitations

While identifying these circuits provides a powerful tool for transparency and control, the method currently requires "white-box" access to model activations. Additionally, while highly effective for single-hop extraction, further research is needed to map circuits for complex multi-hop reasoning and abstractive logic.

Summary updated

BibTeX
@inproceedings{basu2025mechanistic,
  author = {Samyadeep Basu and Vlad I. Morariu and Zichao Wang and Ryan A. Rossi and Cherry Zhao and Soheil Feizi and Varun Manjunatha},
  title = {{On Mechanistic Circuits for Extractive Question-Answering}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=VvSWiNIuPL},
}
Figure