说话的头:理解Transformer语言模型中的层间通信
Talking Heads: Understanding Inter-layer Communication in Transformer Language Models
AI总结:
本文发现Transformer语言模型通过残差流中的低秩子空间实现层间通信,并利用SVD分解注意力头解释列表位置索引机制,据此编辑模型表示和权重,在Laundry List任务上将准确率提升超过20%。
摘要:
尽管已知Transformer语言模型(LMs)会将特征从早期层传递到后期层,但模型如何表示和路由这些信息尚不清楚。我们分析了两个语言模型在一个任务中用于选择性抑制上下文中某些项的一种机制,并发现该机制是许多上下文检索行为中一种常用抽象的基础。具体来说,我们发现模型会写入残差流的低秩子空间来表示特征,这些特征随后被后期层读出,从而在层之间形成低秩通信通道(Elhage et al., 2021)。在GPT-2的模型激活中,可以遍历一个特定的3D子空间来对列表中的项进行位置索引,我们证明该机制可以解释模型对提示中项顺序的一种看似任意的敏感性。也就是说,当许多项“挤占”这一有限空间时,模型难以从上下文中复制正确的信息。通过使用奇异值分解(SVD)分解注意力头,我们发现此前描述的相隔一层或多层的注意力头之间的交互可以仅通过分析其权重矩阵来预测。我们表明,基于我们发现的机制,可以操纵内部模型表示以及编辑模型权重,从而显著提升我们在合成Laundry List任务上的性能,该任务要求从列表中进行回忆,通常可将任务准确率提高超过20%。我们的分析揭示了从语言模型预训练中学习到的令人惊讶的复杂可解释结构,并帮助我们理解为什么复杂的语言模型有时会在简单领域中失败,从而促进未来对更复杂行为的分析。
英文摘要:
Although it is known that transformer language models (LMs) pass features from early layers to later layers, it is not well understood how this information is represented and routed by the model. We analyze a mechanism used in two LMs to selectively inhibit items in a context in one task, and find that it underlies a commonly used abstraction across many context-retrieval behaviors. Specifically, we find that models write into low-rank subspaces of the residual stream to represent features which are then read out by later layers, forming low-rank communication channels (Elhage et al., 2021) between layers. A particular 3D subspace in model activations in GPT-2 can be traversed to positionally index items in lists, and we show that this mechanism can explain an otherwise arbitrary-seeming sensitivity of the model to the order of items in the prompt. That is, the model has trouble copying the correct information from context when many items ``crowd" this limited space. By decomposing attention heads with the Singular Value Decomposition (SVD), we find that previously described interactions between heads separated by one or more layers can be predicted via analysis of their weight matrices alone. We show that it is possible to manipulate the internal model representations as well as edit model weights based on the mechanism we discover in order to significantly improve performance on our synthetic Laundry List task, which requires recall from a list, often improving task accuracy by over 20%. Our analysis reveals a surprisingly intricate interpretable structure learned from language model pretraining, and helps us understand why sophisticated LMs sometimes fail in simple domains, facilitating future analysis of more complex behaviors.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。