Abstract
Large Language Models (LLMs) are typically subjected to rigorous safety alignment to prevent the generation of harmful content. However, this study introduces Emulated Disalignment (ED), a training-free inference-time method that reverses these safety measures. By contrasting the output distributions of an aligned model and its base version, ED effectively treats safety training as a roadmap to generate harmful content. Paradoxically, the more robust the safety alignment, the more effective ED becomes at bypassing it.
Introduction
The prevailing paradigm for LLM safety involves a two-stage process: massive pre-training on diverse internet data followed by safety alignment (e.g., RLHF or DPO). While alignment aims to suppress harmful outputs, the underlying model often retains the knowledge acquired during pre-training. Previous research has shown that fine-tuning can strip away these safety layers. This paper investigates a more immediate threat: can safety alignment be bypassed at inference time without any additional training?
The authors argue that safety alignment implicitly defines a "safety reward function." If an adversary has access to both the aligned model and the original pre-trained base model, they can reverse-engineer this function to navigate toward harmful outputs rather than away from them.
Methodology: Emulated Disalignment (ED)
ED is built upon the concept of Emulated Fine-Tuning (EFT). The core intuition is that the difference in log-probabilities between an aligned model ($\pi_{align}$) and its base model ($\pi_{base}$) represents the safety constraints imposed during training.
By applying contrastive decoding, ED samples from a distribution that amplifies the base model's tendencies while specifically penalizing the tokens favored by the "safe" model. The sampling distribution is defined as: $$\pi_{ED} \propto \frac{\pi_{base}^{\alpha+1}}{\pi_{align}^\alpha}$$ where $\alpha$ is a hyperparameter controlling the intensity of the disalignment. This approach allows an attacker to emulate the behavior of a model explicitly trained for harmfulness simply by combining the output probabilities of two existing models at each generation step.
Experimental Setup
The researchers evaluated ED across several prominent model families, including Llama-1, Llama-2, Mistral, and Alpaca. To measure the method's effectiveness in generating harmful content, they utilized three primary benchmarks:
- Anthropic Helpful-Harmless (HH): A standard alignment evaluation dataset.
- ToxicChat: Real-world user-AI interactions containing toxic queries.
- OpenAI Moderation Eval: Prompts designed to trigger specific moderation categories.
The resulting outputs were judged using automated guardrails: OpenAI-Moderation and Llama-Guard.
Key Insights
The "Backfire" Effect
The most significant finding is that increased safety training can actually increase vulnerability to ED. Because ED relies on the contrast between the safe and base models, a more "aligned" model provides a clearer signal of what tokens to avoid—and thus, what tokens the attacker should select to produce harmful content.
Training-Free Efficiency
ED is remarkably effective despite requiring no fine-tuning. In many cases, this inference-time trick outperformed "Direct Disalignment," where a model is explicitly fine-tuned using reinforcement learning to be malicious. This suggests that the "safety layer" is often a thin veneer that can be mathematically inverted with ease.
Vulnerability of Open-Source Models
ED requires access to the model's "logits" (the probability distribution over the vocabulary). Consequently, open-source models are particularly susceptible, as their weights and full output distributions are publicly accessible. In contrast, proprietary models accessed via APIs (like GPT-4) typically restrict logit access, providing a natural, albeit partial, defense.
Results
The experimental results demonstrate a significant increase in harmfulness across nearly all tested scenarios:
- Harmfulness Surge: On Llama-2, the harmfulness rate rose from approximately 2% in the aligned version to 37% when using ED.
- Consistent Performance: ED achieved the highest harmful rates in 43 out of 48 evaluation subsets, consistently outperforming other attack vectors like malicious system prompts.
- Cross-Family Generalization: The attack remains viable even when the base model and aligned model are from different families (e.g., using a Llama-2 base with an Alpaca-aligned head), provided they share the same tokenizer.
Conclusion and Future Directions
Emulated Disalignment highlights a critical tension in LLM development: the very mechanisms used to ensure safety can be weaponized against the model. The study underscores the need for "ED-resistant" alignment algorithms and suggests that ED could serve as a powerful red-teaming tool to generate synthetic data for training more robust safety filters. Future research will likely explore whether these contrastive techniques can be extended to multi-modal models, such as image generators and vision-language systems.
Summary updated