发现大模型安全关键头,删一个就让有害请求多16倍
On the Role of Attention Heads in Large Language Model Safety
- 提出安全注意力头重要性评分(Ships),量化各注意力头对安全的贡献
- 仅删除0.006%参数中的一个安全头,模型有害响应增加16倍
- 不同模型共享安全注意力头,适合研究模型安全机制的人看
大型语言模型在多项任务中表现优异,但其安全防护机制可能被绕过,导致生成有害内容。尽管已有研究揭示安全表征或组件被抑制会削弱模型安全能力,但现有工作普遍忽视了多头注意力机制的安全影响。本文提出针对多头注意力的新型评估指标——安全头重要性得分(Ships),用于衡量各注意力头对安全性的贡献。基于此,我们进一步构建了安全注意力头归因算法(Sahara),实现对模型内部关键安全注意力头的定位。实验表明,特定注意力头对安全性具有显著影响:仅移除一个安全头,即可使对齐模型(如Llama-2-7b-chat)对有害查询的响应量提升16倍,且仅修改0.006%的参数;相比之下,以往研究需修改约5%参数。更重要的是,通过大量实验验证,来自同一基础模型的微调模型表现出重叠的安全注意力头。本研究为解析大模型安全机制的黑箱提供了新视角。
原文摘要 · Abstract (English)
Large language models (LLMs) achieve state-of-the-art performance on multiple language tasks, yet their safety guardrails can be circumvented, leading to harmful generations. In light of this, recent research on safety mechanisms has emerged, revealing that when safety representations or component are suppressed, the safety capability of LLMs are compromised. However, existing research tends to overlook the safety impact of multi-head attention mechanisms, despite their crucial role in various model functionalities. Hence, in this paper, we aim to explore the connection between standard attention mechanisms and safety capability to fill this gap in the safety-related mechanistic interpretability. We propose a novel metric which tailored for multi-head attention, the Safety Head ImPortant Score (Ships), to assess the individual heads' contributions to model safety. Based on this, we generalize Ships to the dataset level and further introduce the Safety Attention Head AttRibution Algorithm (Sahara) to attribute the critical safety attention heads inside the model. Our findings show that the special attention head has a significant impact on safety. Ablating a single safety head allows aligned model (e.g., Llama-2-7b-chat) to respond to 16 times more harmful queries, while only modifying 0.006% of the parameters, in contrast to the ~ 5% modification required in previous studies. More importantly, we demonstrate that attention heads primarily function as feature extractors for safety and models fine-tuned from the same base model exhibit overlapping safety heads through comprehensive experiments. Together, our attribution approach and findings provide a novel perspective for unpacking the black box of safety mechanisms within large models.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。