Towards Interpreting Language Models: A Case Study in Multi-Hop Reasoning

Mansi Sakarvadia
11/6/2024
cs.CLcs.AIcs.LG

No official code found. Best implementation: msakarvadia/AttentionLens (39 stars, MIT, last commit 2024-08-13).

Abstract

Answering multi-hop reasoning questions requires retrieving and synthesizing information from diverse sources. Language models (LMs) struggle to perform such reasoning consistently. We propose an approach to pinpoint and rectify multi-hop reasoning failures through targeted memory injections on LM attention heads. First, we analyze the per-layer activations of GPT-2 models in response to single- and multi-hop prompts. We then propose a mechanism that allows users to inject relevant prompt-specific information, which we refer to as "memories," at critical LM locations during inference. By thus enabling the LM to incorporate additional relevant information during inference, we enhance the quality of multi-hop prompt completions. We empirically show that a simple, efficient, and targeted memory injection into a key attention layer often increases the probability of the desired next token in multi-hop tasks, by up to 424%. We observe that small subsets of attention heads can significantly impact the model prediction during multi-hop reasoning. To more faithfully interpret these heads, we develop Attention Lens: an open source tool that translates the outputs of attention heads into vocabulary tokens via learned transformations called lenses. We demonstrate the use of lenses to reveal how a model arrives at its answer and use them to localize sources of model failures such as in the case of biased and malicious language generation.

View on arXivView PDF

Code Implementations(1)

MIT

Interpretating the latent space representations of attention head outputs for LLMs

394Shell, PythonJul 3, 20232 years agoMIT

Similar Papers

Cite this paper

@article{sakarvadia2024towards,
  title  = {Towards Interpreting Language Models: A Case Study in Multi-Hop Reasoning},
  author = {Mansi Sakarvadia},
  year   = {2024},
  eprint = {2411.05037},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2411.05037v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.05037.svg)](https://codeofpaper.com/paper/2411.05037)

Discussion