[论文解读] VISIT: Visualizing and Interpreting the Semantic Information Flow of Transformers
该论文介绍了VISIT,一种通过使用logit透镜将隐藏状态和注意力记忆值投影到词汇空间,来可视化和解释类似GPT的变换器中语义信息流的工具。它揭示了层归一化(layer norm)作为语义过滤器的作用,并识别出始终激活的神经元——称为‘正则化神经元’——这些神经元稳定了模型输出,为注意力机制和残差流动态提供了新的机制性洞见。
Recent advances in interpretability suggest we can project weights and hidden states of transformer-based language models (LMs) to their vocabulary, a transformation that makes them more human interpretable. In this paper, we investigate LM attention heads and memory values, the vectors the models dynamically create and recall while processing a given input. By analyzing the tokens they represent through this projection, we identify patterns in the information flow inside the attention mechanism. Based on our discoveries, we create a tool to visualize a forward pass of Generative Pre-trained Transformers (GPTs) as an interactive flow graph, with nodes representing neurons or hidden states and edges representing the interactions between them. Our visualization simplifies huge amounts of data into easy-to-read plots that can reflect the models' internal processing, uncovering the contribution of each component to the models' final prediction. Our visualization also unveils new insights about the role of layer norms as semantic filters that influence the models' output, and about neurons that are always activated during forward passes and act as regularization vectors.
研究动机与目标
- 通过可视化注意力机制和隐藏状态中的语义信息流,提升变换器语言模型的可解释性。
- 研究动态组件(如注意力记忆值和层归一化)在残差流中的功能角色。
- 开发一种易于使用、交互式的可视化工具,简化研究人员和实践者对复杂内部模型动态的理解。
- 揭示神经元和注意力头在最终预测中贡献的先前未被观察到的模式。
- 为GPT-2中的组件(如层归一化和始终活跃的神经元)提供机制性洞见。
提出的方法
- 使用logit透镜将隐藏状态和注意力记忆值投影到词汇空间,使模型激活状态可被人类理解。
- 构建交互式流程图,其中节点代表神经元或隐藏状态,边代表组件之间的信息流。
- 通过追踪跨层查询、键、值和输出头的语义内容,分析注意力机制。
- 应用层归一化(LN)对隐藏状态的影响,并比较LN前后标记的概率分布,以评估语义过滤效果。
- 识别在所有前向传播中均持续激活的神经元,将其定义为与异常维度不同的正则化神经元。
- 通过GPT-2的案例研究,验证在间接宾语识别、LN过滤和神经元行为方面的发现。

实验结果
研究问题
- RQ1在GPT中,注意力记忆值和隐藏状态如何通过残差流传递语义信息?
- RQ2层归一化层在塑造隐藏状态语义内容方面发挥什么功能作用?
- RQ3是否存在在推理过程中始终激活的神经元?它们对模型行为有何影响?
- RQ4隐藏状态的logit透镜投影如何揭示模型在预测前的内部推理过程?
- RQ5层归一化在多大程度上充当语义过滤器,从而改变生成标记的概率分布?
主要发现
- 层归一化层作为语义过滤器,抑制功能词,同时促进领域特定或上下文相关的标记(如'Redmond'或'downtown')。
- 在不使用最终层归一化($ln_f$)的logit透镜投影下,会产生语义不连贯的标记分布,凸显$ln_f$在维持语境连贯性中的关键作用。
- 在所有前向传播中均持续激活的神经元——称为‘正则化神经元’——与异常维度不同,有助于模型稳定性。
- 注意力机制的记忆值(键和值)携带有意义的语义内容,信息流模式揭示了过去标记如何影响当前预测。
- 可视化工具成功捕捉了语义信息的动态流动,使个体神经元对最终输出的贡献得以检测。
- 案例研究证实,该工具能以简化且可解释的方式重现已知的机制性行为,如间接宾语识别。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。