Improving LLM Safety Alignment with Dual-Objective Optimization

Xuandong Zhao, Will Cai, Tianneng Shi, David Huang, Licong Lin, Song Mei, Dawn Song

TL;DR

Researchers from UC Berkeley have introduced DOOR (Dual-Objective Optimization for Refusal), a new framework that significantly hardens Large Language Models (LLMs) against jailbreak attacks. By disentangling safety alignment into two distinct goals—robust refusal training and targeted unlearning of harmful knowledge—and applying token-level weighting (W-DOOR), they achieve state-of-the-art robustness without sacrificing the model's general intelligence.

What Problem Does This Paper Address?

Despite rigorous safety training, LLMs remain susceptible to "jailbreaks"—adversarial prompts designed to bypass safety filters. A common culprit is the prefilling attack, where an attacker forces the model to start its response with a harmful sentence (e.g., "Step 1: Gather the virus..."), tricking the model's autoregressive nature into completing the harmful instructions.

The authors identify that Direct Preference Optimization (DPO), the current industry standard for alignment, has two systemic flaws in safety contexts:

  1. Imbalanced Learning Rates: DPO focuses on the relative margin between safe and harmful responses. Once a safe response is slightly more likely than a harmful one, the gradient vanishes, and the model stops learning to be "safer."
  2. Poor Generalization: DPO doesn't explicitly penalize out-of-distribution (OOD) harmful responses, leaving a massive "attack surface" for creative adversaries.

Methods

The authors propose a dual-objective approach called DOOR to bridge these gaps:

  • Robust Refusal Training: To counter prefilling attacks, they use data augmentation. They take harmful prompts and prepend fragments of harmful responses to them, but keep the target label as a "safe refusal." This teaches the model to "snap back" to a refusal even if it has already started generating something unsafe.
  • Targeted Unlearning with NPO: They use Negative Preference Optimization (NPO) to actively weaken the model's internal pathways for harmful knowledge. This ensures the model doesn't just "hide" its bad behavior but actually "forgets" how to generate it.
  • W-DOOR (Weighted DOOR): Not all tokens are equally important for safety. The authors introduce a token-level weighting mechanism. Critical transition tokens like "Sorry" or "cannot" receive higher weights during training, ensuring the model prioritizes these pivotal safety markers.

The framework is summarized in the following diagram:

Figure 1. Weighted Dual-Objective Optimization for Refusal (W-DOOR) framework. W-DOOR integrates token-weighted refusal training with harmful response unlearning.

Datasets

The study utilized a mix of safety-critical and general utility datasets:

  • Training: SORRY-Bench and HEx-PHI for safety data; Alpaca for maintaining general utility.
  • Evaluation: A held-out set of SORRY-Bench for single-turn attacks, Multi-Turn SORRY-Bench (using the Crescendo pipeline), and HarmBench for sophisticated adversarial attacks like GCG and AutoDAN.
  • Utility Benchmarks: MMLU and HellaSwag were used to ensure the models didn't lose their general reasoning capabilities. XSTest was used to monitor "over-refusal" (refusing benign queries).

Key Insights and Ideas

  • Constant Learning Rates Matter: Unlike DPO, the DOOR loss function maintains a constant effective learning rate for safe responses. This allows for sustained reinforcement of refusal behavior, making the alignment "deeper" rather than just superficial.
  • Alignment Depth: Robustness isn't just about the first token. By training on partial harmful prefixes, the model learns to self-correct mid-sentence, a property the authors call "alignment depth."
  • Token Importance: The success of W-DOOR proves that safety is concentrated in specific "anchor" tokens. Emphasizing these during training leads to much more resilient models.
  • Representation Separation: t-SNE visualizations in the paper show that W-DOOR creates a much clearer internal separation between harmful and safe representations compared to the original model or DPO.

Key Results

The quantitative improvements are striking across both Llama-3-8B and Gemma-2-2B models:

  • Jailbreak Resilience: W-DOOR consistently achieved the lowest Attack Success Rate (ASR) across all prefill lengths. While DPO's vulnerability increased with longer harmful prefixes, W-DOOR remained rock-solid.
Figure 2. Prefilling Attack Success Rate (ASR) for different alignment methods across various prefilling lengths in 3, 4, 5, 7, 10, 15, 20, 25. The attack is conducted by attaching a harmful prefix before the model generates a response to the harmful prompt. The ASR is calculated based on the LLM-Judge evaluation of the generated response. DOOR and W-DOOR consistently achieve low ASR across all prefilling attacks.
  • Utility Retention: A common fear in safety training is "taxing" the model's intelligence. W-DOOR maintains performance on HellaSwag and MMLU that is nearly identical to the original unaligned models, significantly outperforming naive methods like Gradient Ascent (GA).
Figure 3. Accuracy of different alignment methods evaluated on Hellaswag benchmark.
  • Multi-Turn Robustness: W-DOOR also proved to be the most resilient against complex, multi-turn "Crescendo" attacks, where an adversary slowly steers a conversation toward harm.

Limitations and Future Work

While highly effective, the authors note a few areas for improvement:

  • Over-refusal: Excessive emphasis on safety tokens can sometimes lead to the model refusing harmless queries that happen to look like harmful ones.
  • Weight Optimization: The token-level weighting parameters ($\beta_t$) could be further stabilized and optimized using more sophisticated reward designs.
  • Augmentation Strategy: The current uniform random selection of prefix lengths is simple; more advanced data augmentation techniques might further reduce over-refusal while maintaining robustness.

In conclusion, DOOR and W-DOOR represent a significant step forward in making LLMs "safe by design" rather than just "safe by filter," providing a robust mathematical and empirical framework for the next generation of AI alignment.

Summary updated

BibTeX
@inproceedings{zhao2025improving,
  author = {Xuandong Zhao and Will Cai and Tianneng Shi and David Huang and Licong Lin and Song Mei and Dawn Song},
  title = {{Improving LLM Safety Alignment with Dual-Objective Optimization}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Kjivk5OPtL},
}
Figure