Papers › Efficient Adversarial Training in LLMs with Continuous Attacks

Efficient Adversarial Training in LLMs with Continuous Attacks

24 May 2024arXiv:2405.15589archive 2025-07-28

Sophie Xhonneux, Alessandro Sordoni, Stephan Günnemann, Gauthier Gidel, Leo Schwinn

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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2405.15589")

Code

Syntology Ran 7 of 10 code samples harvested from 1 repository linked to this paper; 3 have no recorded run. Of those that ran: 7 ran with no contract checked.

By repository: official repository: 10 samples from 1 repository, 7 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

sophie-xhonneux/continuous-advtrain officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 7 ran; 0 honoured the contract we drafted; 3 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

7ran
3unverified

Licence: 0 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from sophie-xhonneux/continuous-advtrain. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

flatten_dict sophie-xhonneux/continuous-advtrain/src/database_handling.py official repository ran MIT (permissive) · 15be2e56e073a228 · report
get_chat_template sophie-xhonneux/continuous-advtrain/src/model_utils.py official repository ran MIT (permissive) · 780c913ff9f68d7b · report
get_dataset_id sophie-xhonneux/continuous-advtrain/src/data.py official repository ran MIT (permissive) · afa643eee62ab913 · report
get_dpo_loss sophie-xhonneux/continuous-advtrain/src/adversarial_training.py official repository ran MIT (permissive) · 68d78c403eece7f7 · report
load_checkpoint sophie-xhonneux/continuous-advtrain/src/model_utils.py official repository ran MIT (permissive) · 711d5028382d4919 · report
load_specific_dataset sophie-xhonneux/continuous-advtrain/src/data.py official repository ran MIT (permissive) · e92c968a55357248 · report
log_1_minus_p_loss sophie-xhonneux/continuous-advtrain/src/adversarial_training.py official repository ran MIT (permissive) · b5c7e326ac7ad2ed · report
acquireLock sophie-xhonneux/continuous-advtrain/src/run_experiments.py official repository unverified MIT (permissive) · dfef7ce9fc6e4f99 · report
init_experiment sophie-xhonneux/continuous-advtrain/src/database_handling.py official repository unverified MIT (permissive) · 61ad493f36ea49b1 · report
load_model_and_tokenizer sophie-xhonneux/continuous-advtrain/src/model_utils.py official repository unverified MIT (permissive) · 06cd66993d331abf · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections