Memory Injections: Correcting Multi-Hop Reasoning Failures during Inference in Transformer-Based Language Models

Mansi Sakarvadia, Aswathy Ajith, Arham Khan, Daniel Grzenda, Nathaniel Hudson +3 more
9/11/2023
cs.CLcs.AIcs.LG

Official code: msakarvadia/memory_injections (12 stars, MIT, last commit 2024-02-21).

Abstract

Answering multi-hop reasoning questions requires retrieving and synthesizing information from diverse sources. Large Language Models (LLMs) struggle to perform such reasoning consistently. Here we propose an approach to pinpoint and rectify multi-hop reasoning failures through targeted memory injections on LLM 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 pertinent prompt-specific information, which we refer to as "memories," at critical LLM locations during inference. By thus enabling the LLM to incorporate additional relevant information during inference, we enhance the quality of multi-hop prompt completions. We show empirically that a simple, efficient, and targeted memory injection into a key attention layer can often increase the probability of the desired next token in multi-hop tasks, by up to 424%.

View on arXivView PDF

Code Implementations(1)

MIT

Initial Exploratory Works on Knowledge Tracing in Transformer Based Language Models

121Shell, PythonMar 15, 20232 years agoMIT
interpretability-methodslangauge-modelmultihop-reasoning

Similar Papers

Cite this paper

@article{sakarvadia2023memory,
  title  = {Memory Injections: Correcting Multi-Hop Reasoning Failures during Inference in Transformer-Based Language Models},
  author = {Mansi Sakarvadia and Aswathy Ajith and Arham Khan and Daniel Grzenda and Nathaniel Hudson and André Bauer and Kyle Chard and Ian Foster},
  year   = {2023},
  eprint = {2309.05605},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2309.05605v3}
}

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/2309.05605.svg)](https://codeofpaper.com/paper/2309.05605)

Discussion