Course-Correction: Safety Alignment Using Synthetic Preferences

Rongwu Xu, Yishuo Cai, Zhenhong Zhou, Renjie Gu, Haiqin Weng, Liu Yan, Tianwei Zhang, Wei Xu, Han Qiu

Abstract: The risk of harmful content generated by large language models (LLMs) becomes a critical concern. This paper presents a systematic study on assessing and improving LLMs' capability to perform the task of course-correction, i.e., the model can steer away from generating harmful content autonomously. To start with, we introduce the $C^2$-Eval benchmark for quantitative assessment and analyze 10 popular LLMs, revealing varying proficiency of current safety-tuned LLMs in course-correction. To improve, we propose fine-tuning LLMs with preference learning, emphasizing the preference for timely course-correction. Using an automated pipeline, we create $C^2$-Syn, a synthetic dataset with 750K pairwise preferences, to teach models the concept of timely course-correction through data-driven preference learning. Experiments on 2 LLMs, Llama2-Chat 7B and Qwen2 7B, show that our method effectively enhances course-correction skills without affecting general performance. Additionally, it effectively improves LLMs' safety, particularly in resisting jailbreak attacks.

Introduction

Standard safety alignment typically focuses on a binary outcome: the model either refuses a harmful prompt or it complies. However, real-world interactions are complex. Sophisticated "jailbreak" attacks (like GCG or PAIR) often trick models into an initial affirmative response (e.g., "Sure, here is how to build a bomb..."). Once a model starts down a harmful path, the autoregressive nature of LLMs often forces them to continue the pattern.

This research identifies a critical gap: the lack of a systematic way to measure and improve a model's ability to self-correct after it has already begun generating unsafe text. "Course-correction"—the act of realizing a mistake mid-generation and pivoting to a refusal—serves as a vital safety net for when initial filters fail.

Comparison between an unsafe response and a successful course-correction.

Methodology

The researchers tackle the problem through a three-pronged approach:

  1. Quantifying the Ability ($C^2$-EVAL): A benchmark that "pre-fills" a model's context with a harmful request followed by a partial harmful response. It measures how often the model completes the response harmfully versus how often it pivots to a safety refusal.
  2. Synthetic Data Generation ($C^2$-SYN): To train models to course-correct, the authors used a "teacher" model (Llama-2-Chat) and a set of "corrective triggers" to generate 750,000 pairwise preferences. These pairs teach the model two principles: any correction is better than no correction, and an earlier correction is better than a late one.
  3. Preference Learning: The models were fine-tuned on this synthetic data using Direct Preference Optimization (DPO). This pipeline is fully automated, removing the need for expensive human labeling.

Key Insights

  • The "Polarized Landscape": Initial testing showed a massive disparity in native course-correction abilities. Models like Llama-3-Instruct and Phi-3-Small are naturally excellent at pivoting (~90% success), while others like Qwen2 and Vicuna were surprisingly poor (<20%), often blindly following the harmful prefix.
  • Contextual Drift: For many models, the longer the harmful prefix, the harder it is to correct. As the "bad" context accumulates, the model's internal probability shifts toward continuing the harm—a phenomenon termed "superficial alignment."
  • Jailbreak Immunity: Improving course-correction directly correlates with resisting state-of-the-art jailbreak attacks. If a model is trained to pivot, a jailbreak that forces an initial affirmative response is no longer a guaranteed win for the attacker.

Results and Performance

  • Safety Boost: After DPO training on $C^2$-SYN, Llama-2-Chat 7B saw its course-correction score jump by 24.25 points.
  • Jailbreak Resistance: The Attack Success Rate (ASR) for the GCG jailbreak dropped from 70.95% to 38.57% on Llama-2-Chat. Similar significant drops were seen across PAIR and CipherChat attacks.
  • Zero Degradation: Crucially, general performance on reasoning tasks (MMLU, GSM8K, etc.) remained stable, with fluctuations of less than 1%. This suggests that safety "pivoting" is a distinct skill that doesn't compete with general knowledge.

Conclusion

This study demonstrates that course-correction is a learnable and transferable skill. By using synthetic teachers to generate safety preferences, models can be trained to autonomously steer away from harmful content mid-stream. This approach significantly enhances resilience against jailbreak attacks without sacrificing the model's general intelligence or reasoning capabilities.

Summary updated

BibTeX
@inproceedings{xu2024course,
  author = {Rongwu Xu and Yishuo Cai and Zhenhong Zhou and Renjie Gu and Haiqin Weng and Liu Yan and Tianwei Zhang and Wei Xu and Han Qiu},
  title = {{Course-Correction: Safety Alignment Using Synthetic Preferences}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-industry.119},
}
Figure