Skip to main content
QUICK REVIEW

[Paper Review] Efficient Adversarial Training in LLMs with Continuous Attacks

Sophie Xhonneux, Alessandro Sordoni|arXiv (Cornell University)|May 24, 2024
Adversarial Robustness in Machine LearningComputer Science3 citations
TL;DR

This paper proposes C-AdvUL and C-AdvIPO, efficient adversarial training methods for large language models (LLMs) that use continuous attacks in the embedding space to achieve robustness against discrete adversarial attacks—such as suffix and jailbreaking attacks—while reducing computational costs by over 299× compared to prior methods. The approach achieves up to 100% robustness against state-of-the-art attacks with minimal utility degradation.

ABSTRACT

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.

Motivation & Objective

  • To address the high computational cost of discrete adversarial training in LLMs, which relies on expensive token-level perturbations like GCG.
  • To investigate whether robustness to continuous perturbations in the embedding space can generalize to discrete natural language attacks.
  • To develop efficient adversarial training algorithms that maintain model utility while improving robustness.
  • To identify and correct flawed evaluation protocols that overfit safety objectives and harm model helpfulness.
  • To reduce the carbon footprint of training robust LLMs by minimizing compute requirements.

Proposed method

  • C-AdvUL combines adversarial training on a harmful behavior dataset using continuous attacks in the embedding space with fine-tuning on a utility dataset to preserve helpfulness.
  • The continuous attack is computed by optimizing perturbations in the embedding space, which is significantly faster than discrete token-level search methods like GCG.
  • C-AdvIPO is an adversarial variant of IPO that integrates robustness and alignment without requiring a separate utility dataset.
  • The method uses a dual-loss objective: one for robustness against continuous attacks and one for alignment or utility, depending on the variant.
  • Hyperparameters such as the attack magnitude (ε) and the IPO weighting (β) are tuned to balance robustness and utility.
  • The evaluation protocol is revised to include the chat template in both safety and utility evaluations, preventing overfitting to the safety objective.
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
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

Experimental results

Research questions

  • RQ1Can robustness to continuous attacks in the embedding space generalize to discrete natural language attacks such as suffix and jailbreaking attacks?
  • RQ2Can continuous adversarial training achieve comparable or better robustness than discrete adversarial training while reducing computational cost?
  • RQ3Does the use of continuous attacks in adversarial training lead to overfitting to the safety objective, causing refusal of benign inputs?
  • RQ4Can adversarial alignment be achieved without a separate utility dataset, as in C-AdvIPO?
  • RQ5How do hyperparameters like ε and β affect the robustness-utility trade-off in continuous adversarial training?

Key findings

  • C-AdvUL and C-AdvIPO achieve up to 100% robustness against GCG, AutoDAN, and PAIR attacks across multiple LLMs (Gemma, Phi3, Mistral, Zephyr) at 2B–7B parameter scales.
  • The models trained with C-AdvUL and C-AdvIPO show significantly fewer refusals on benign inputs compared to R2D2, which overfits the safety objective and grammar of the harmful dataset.
  • A strong Pearson correlation (r = 0.99, p = 0.0075) is observed between continuous attack loss and GCG loss, indicating that robustness to continuous attacks predicts robustness to discrete attacks.
  • C-AdvUL reduces computational cost by at least 299× compared to R2D2, making adversarial training scalable for LLMs.
  • The robustness-utility trade-off is intuitive: larger ε values and smaller β values increase robustness but slightly reduce utility, as expected.
  • The study identifies a critical flaw in prior evaluation protocols: testing safety with the chat template but utility without it leads to misleading results and overfitting.
(a) Gemma
(a) Gemma

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.