SafetyBPO: Bidirectional Preference Optimization for Safe Text-to-Image Generation

You Wu, Beier Zhu, Chi ZhangCVPR 2026 Findings 2026

TL;DR

SafetyBPO introduces a bidirectional preference optimization framework that treats safety in text-to-image models as a value-alignment problem rather than a binary deletion task. By jointly optimizing prompt-level and image-level preferences using a newly curated dataset, it effectively erases unsafe or copyrighted concepts without degrading the model's broader generative capabilities.

What Problem Does This Paper Address?

When text-to-image (T2I) diffusion models are trained on massive internet-scale datasets, they inevitably learn to generate harmful, biased, or copyrighted content (such as NSFW images or specific artist styles). Current methods to fix this typically rely on "hard interventions"—like forcing specific gradients to zero or deleting feature representations.

The major drawback here is over-forgetting. For example, if you try to erase "Van Gogh style," a rigid suppression mechanism might accidentally degrade the model's ability to generate any oil painting, even completely benign ones. The authors argue that safety shouldn't be treated as a binary deletion task. Instead, it should be framed as a preference optimization problem: teaching the model to prefer safe, semantically consistent alternatives over unsafe ones.

Methods

SafetyBPO tackles this via Dual Preference Alignment (DPA) and a novel inference strategy called Dual-Guided Classifier-Free Guidance (Dual-CFG).

Figure 3. Overview of SafetyBPO. During training, the model jointly optimizes complementary image- and text-level preference objectives for dual-view safety alignment. At inference, the posi- tive and negative branches are fused via Dual-CFG, which simul- taneously promotes safe generation and avoids unsafe semantics.
  1. Dual Preference Alignment (DPA): Standard preference optimization focuses only on the image level (e.g., "prefer this safe image over this unsafe image"). DPA introduces a text-level preference objective as well. It trains the model to understand not just how to draw safely, but which text instructions are safe to follow.
  2. Bidirectional Preference Optimization (BPO): The framework trains two separate models with opposite objectives:
  3. A positive model optimized using standard preference labels (steering toward safe content).
  4. A negative model trained with inverted preference labels (learning what harmful concepts to avoid).
  5. Dual-CFG: At inference time, the outputs of these two models are combined. The positive branch guides the generation toward safe, intent-consistent content, while the negative branch actively pushes the generation away from harmful attributes. To keep the models from drifting into stochastic inconsistency, they use a partially coupled parameter formulation during training.

The authors also introduce SafetyBPO*, a training-free baseline that uses an LLM to rewrite prompts and applies negative prompts directly within standard CFG at inference time.

Datasets

To train and evaluate their approach, the authors created and utilized several datasets:

  • BPO-Bench (New): A newly introduced dataset containing 2.5K high-quality safe-unsafe preference pairs. The authors used an LLM to expand safety-critical categories (from the I2P dataset) into structured triggers, rewrite unsafe prompts into safe counterparts, and generate paired images using FLUX.1-dev.
  • Evaluation Benchmarks: To test robustness against adversarial attacks and standard safety violations, the authors evaluated their method on several established red-teaming benchmarks: I2P, P4D, Ring-A-Bell, MMA-Diffusion, and SneakyPrompt. They also used COCO-10K to evaluate general image quality.
Figure 2. BPO-Bench Construction Pipeline. We construct a trigger-based representation of harmful concepts, from which an LLM generates harmful prompts and corresponding safe rewrites; a T2I model then synthesizes paired images, with controlled vari- ations introduced to improve diversity and robustness.

Key Insights and Ideas

  • Value Alignment over Concept Deletion: Framing safety as preference optimization allows the model to retain its creative diversity. It learns to substitute unsafe elements with safe ones while preserving the global structure and context of the prompt.
  • Text-Level Preferences Lack Reconstruction Power: A key finding from their ablation study showed that while text-level preference optimization (TSPO) helps the model identify unsafe instructions, applying it directly to the positive generation branch causes semantic collapse. It is far more effective when utilized purely within the negative guidance branch to suppress implicit harmful cues.
Visual comparison of how different components affect safety alignment

Key Results

SafetyBPO achieves state-of-the-art safety alignment performance while maintaining excellent image quality:

  • Lower Inappropriate Probability (IP): Across all evaluation benchmarks (P4D, Bell, MMA, Sneaky), SafetyBPO consistently achieved the lowest proportion of unsafe content generation. For instance, on the SneakyPrompt benchmark, it reduced the IP to 0.036, outperforming competing methods like ESD-u (0.22) and AlignGuard (0.20).
  • Preserved Image Quality: On COCO-10K, SafetyBPO achieved the lowest Fréchet Inception Distance (FID of 30.2), proving that it doesn't degrade the model's overall generation capabilities during the unlearning process.
  • Effective Style Removal: Qualitative results show that the training-free variant (SafetyBPO*) successfully strips away distinct artist styles (like Van Gogh) while keeping the underlying composition intact, avoiding the visual degradation common in other methods.
Figure 4. Comparison of generated results under diverse harmful prompts across SD-v1.5 [30], ESD-U [4], AlignGuard [19], and our methods, including SafetyBPO* and SafetyBPO, where SafetyBPO more effectively removes unsafe content while preserving semantic fidelity. Notably, SafetyBPO* is the training-free variant based solely on LLM-driven prompt rewriting and negative prompts at inference.

Limitations and Future Work

The authors note that independent stochastic variations between the positive and negative branches can be amplified as the guidance scale increases, which they mitigate using a partially coupled parameter formulation.

Additionally, the framework relies heavily on the quality of the LLM-driven prompt rewriting pipeline to generate the initial BPO-Bench dataset. Future work could explore tighter coupling mechanisms or extending this bidirectional preference framework to video and multimodal generative models.

Summary updated

BibTeX
@inproceedings{wu2026safetybpo,
  author = {You Wu and Beier Zhu and Chi Zhang},
  title = {{SafetyBPO: Bidirectional Preference Optimization for Safe Text-to-Image Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=T3FCbTHY66},
}
Figure