arXiv:2602.05228cs.AI2026-02被引 5

通过注意力聚焦机制识别并抑制有害微调,提升大模型安全性

Surgery: Mitigating Harmful Fine-Tuning for Large Language Models via Attention Sink

  • 利用注意力聚焦差异性区分有害与安全的注意力头
  • 在三个评测集上防御效果提升5.9%至11.3%
  • 适合关注大模型安全对齐的研究者和开发者

有害微调会破坏大语言模型的安全对齐,带来显著风险。本文提出利用注意力聚焦机制缓解此问题。我们定义了注意力头的聚焦差异性(sink divergence)统计量,发现不同注意力头呈现正负两种符号差异。实验表明,模型有害性越高,正聚焦差异性的注意力头数量越多。基于此,我们提出可分性聚焦差异假设:有害模式学习对应的注意力头可通过其聚焦差异符号分离。据此提出Surgery方法,在微调阶段引入聚焦差异正则化,引导注意力头趋向负聚焦差异组,从而降低模型学习并放大有害模式的倾向。大量实验显示,Surgery在BeaverTails、HarmBench和SorryBench上分别提升防御性能5.90%、11.25%和9.55%。源码已公开于https://github.com/Lslland/Surgery。

原文摘要 · Abstract (English)

Harmful fine-tuning can invalidate safety alignment of large language models, exposing significant safety risks. In this paper, we utilize the attention sink mechanism to mitigate harmful fine-tuning. Specifically, we first measure a statistic named \emph{sink divergence} for each attention head and observe that \emph{different attention heads exhibit two different signs of sink divergence}. To understand its safety implications, we conduct experiments and find that the number of attention heads of positive sink divergence increases along with the increase of the model's harmfulness when undergoing harmful fine-tuning. Based on this finding, we propose a separable sink divergence hypothesis -- \emph{attention heads associating with learning harmful patterns during fine-tuning are separable by their sign of sink divergence}. Based on the hypothesis, we propose a fine-tuning-stage defense, dubbed Surgery. Surgery utilizes a regularizer for sink divergence suppression, which steers attention heads toward the negative sink divergence group, thereby reducing the model's tendency to learn and amplify harmful patterns. Extensive experiments demonstrate that Surgery improves defense performance by 5.90\%, 11.25\%, and 9.55\% on the BeaverTails, HarmBench, and SorryBench benchmarks, respectively. Source code is available on https://github.com/Lslland/Surgery.

模型安全微调防护注意力机制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。