Knowledge Circuits in Pretrained Transformers

📄 arXiv: 2405.17969v4 📥 PDF

作者: Yunzhi Yao, Ningyu Zhang, Zekun Xi, Mengru Wang, Ziwen Xu, Shumin Deng, Huajun Chen

分类: cs.CL, cs.AI, cs.CV, cs.IR, cs.LG

发布日期: 2024-05-28 (更新: 2025-01-03)

备注: NeurIPS 2024, 26 pages

🔗 代码/项目: GITHUB


💡 一句话要点

揭示Transformer中知识存储方式:提出知识回路以理解模型行为

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 知识回路 Transformer 知识编辑 语言模型 模型可解释性

📋 核心要点

  1. 现有研究主要关注Transformer模型中孤立的组件,如MLP和注意力头,缺乏对知识存储整体机制的理解。
  2. 本文提出“知识回路”的概念,通过分析计算图来揭示模型中协同编码特定知识的组件集合。
  3. 通过GPT2和TinyLLAMA的实验,验证了知识回路的存在,并分析了其对知识编辑和模型行为的影响。

📝 摘要(中文)

大型语言模型的能力源于其参数中编码的海量知识,使其能够感知世界并进行推理。模型如何存储知识一直是研究的热点。本文深入研究语言模型的计算图,揭示了表达特定知识的知识回路。通过GPT2和TinyLLAMA的实验,观察到信息头、关系头和多层感知器如何协同编码知识。此外,评估了现有知识编辑技术对这些知识回路的影响,从而更深入地了解这些编辑方法的功能和约束。最后,利用知识回路来分析和解释语言模型的幻觉和上下文学习等行为。知识回路有望促进我们对Transformer的理解,并指导知识编辑的改进设计。

🔬 方法详解

问题定义:现有研究对Transformer内部知识存储的理解主要集中在孤立的模块上,缺乏对模块间协作关系的深入分析,难以解释模型整体的知识表达和推理机制。此外,现有的知识编辑方法缺乏对模型内部知识表示全局性的考虑,效果提升有限。

核心思路:本文的核心思路是通过分析Transformer模型的计算图,识别出负责特定知识表达的组件集合,即“知识回路”。通过研究这些回路的结构和功能,可以更深入地理解模型如何存储和利用知识,从而为知识编辑和模型行为分析提供新的视角。

技术框架:本文的技术框架主要包括以下几个步骤:1) 构建Transformer模型的计算图;2) 定义知识回路的搜索算法,识别出与特定知识相关的组件集合;3) 分析知识回路的结构和功能,例如,哪些类型的注意力头和MLP参与了知识的编码;4) 评估知识编辑技术对知识回路的影响;5) 利用知识回路分析和解释语言模型的行为,如幻觉和上下文学习。

关键创新:本文最重要的创新点在于提出了“知识回路”的概念,并提供了一种识别和分析知识回路的方法。与以往研究关注孤立模块不同,本文强调了模型内部组件之间的协作关系,为理解Transformer的知识表达和推理机制提供了一种新的视角。

关键设计:本文的关键设计包括:1) 知识回路的搜索算法,该算法需要能够有效地识别出与特定知识相关的组件集合;2) 知识回路的分析方法,该方法需要能够揭示回路的结构和功能,例如,哪些类型的注意力头和MLP参与了知识的编码;3) 实验设计,需要选择合适的知识编辑技术和模型行为分析任务,以验证知识回路的有效性。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

通过在GPT2和TinyLLAMA上的实验,本文验证了知识回路的存在,并观察到不同类型的注意力头和MLP在知识编码中的作用。实验还表明,现有的知识编辑技术对知识回路的影响有限,表明需要更精细的编辑方法。此外,通过分析知识回路,本文成功解释了语言模型的幻觉和上下文学习等行为。

🎯 应用场景

该研究成果可应用于提升语言模型的知识编辑能力,例如,通过修改知识回路来更精确地更新模型知识。此外,还可以用于分析和解释语言模型的行为,例如,通过识别导致幻觉的知识回路来提高模型的可信度。该研究还有助于更好地理解Transformer的内部机制,从而指导更有效的模型设计。

📄 摘要(原文)

The remarkable capabilities of modern large language models are rooted in their vast repositories of knowledge encoded within their parameters, enabling them to perceive the world and engage in reasoning. The inner workings of how these models store knowledge have long been a subject of intense interest and investigation among researchers. To date, most studies have concentrated on isolated components within these models, such as the Multilayer Perceptrons and attention head. In this paper, we delve into the computation graph of the language model to uncover the knowledge circuits that are instrumental in articulating specific knowledge. The experiments, conducted with GPT2 and TinyLLAMA, have allowed us to observe how certain information heads, relation heads, and Multilayer Perceptrons collaboratively encode knowledge within the model. Moreover, we evaluate the impact of current knowledge editing techniques on these knowledge circuits, providing deeper insights into the functioning and constraints of these editing methodologies. Finally, we utilize knowledge circuits to analyze and interpret language model behaviors such as hallucinations and in-context learning. We believe the knowledge circuits hold potential for advancing our understanding of Transformers and guiding the improved design of knowledge editing. Code and data are available in https://github.com/zjunlp/KnowledgeCircuits.