[论文解读] Efficient Adversarial Training in LLMs with Continuous Attacks
本文提出 C-AdvUL 和 C-AdvIPO,这两种高效对抗训练方法针对大语言模型(LLMs)使用嵌入空间中的连续攻击,以实现对离散对抗攻击(如后缀攻击和越狱攻击)的鲁棒性,同时相比先前方法将计算成本降低超过 299 倍。该方法在最小化模型效用损失的前提下,实现了对最先进攻击的最高 100% 鲁棒性。
Large language models (LLMs) are vulnerable to adversarial attacks that can bypass their safety guardrails. In many domains, adversarial training has proven to be one of the most promising methods to reliably improve robustness against such attacks. Yet, in the context of LLMs, current methods for adversarial training are hindered by the high computational costs required to perform discrete adversarial attacks at each training iteration. We address this problem by instead calculating adversarial attacks in the continuous embedding space of the LLM, which is orders of magnitudes more efficient. We propose a fast adversarial training algorithm (C-AdvUL) composed of two losses: the first makes the model robust on continuous embedding attacks computed on an adversarial behaviour dataset; the second ensures the usefulness of the final model by fine-tuning on utility data. Moreover, we introduce C-AdvIPO, an adversarial variant of IPO that does not require utility data for adversarially robust alignment. Our empirical evaluation on five models from different families (Gemma, Phi3, Mistral, Zephyr, Llama2) and at different scales (2B, 3.8B, 7B) shows that both algorithms substantially enhance LLM robustness against discrete attacks (GCG, AutoDAN, PAIR), while maintaining utility. Our results demonstrate that robustness to continuous perturbations can extrapolate to discrete threat models. Thereby, we present a path toward scalable adversarial training algorithms for robustly aligning LLMs.
研究动机与目标
- 为解决大语言模型中离散对抗训练的高计算成本问题,该方法依赖于昂贵的标记级扰动(如 GCG)
- 探究在嵌入空间中对连续扰动的鲁棒性是否能泛化至离散自然语言攻击
- 开发高效的对抗训练算法,在提升鲁棒性的同时保持模型效用
- 识别并纠正过度拟合安全目标且损害模型帮助性的有缺陷的评估协议
- 通过最小化计算需求,降低训练鲁棒大语言模型的碳足迹
提出的方法
- C-AdvUL 将在有害行为数据集上使用嵌入空间中连续攻击的对抗训练,与在效用数据集上的微调相结合,以保持模型的有用性
- 连续攻击通过在嵌入空间中优化扰动来计算,相比 GCG 等离散标记级搜索方法快得多
- C-AdvIPO 是 IPO 的对抗变体,通过整合鲁棒性与对齐性,无需单独的效用数据集
- 该方法使用双损失目标:一个用于对抗连续攻击的鲁棒性,另一个用于对齐或效用,具体取决于变体
- 超参数如攻击幅度(ε)和 IPO 加权(β)经过调优,以在鲁棒性与效用之间取得平衡
- 评估协议已修订,安全与效用评估中均包含聊天模板,防止对安全目标的过拟合
![Figure 1 : We propose continuous adversarial training (AT) to address the large computational requirements of existing discrete AT approaches [ 6 ] . We demonstrate that robustness against continuous attacks successfully extrapolates to discrete threats, such as suffix and jailbreaking attacks while](https://ar5iv.labs.arxiv.org/html/2405.15589/assets/x1.png)
实验结果
研究问题
- RQ1在嵌入空间中对连续攻击的鲁棒性是否能泛化至如后缀攻击和越狱攻击等离散自然语言攻击?
- RQ2使用连续攻击的对抗训练是否能在显著降低计算成本的同时,实现与离散对抗训练相当或更优的鲁棒性?
- RQ3在对抗训练中使用连续攻击是否会引发对安全目标的过拟合,导致拒绝良性输入?
- RQ4是否可以不依赖单独的效用数据集实现对抗对齐,如 C-AdvIPO 所示?
- RQ5ε 和 β 等超参数如何影响连续对抗训练中的鲁棒性-效用权衡?
主要发现
- C-AdvUL 和 C-AdvIPO 在多个大语言模型(Gemma、Phi3、Mistral、Zephyr)的 2B–7B 参数规模下,对 GCG、AutoDAN 和 PAIR 攻击实现了最高 100% 的鲁棒性
- 与 R2D2 相比,使用 C-AdvUL 和 C-AdvIPO 训练的模型在良性输入上的拒绝行为显著减少,后者因过度拟合有害数据集的安全目标和语法而表现不佳
- 连续攻击损失与 GCG 损失之间观察到强烈的皮尔逊相关性(r = 0.99,p = 0.0075),表明对连续攻击的鲁棒性可预测对离散攻击的鲁棒性
- C-AdvUL 相比 R2D2 将计算成本降低了至少 299 倍,使大语言模型的对抗训练更具可扩展性
- 鲁棒性-效用权衡直观合理:ε 值越大、β 值越小,鲁棒性越高但效用略有下降,符合预期
- 本研究识别出先前评估协议中的关键缺陷:安全测试使用聊天模板,而效用测试不使用,导致结果误导并引发过拟合

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。