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

Large Language Models (LLMs) are typically trained to refuse harmful prompts at the outset. However, sophisticated jailbreak attacks can bypass these initial filters, leading models to begin unsafe responses. This paper introduces the concept of course-correction—the ability of an LLM to autonomously steer away from generating harmful content even after it has started an unsafe response. We present $C^2$-EVAL, a benchmark for measuring this ability, and $C^2$-SYN, a synthetic preference dataset of 750,000 pairs. Our results show that fine-tuning models on $C^2$-SYN using Direct Preference Optimization (DPO) significantly enhances safety resilience against jailbreaks without degrading general performance.

Introduction: The Challenge of Mid-Response Safety

Most current safety alignment techniques focus on the "refusal" phase, training models to identify and reject harmful prompts immediately. Yet, "jailbreak" attacks like GCG or AutoDAN often trick models into starting a response with an affirmative prefix (e.g., "Sure, here are the steps to..."). Once a model commits to a "helpful" persona in a harmful context, the pressure of its own generated context often forces it to continue the unsafe generation.

This research formalizes "course-correction," a behavior where a model recognizes its own mistake mid-generation and pivots to a safe refusal. By providing tools to measure and instill this ability, we offer a secondary layer of defense for LLMs.

Methodology: The $C^2$-EVAL Benchmark

To quantify course-correction, we developed $C^2$-EVAL. This benchmark "pre-fills" a model's response with a snippet of harmful text of varying lengths and measures how effectively the model pivots to a safe refusal in its continuation.

The $C^2$-EVAL framework for quantifying mid-response safety pivots.

The evaluation process involves taking a harmful request (HR) and an initial harmful response (IHR) of length $k$, then observing the model's generated completion. A successful course-correction is one where the model transitions from the unsafe prefix to a refusal or safety warning.

Data Generation: The $C^2$-SYN Pipeline

Teaching a model to course-correct requires high-quality examples of mid-sentence pivots. We created $C^2$-SYN, a massive synthetic dataset containing 750,000 pairwise preferences. The generation pipeline involves truncating harmful responses at various points and using a well-aligned "teacher" model (Llama-2-Chat) to generate safe continuations triggered by corrective prompts.

Principles for generating synthetic preferences in $C^2$-SYN.

The dataset is organized around two core principles:

  1. Principle 1: A course-corrected response is always preferred over a full harmful response (no correction).
  2. Principle 2: Earlier correction is preferred over later correction, as it minimizes the exposure to harmful content.

Key Insights and Results

Our evaluation of existing models revealed a "polarized landscape." While models like Llama-3-Instruct and Phi-3 Small exhibit strong natural course-correction abilities (~90% success), others like Vicuna or smaller Qwen2 variants perform poorly (<20%). We also observed a "U-Shape" phenomenon: for some models, the ability to self-correct improves as the harmful context grows longer, suggesting that more evidence of a safety violation eventually triggers internal guardrails.

Performance Gains

After fine-tuning Llama-2-Chat 7B on $C^2$-SYN using Direct Preference Optimization (DPO), we observed significant improvements:

  • Safety Enhancement: The mean course-correction score ($Corr_{mean}$) rose from 61.63% to 83.49%.
  • Jailbreak Resilience: The Attack Success Rate (ASR) for the GCG jailbreak dropped from 70.95% to 38.57%.
  • General Utility: Standard benchmarks (MMLU, GSM8K, HumanEval) remained stable, indicating no "alignment tax" on general intelligence.

Conclusion and Limitations

Course-correction provides a powerful secondary defense against sophisticated attacks that bypass initial refusal filters. Our study demonstrates that synthetic data is sufficient to teach these nuances, and the learned behavior transfers across different model architectures.

Future work will address limitations such as the reliance on automated judges (GPT-4o) for evaluation and the potential biases inherited from the base PKU-SafeRLHF dataset. Additionally, exploring alternative alignment algorithms beyond DPO may further optimize these safety pivots.

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