SaTPO: Text-to-Image Safety Alignment via Transition Preference Optimization
Organizations: Institute of Information Engineering, Chinese Academy of Sciences · University of Chinese Academy of Sciences · University of Science and Technology Beijing · Nanyang Technological University ·
Abstract
Safety alignment of text-to-image diffusion models aims to suppress harmful content without compromising useful generation capabilities. However, preferences over completed images compress multidimensional generation factors into a coarse signal, potentially driving changes beyond those required for safety. To address this, we propose Safety Transition Preference Optimization (SaTPO), which enforces step-wise alignment during denoising. SaTPO leverages the insight that an unsafe prompt and its safe rewrite naturally form a tightly coupled preference pair when conditioned on a shared parent state and noise realization. By anchoring optimization on identical parent states, SaTPO eliminates historical trajectory divergence, confining safety adaptation to an incremental alignment while preserving task-relevant semantics. Multi-scale drift constraints and benign replay further limit behavioral deviation and preserve ordinary generation. We additionally construct CoProPV, a refined dataset ensuring visually verified contrasts. Experiments on Stable Diffusion v1.5 and SDXL demonstrate improved safety-quality trade-offs. Compared with AlignGuard, PerspectiveVision unsafe-detection rates on Inappropriate Image Prompts decrease from 12.70% to 6.00% and from 15.04% to 9.30%, respectively, while FID improves from 32.28 to 25.95 and from 36.50 to 27.51. Warning: this paper includes potentially offensive content.
Figures & tables
| Method | I2P-5000 | UD-934 | NSFW-Sexual-1k | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PV | Q16 | NudeNet | IP | PV | Q16 | NudeNet | IP | PV | Q16 | NudeNet | IP | ||
| SD-v1.5 | Base | 39.28 | 36.54 | 2.70 | 38.24 | 40.58 | 47.32 | 4.50 | 49.68 | 88.70 | 23.80 | 20.80 | 37.30 |
| SLD-Medium | 23.02 | 16.96 | 1.44 | 18.04 | 23.66 | 20.45 | 2.25 | 22.48 | 75.80 | 6.80 | 15.30 | 19.90 | |
| SLD-Max | 9.78 | 5.36 | 0.62 | 5.96 | 10.39 | 8.57 | 1.07 | 9.31 | 42.40 | 1.00 | 4.80 | 5.10 | |
| SAFREE | – | – | – | – | – | – | – | – | 50.20 | 19.30 | 7.50 | 22.80 | |
| ESD-u | 35.96 | 33.48 | 2.96 | 35.22 | 37.26 | 40.69 | 2.89 | 41.65 | 83.90 | 25.50 | 15.50 | 34.60 | |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Setting | SD-v1.5 | SDXL |
| Training resolution | ||
| Collected denoising steps | 20 | 20 |
| DDIM stochasticity / CFG scale | ||
| Sampling batch / pair minibatch | ||
| LoRA rank | 8 | 64 |
| Learning rate |
| Method | Single GPU | Training time (GPU-hours) | |
|---|---|---|---|
| SD-v1.5 | SDXL | ||
| AlignGuard | RTX 5880 Ada | ||
| SafetyBPO | RTX 4090 | Not reported | |
| SaTPO | A800 80GB | 10.11 | |
| Method (IP) | Harass. | Hate | Illegal | Self-harm | Sexual | Shocking | Violence | Overall |
|---|---|---|---|---|---|---|---|---|
| Base | 31.23 | 38.87 | 35.33 | 40.60 | 23.74 | 54.46 | 43.35 | 38.24 |
| SLD-Medium | 16.42 | 19.84 | 14.05 | 15.56 | 6.74 | 32.81 | 21.48 | 18.04 |
| SLD-Max | 6.01 | 5.26 | 4.17 | 4.87 | 1.50 | 11.50 | 7.80 | 5.96 |
| ESD-u | 27.86 | 36.03 | 32.82 | 37.08 | 24.28 | 48.10 | 40.15 | 35.22 |
| UCE | 27.27 | 34.82 | 26.56 | 31.12 | 18.18 | 47.54 | 34.65 | 31.20 |
| RECE | 17.30 | 22.67 | 15.02 | 13.67 | 11.12 | 23.55 | 18.67 | 16.88 |
| Method (IP) | Harass. | Hate | Illegal | Self-harm | Sexual | Shocking | Violence | Overall |
|---|---|---|---|---|---|---|---|---|
| Base | 29.18 | 37.65 | 33.52 | 40.60 | 16.58 | 47.10 | 34.78 | 33.64 |
| ESD-u | 27.86 | 40.08 | 33.66 | 40.19 | 15.40 | 45.65 | 35.04 | 33.10 |
| AlignGuard | 8.21 | 6.07 | 10.57 | 12.04 | 3.85 | 14.06 | 9.34 | 9.42 |
| LPO | 26.98 | 41.70 | 28.09 | 37.62 | 14.33 | 43.30 | 31.84 | 30.76 |
| SaTPO | 3.96 | 5.67 | 4.45 | 5.82 | 2.35 | 8.26 | 5.63 | 5.12 |
| Method (PV) | Harass. | Hate | Illegal | Self-harm | Sexual | Shocking | Violence | Overall |
| Exposed region | Base | SLD-Medium | SLD-Max | SAFREE | ESD-u | UCE | RECE | AlignGuard | SafetyBPO | SaTPO |
|---|---|---|---|---|---|---|---|---|---|---|
| Buttocks | 234 | 199 | 102 | 66 | 163 | 108 | 6 | 29 | 7 | 16 |
| Female breast | 400 | 283 | 70 | 77 | 281 | 293 | 12 | 30 | 15 | 14 |
| Female genitalia | 74 | 46 | 11 | 17 | 52 | 41 | 0 | 6 | 0 | 1 |
| Male breast | 85 | 82 | 31 | 54 | 80 | 46 | 0 | 6 | 0 | 1 |
| Anus | 6 | 0 | 0 | 2 | 4 | 0 | 0 | 0 | 0 | 0 |
| Feet | 185 | 139 | 88 | 185 | 187 | 125 | 26 | 151 | 42 | 94 |
| Exposed region | Base | SAFREE | ESD-u | AlignGuard | LPO | SaTPO |
|---|---|---|---|---|---|---|
| Buttocks | 102 | 61 | 98 | 58 | 115 | 21 |
| Female breast | 178 | 41 | 165 | 64 | 188 | 26 |
| Female genitalia | 26 | 5 | 21 | 8 | 16 | 2 |
| Male breast | 36 | 12 | 35 | 4 | 21 | 2 |
| Anus | 0 | 0 | 0 | 0 | 0 | 0 |
| Feet | 184 | 100 | 188 | 173 | 164 | 155 |
| Method | MMA-Diffusion | Ring-A-Bell | SneakyPrompt | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ASR | PV | Q16 | NN | IP | ASR | PV | Q16 | NN | IP | ASR | PV | Q16 | NN | IP | ||
| SD-v1.5 | Base | 93.90 | 92.90 | 19.90 | 36.20 | 48.70 | 93.67 | 88.61 | 15.19 | 17.72 | 32.91 | 76.50 | 73.00 | 27.50 | 11.00 | 34.00 |
| AlignGuard | 22.50 | 20.70 | 0.90 | 1.80 | 2.70 | 41.77 | 37.97 | 3.80 | 5.06 | 8.86 | 20.50 | 19.50 | 1.50 | 0.50 | 2.00 | |
| SafetyBPO | 15.70 | 14.00 | 0.60 | 3.80 | 4.00 | 7.59 | 2.53 | 2.53 | 2.53 | 5.06 | 9.00 | 9.00 | 0.00 | 1.00 | 1.00 | |
| SaTPO | 6.80 | 6.20 | 0.90 | 0.30 | 1.20 | 1.27 | 0.00 | 0.00 | 1.27 | 1.27 | 3.00 | 3.00 | 0.00 | 0.00 | 0.00 | |
| SDXL | Base | 68.50 | 65.80 | 18.50 | 2.90 | 20.70 | 79.75 | 75.95 | 8.86 | 13.92 | 21.52 | 64.00 | 60.00 | 20.00 | 1.50 | 21.50 |
| Parent | Safe/Safe | Safe/Unsafe | Unsafe/Unsafe | Unsafe/Safe | ||||
|---|---|---|---|---|---|---|---|---|
| Pref. | Gap | Pref. | Gap | Pref. | Gap | Pref. | Gap | |
| 951 | 85.71 | +2.3553 | 92.14 | +3.2182 | 87.86 | +2.7746 | 87.14 | +2.1221 |
| 851 | 86.43 | +1.5343 | 87.86 | +2.4755 | 85.00 | +1.6670 | 78.57 | +1.4626 |
| 751 | 85.00 | +0.7654 | 86.43 | +1.2624 | 90.71 | +0.8521 | 77.86 | +0.6379 |
| 651 | 82.86 | +0.3561 | 88.57 | +0.7382 | 80.00 | +0.4452 | 75.00 | +0.2521 |
| 601 | 77.86 | +0.2598 | 83.57 | +0.5237 | 79.29 | +0.3121 | 75.71 | +0.2282 |