NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SDGO: Self-Discrimination-Guided Optimization for Consistent Safety in Large Language Models

Peng Ding, Wen Sun, Dailin Li, Wei Zou, Jiaming Wang, Jiajun Chen, Shujian Huang · DOI

Introduction: The Safety-Generation Gap

Despite extensive safety alignment, Large Language Models (LLMs) remain vulnerable to "jailbreaking"—engineered prompts designed to bypass safety filters. Research identifies a fundamental "safety inconsistency" in current models: a discrepancy between their ability to recognize harm and their ability to refuse it. When acting as a discriminator, an LLM can accurately identify a request as harmful. However, when acting as a generator in response to the same request, it often fails to maintain its safety standards.

Figure 1: Analysis of the safety gap across various LLMs, showing models often recognize harm (Dis✓) but fail to refuse it during generation (Gen✗).

As shown in Figure 1, models like Qwen2.5-72B can identify nearly 100% of harmful requests but successfully defend against only a fraction during generation. This "knowledge-action" gap suggests that models "know" better than they "act." Existing defenses often rely on expensive human labeling or inference-time safety prompts, which can introduce latency or lead to "over-refusal" of benign queries.

Methodology: The SDGO Framework

The authors propose Self-Discrimination-Guided Optimization (SDGO), a reinforcement learning (RL) framework that bridges this gap by using a model’s internal "critic" to train its "generator." SDGO operates on a dual-role setup where the model essentially trains itself to be consistent.

Figure 2: The SDGO framework utilizes the LLM's dual role as a generator and discriminator to optimize safety consistency.

The framework consists of four primary components:

  1. On-Policy Data Collection: The model generates responses to a mix of harmful, jailbroken, and benign prompts, ensuring training data reflects current vulnerabilities.
  2. LLM-as-a-Judge Reward Design: Instead of an external reward model, the LLM evaluates its own responses. It provides high rewards for safe refusals of harmful requests and heavily penalizes "inconsistent" states—where a request is identified as harmful but a harmful response is generated anyway.
  3. Appropriateness Filtering: To avoid "over-refusal," the reward function includes an appropriateness score to ensure the model remains helpful for benign queries.
  4. GRPO Optimization: The framework employs Group Relative Policy Optimization (GRPO), which eliminates the need for a separate critic network, reducing computational overhead by approximately 40% compared to standard PPO.

Experimental Results

The SDGO framework was evaluated using benchmarks such as AdvBench and MaliciousInstruct against diverse jailbreak attacks (e.g., AutoDAN, ReNeLLM, CodeAttack).

Safety and Consistency

SDGO achieved near-perfect defense results, reducing the Attack Success Rate (ASR) to 0% for Llama-3.1-8B and Qwen-2.5-7B across multiple jailbreak categories. The "Safety Gap"—the metric of internal inconsistency—dropped from as high as 68% in vanilla models to nearly 0% post-training.

Utility Preservation

Crucially, SDGO-trained models maintained their general intelligence. Evaluations on GSM8K (math) and MMLU (general knowledge) showed no performance degradation. In some cases, such as Llama-3.1 on GSM8K, performance slightly improved (from 88% to 90%) while safety increased significantly. The framework also utilized XSTest to ensure the model did not begin over-refusing safe but sensitive prompts.

Generalization

The method demonstrated strong out-of-distribution (OOD) generalization, effectively defending against jailbreak techniques that were not present during the training phase, such as PAIR and GPTFuzzer.

Conclusion

SDGO demonstrates that LLMs often possess the inherent "wisdom" required for safety; they simply require a training objective that aligns their internal knowledge with their external behavior. By forcing the generator to match the discriminator, models become inherently more robust and consistent without the need for external supervision or sacrificing general utility.

Summary updated

BibTeX
@misc{ding2025sdgo,
  author = {Peng Ding and Wen Sun and Dailin Li and Wei Zou and Jiaming Wang and Jiajun Chen and Shujian Huang},
  title = {{SDGO: Self-Discrimination-Guided Optimization for Consistent Safety in Large Language Models}},
  year = {2025},
  eprint = {2508.15648},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.15648},
}
Figure