The Mysterious Case of Neuron 1512: Injectable Realignment Architectures Reveal Internal Characteristics of Meta's Llama 2 Model

📄 arXiv: 2407.03621v1 📥 PDF

作者: Brenden Smith, Dallin Baker, Clayton Chase, Myles Barney, Kaden Parker, Makenna Allred, Peter Hu, Alex Evans, Nancy Fulda

分类: cs.CL

发布日期: 2024-07-04

备注: 21 pages, 17 figures

🔗 代码/项目: GITHUB


💡 一句话要点

提出可注入重对齐模型(IRM),揭示Llama 2模型内部神经元与对齐行为的关联性。

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

关键词: 大型语言模型 可解释性 对齐 神经元分析 Llama 2 可注入重对齐模型 情感分析

📋 核心要点

  1. 大型语言模型内部机制复杂,难以理解其对齐人类偏好的内在原因,现有方法缺乏有效手段。
  2. 提出可注入重对齐模型(IRM),通过训练小型网络诱导LLM产生情感对齐,并分析其激活模式。
  3. 实验发现,IRM激活模式与神经元索引而非层相关,且特定神经元(1512)与所有测试对齐方式强相关。

📝 摘要(中文)

大型语言模型(LLMs)在将其输出与各种人类偏好“对齐”方面具有无与伦比的宝贵能力,通过在它们生成的文本中反映这些偏好。然而,此类模型的内部特征在很大程度上仍然不透明。本研究提出了可注入重对齐模型(IRM),作为一种新颖的语言模型可解释性和可解释性方法。受到早期神经编程接口工作的启发,我们构建并训练了一个小型网络——IRM——以在7B参数LLM架构中诱导基于情感的对齐。IRM的输出通过逐层加法注入到LLM前向传递的各个点,从而在不改变原始模型权重的情况下调节其行为。这会将对齐行为与transformer模型的复杂机制隔离开来。对训练后的IRM输出的分析揭示了一种奇特的模式。在超过24次训练运行和多个对齐数据集中,IRM激活模式以与每个transformer层中神经元索引相关的条纹形式对齐,而不是与层本身相关联。此外,单个神经元索引(1512)与所有测试的对齐方式强烈相关。虽然最初违反直觉,但这一结果可以直接归因于几乎所有商业可用的transformer架构中存在的设计选择,并突出了Meta预训练的Llama 2模型中潜在的薄弱点。它还证明了IRM架构在语言模型分析和可解释性方面的价值。我们的代码和数据集可在https://github.com/DRAGNLabs/injectable-alignment-model获得。

🔬 方法详解

问题定义:论文旨在解决大型语言模型(LLMs)内部对齐机制不透明的问题。现有方法难以理解LLMs如何将其输出与人类偏好对齐,缺乏有效的可解释性工具。这使得我们难以诊断和改进LLMs的对齐行为,并可能导致意外或有害的输出。

核心思路:论文的核心思路是通过构建一个小型可训练网络(IRM),将其输出注入到LLM的中间层,从而在不改变LLM原始权重的情况下,诱导特定的对齐行为。通过分析IRM的激活模式,可以揭示LLM内部与对齐相关的神经元或结构。这种方法将对齐行为与LLM的复杂机制隔离开来,简化了分析过程。

技术框架:整体框架包括以下几个主要步骤:1) 选择一个预训练的LLM(如Llama 2)。2) 构建一个小型神经网络作为IRM,其输入是文本,输出是与LLM中间层维度匹配的向量。3) 使用特定的对齐数据集(如情感分类数据集)训练IRM,目标是使LLM在注入IRM输出后,产生与数据集标签一致的输出。4) 在LLM的前向传递过程中,将IRM的输出逐层添加到LLM的中间层。5) 分析训练后的IRM的激活模式,寻找与对齐行为相关的神经元或结构。

关键创新:最重要的技术创新点是IRM架构本身,它提供了一种非侵入式的干预手段,可以在不修改LLM原始权重的情况下,研究其内部对齐机制。与传统的模型解释方法相比,IRM可以直接诱导特定的对齐行为,并分析其对应的神经元激活模式,从而更深入地理解LLM的内部工作原理。

关键设计:IRM是一个小型神经网络,可以使用简单的MLP结构。关键参数包括IRM的层数、每层神经元数量、学习率等。损失函数通常是交叉熵损失,用于衡量LLM在注入IRM输出后的预测结果与数据集标签之间的差异。IRM的输出通过逐层加法注入到LLM的中间层,注入的位置和权重可以作为超参数进行调整。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,IRM的激活模式与神经元索引(特别是1512)高度相关,而非与transformer层相关。这一发现揭示了Llama 2模型中可能存在的潜在弱点,并验证了IRM架构在语言模型分析中的有效性。在多个对齐数据集上进行了超过24次训练运行,结果均显示出一致的模式。

🎯 应用场景

该研究成果可应用于提升大型语言模型的可解释性和安全性。通过IRM,可以诊断和修复LLM中存在的对齐问题,例如偏见或有害内容生成。此外,该方法还可以用于开发更可靠和可控的LLM,使其更好地服务于人类需求。

📄 摘要(原文)

Large Language Models (LLMs) have an unrivaled and invaluable ability to "align" their output to a diverse range of human preferences, by mirroring them in the text they generate. The internal characteristics of such models, however, remain largely opaque. This work presents the Injectable Realignment Model (IRM) as a novel approach to language model interpretability and explainability. Inspired by earlier work on Neural Programming Interfaces, we construct and train a small network -- the IRM -- to induce emotion-based alignments within a 7B parameter LLM architecture. The IRM outputs are injected via layerwise addition at various points during the LLM's forward pass, thus modulating its behavior without changing the weights of the original model. This isolates the alignment behavior from the complex mechanisms of the transformer model. Analysis of the trained IRM's outputs reveals a curious pattern. Across more than 24 training runs and multiple alignment datasets, patterns of IRM activations align themselves in striations associated with a neuron's index within each transformer layer, rather than being associated with the layers themselves. Further, a single neuron index (1512) is strongly correlated with all tested alignments. This result, although initially counterintuitive, is directly attributable to design choices present within almost all commercially available transformer architectures, and highlights a potential weak point in Meta's pretrained Llama 2 models. It also demonstrates the value of the IRM architecture for language model analysis and interpretability. Our code and datasets are available at https://github.com/DRAGNLabs/injectable-alignment-model