arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.08956cs.CRcs.SE
收藏

基于欺骗性交叉熵损失的代码语言模型后门攻击防御方法

Defending Code Language Models against Backdoor Attacks with Deceptive Cross-Entropy Loss

Guang Yang, Yu Zhou, Xiang Chen, Xiangyu Zhang, Terry Yue Zhuo, David Lo, Taolue Chen

AI总结:

针对代码语言模型易受后门攻击且现有防御方法通用性不足的问题,该研究证实CLM训练中的“早学”现象,提出DeCE损失函数通过限制梯度防止模型对后门触发器过拟合,提升模型后门防御能力。

摘要:

代码语言模型(Code Language Models, CLMs),尤其是基于深度学习的代码语言模型,已在代码智能领域取得显著成功。但这一过程中安全问题常被忽视,尤其是后门攻击。现有研究多聚焦于为CLMs设计后门攻击,而有效防御手段尚未得到充分研究。特别是自然语言处理领域的现有防御方法直接应用于CLMs时效果不佳且缺乏通用性,仅在部分模型和场景下有效,在其他场景中失效,因此无法持续缓解后门攻击。为填补这一空白,我们首先证实“早学”现象是CLMs训练过程中的普遍现象:模型初始阶段会关注训练数据的主要特征,但随训练推进可能对后门触发器愈发敏感,进而导致过拟合并易受后门攻击。我们进一步分析发现,对后门触发器的过拟合源于交叉熵损失函数的使用——交叉熵的无界性会使模型越来越关注中毒数据的特征。基于这一洞察,我们提出一种通用且有效的损失函数DeCE(欺骗性交叉熵),通过融合欺骗性分布并应用标签平滑将梯度限制在有界范围内,防止模型对后门触发器过拟合,从而提升CLMs抵御后门攻击的安全性。

英文摘要:

Code Language Models (CLMs), particularly those leveraging deep learning, have achieved significant success in code intelligence domain. However, the issue of security, particularly backdoor attacks, is often overlooked in this process. The previous research has focused on designing backdoor attacks for CLMs, but effective defenses have not been adequately addressed. In particular, existing defense methods from natural language processing, when directly applied to CLMs, are not effective enough and lack generality, working well in some models and scenarios but failing in others, thus fall short in consistently mitigating backdoor attacks. To bridge this gap, we first confirm the phenomenon of "early learning" as a general occurrence during the training of CLMs. This phenomenon refers to that a model initially focuses on the main features of training data but may become more sensitive to backdoor triggers over time, leading to overfitting and susceptibility to backdoor attacks. We then analyze that overfitting to backdoor triggers results from the use of the cross-entropy loss function, where the unboundedness of cross-entropy leads the model to increasingly concentrate on the features of the poisoned data. Based on this insight, we propose a general and effective loss function DeCE (Deceptive Cross-Entropy) by blending deceptive distributions and applying label smoothing to limit the gradient to bounded, which prevents the model from overfitting to backdoor triggers and then enhances the security of CLMs against backdoor attacks.

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

↑