arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2410.13708cs.CLcs.AIcs.CRcs.LG
收藏

注意力头在大语言模型安全中的作用

On the Role of Attention Heads in Large Language Model Safety

Tongyi Lab(通义实验室);USTC(中国科学技术大学);Tsinghua University(清华大学);Nanyang Technological University(南洋理工大学)

Zhenhong Zhou, Haiyang Yu, Xinghua Zhang, Rongwu Xu, Fei Huang, Kun Wang, Yang Liu, Junfeng Fang, Yongbin Li

AI总结:

本文提出安全头重要性分数(Ships)与安全注意力头归因算法(Sahara),揭示注意力头对LLM安全的关键作用:消融单个安全头仅修改0.006%参数即可使有害查询响应增加16倍,为安全机制可解释性提供新视角。

摘要:

大语言模型(LLMs)在多项语言任务上取得了最先进的性能,但其安全护栏可能被绕过,导致有害内容生成。鉴于此,近年来关于安全机制的研究不断涌现,揭示出当安全表示或组件被抑制时,LLMs的安全能力会受到损害。然而,现有研究往往忽视多头注意力机制对安全的影响,尽管注意力机制在模型的各种功能中起着至关重要的作用。因此,本文旨在探索标准注意力机制与安全能力之间的联系,以填补安全相关机制可解释性方面的这一空白。我们提出了一种专门针对多头注意力的新指标——安全头重要性分数(Ships),用于评估各个注意力头对模型安全的贡献。在此基础上,我们将Ships推广到数据集级别,并进一步引入安全注意力头归因算法(Sahara),以归因模型内部的关键安全注意力头。我们的研究结果表明,特定的注意力头对安全具有显著影响。消融单个安全头可使对齐模型(如Llama-2-7b-chat)响应16倍多的有害查询,而仅需修改0.006%的参数,相比之下,先前研究需要修改约5%的参数。更重要的是,我们通过综合实验证明,注意力头主要作为安全特征提取器,且从同一基础模型微调得到的模型表现出重叠的安全头。总之,我们的归因方法和发现为解开大模型内部安全机制的黑箱提供了新的视角。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑