通过注入记忆修复大模型多跳推理错误,提升答案准确性。
Towards Interpreting Language Models: A Case Study in Multi-Hop Reasoning
- 在关键注意力层注入特定记忆信息,增强模型推理能力。
- 实验显示关键层注入可使目标词概率提升最高达424%。
- 开源工具Attention Lens可可视化注意力机制,定位模型缺陷。
回答多跳推理问题需要从不同来源检索并整合信息,语言模型在此类任务中表现不稳定。本文提出一种方法,通过在推理过程中向语言模型的关键注意力头注入特定信息(称为'记忆'),定位并修正多跳推理的失败。我们分析了GPT-2在单跳与多跳提示下的各层激活情况,并设计了一种机制,在推理时精准注入相关上下文信息。实验证明,对关键注意力层进行简单、高效的针对性记忆注入,可使多跳任务中目标下一词的概率最高提升424%。我们发现少数注意力头对多跳推理结果影响显著。为更准确解读这些头,我们开发了开源工具Attention Lens,通过学习得到的'透镜'将注意力输出转换为词汇标记,揭示模型决策路径,并用于定位偏见或恶意语言生成等故障源头。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。