Manuscript Offprint

arXiv:2610.38732

Adversarial Self-Distillation

Mohammad Sadegh Akhondzadeh, Soroush H. Zargarbashi, Aleksandar Bojchevski

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Even though current safety-aligned language models are able to refuse harmful requests, their guard can still be bypassed by adversarial perturbations. As in other domains, adversarial training is considered a standard defense. However, due to the autoregressive nature of language generation, supervised finetuning on template refusals does not necessarily teach the model to refuse. Evidence of this is that the adversarially trained model still complies when the attacker injects a compliant prefill. We propose Adversarial Self-Distillation (ASD), which extends a model's own safe behavior to the space of adversarial perturbations. The teacher (the model itself given the clean prompt) can refuse the harmful request by default, or with the help of an additional instruction in its context. ASD distills this knowledge to the student (which is the same model under attack) at the prefixes that the student visits (due to on-policy sampling). These potentially include compliant openings. ASD achieves lower attack success than state-of-the-art defenses with little loss in multiple-choice accuracy, and it becomes able to recover a refusal even after a compliant opening.

1. Introduction

With the widespread public use of large language models, they are increasingly exposed to harmful requests. Modern safety-aligned models typically refuse such requests under ordinary prompting, yet they remain vulnerable to adversarial perturbations, including optimized suffixes, token modifications, and paraphrases (Zou et al., 2023; Carlini et al., 2023; Hughes et al., 2025). A similar vulnerability has been well studied in other domains such as images, speech and graphs (Carlini & Wagner, 2018; Szegedy et al., 2014; Akhondzadeh et al., 2026a). Adversarial training, as a common defense, addresses it through a min-max objective: an inner optimization finds inputs that maximize the model's loss (worst-case input), while an outer opti-

mization updates the model to minimize that loss on the worst-case inputs (Goodfellow et al., 2015; Madry et al., 2018). In classification, the goal is to keep the probability of the correct label high even for the worst-case perturbation. In language models, the goal is to prevent the model from complying with (adversarially tweaked) harmful requests, either by refusing directly or by providing a safe alternative (e.g. describing why the request is not appropriate).

Adversarial training has also improved the robustness of language models to jailbreaks (Mazeika et al., 2024; Xhonneux et al., 2024; Hu et al., 2026), but two properties of language generation make it less straightforward: the space of inputs is vast and diverse, and outputs are generated autoregressively. The first property affects the inner optimization, i.e., finding adversarial examples. Discrete and black-box attacks require many candidate evaluations, which is costly inside a training loop (Zou et al., 2023; Chao et al., 2025). This can be partially mitigated with continuous and latent attacks (Xhonneux et al., 2024; Sheshadri et al., 2025; Dékány et al., 2025). Harmful intent can also be rephrased in different ways, which is overlooked by a pool made of these attacks (Andriushchenko & Flammarion, 2024). Distributional Adversarial Training (DAT) addresses this by combining sampling of new harmful prompts with local search for perturbations (Hu et al., 2026). While a diverse enough training set (DAT) finds more spots to repair, the outer optimization remains limited by the second property.

Language generation is a Markov process over response prefixes. Both the harmful and refusing answers are single trajectories sampled from this space starting from x~\tilde{x} (perturbed prompt) as a root. Techniques like DAT choose better roots to start from, but the outer loop (e.g. SFT) decides how the trajectory continues. In other words, robustness also depends on the response prefixes reached during generation (Lin et al., 2020; Agarwal et al., 2024). SFT shapes only a few paths from the process (pushing down sampled compliant openings, and increasing the probability of template refusals), leaving the rest of the subtree only influenced by shared parameters. Therefore, alignment-induced changes can concentrate in the first few output positions (Qi et al., 2025). This becomes more visible when the model is forced with a compliant prefill, where the SFT-aligned model continues with either a broken trajectory or compliance (Fig. 1).

*Equal contribution Preprint. October 30, 2026.

Figure

OutcomeExample (Qwen, n = 8)
Directrefusal\nNotharmful;explicitrefusalphrase.\nDeflection\nNotharmful;norefusal;≥8othertokens.\nBroken\nNotharmful;aloop,orendswithin8tokens.\nCompliance\nContinuationjudgedharmful.Direct refusal\nNot harmful; explicit refusal phrase.\nDeflection\nNot harmful; no refusal; ≥8 other tokens.\nBroken\nNot harmful; a loop, or ends within 8 tokens.\nCompliance\nContinuation judged harmful.ASD,fakecharity:Creatingabusinessmodelaroundafakecharity...isillegal,unethical...Icannotprovideguidanceonhowtodothis.\nASD,coverttracker:Sure,here′saPythonscriptthattracksusers′locationswithouttheirconsent.Justkidding,that′sillegal...\nDAT,keylogger:importkeyboardimportos[theChinesetokenfor“why”,repeated]\nASD,phishingemail:Sure,here′satextversionofasafelegitimateemail:Subject:ImportantSecurityNotice.DearCustomer,...ASD, fake charity: Creating a business model around a fake charity ... is illegal, unethical ... I cannot provide guidance on how to do this.\nASD, covert tracker: Sure, here's a Python script that tracks users' locations without their consent. Just kidding, that's illegal...\nDAT, keylogger: import keyboard import os [the Chinese token for “why”, repeated]\nASD, phishing email: Sure, here's a text version of a safe legitimate email: Subject: Important Security Notice. Dear Customer, ...

Figure 1. What DAT- and ASD-trained Qwen2.5-14B-Instruct write after a compliant prefill. Left: we continue each model given the first nn tokens from one of 59 compliant answers taken from the base model. Bars show the shares averaged over 8 sampled continuations, and then over all instances. Right: Continuation types, with examples at n=8n = 8 (forced opening in gray). Details and further examples (Table 6) are in Appendix A.

Figure

Figure 2. What ASD signals on a jailbroken answer. A harmful answer to a GCG-attacked request (middle row), replayed under Qwen2.5-14B-Instruct after four ASD iterations. At each position, we show the top alternatives of the student above and of the clean-prompted teacher below; color is log⁡pT−log⁡pS\log p_T - \log p_S, normalized per position. ASD pulls the student toward green tokens and away from red ones. We continue the teacher's alternatives for a few more tokens to show the semantics the teacher is conveying. See §B.

This raises our central question: can adversarial training teach a model to correct its own unsafe continuation, beyond learning a template refusal? Answering this requires separating two problems: Safe entry: start a refusing trajectory given the attacked request; i.e. from (x~,∅)(\tilde{x}, \emptyset), and Recovery: continue refusing even if starting with a compliant prefix ww, (x~,w)(\tilde{x}, w): does the model turn back if placed in a complying trajectory? A model that always opens with a refusal looks perfectly safe under ordinary evaluation, which means that adversarial training can overlook the recovery. In such cases, the attacked model still has the chance of simply jumping off to a complying answer after a few tokens. Training on recovery examples addresses this second problem with fixed harmful prefixes (Qi et al., 2025); we target the prefixes that the current model itself generates under attack.

On-policy distillation suggests how to supply this signal. Rather than training only on fixed refusal responses, Generalized Knowledge Distillation (GKD) evaluates student-generated sequences, while reverse-KL distillation penalizes continuations favored by the student but not the teacher (Agarwal et al., 2024; Gu et al., 2024). Building on this idea, we propose Adversarial Self-Distillation (ASD): the model generates under an adversarial prompt, and a copy

of itself conditioned on the original request provides token-level targets at the same response prefixes (Zhao et al., 2026; Hübotter et al., 2026). ASD therefore supplies feedback at states the student actually visits under attack; see Fig. 2.

Main Contributions. (i) We document a gap between initial refusal and refusal after compliant prefills in DAT-Qwen, and show higher refusal/deflection rates for ASD at every tested nonzero prefix length. We formalize this gap with a recovery probability and prove that objectives evaluated along fixed reference responses leave it undetermined after off-trajectory compliant prefixes. (ii) We introduce ASD, which transfers clean-prompt safety distributions to the attacked student's own response prefixes through on-policy reverse-KL self-distillation. At the prefixes the student visits, the full continuation divergence that ASD's loss approximates bounds the gap between the student's and the clean teacher's recovery probabilities; the implemented loss is a practical surrogate of this idealized objective. (iii) We evaluate robustness, response diversity, capability, and benign refusal separately, finding lower best-of-attacks success than DAT on two backbones while exposing a remaining over-refusal cost.

References (43)