The Tokens Strike Back: Safety-Aware Denoising with Directional Embedding-based Revision
Organizations: Department of Computer Science, University of British Columbia, Canada · Korea Advanced Institute of Science and Technology (KAIST), South Korea · RBC Borealis, Canada
Abstract
The Safety-Aware Denoiser (SAD) is a recent, training-free, safety-guidance framework for text diffusion models. During inference, SAD steers text samples toward safe regions of the token probability space. In this paper, we propose (Safety-Aware Denoising with Directional Embedding-based Revision), which improves the safety and quality trade-offs of SAD by exploiting a safety-guidance signal in the embedding (or activation) space for each token position, then updating the token positions using the SAD update rule multiplied by the guidance signal. This multiplication acts as a gating mechanism: tokens with a high unsafe signal are more likely to be modified during inference following the SAD update rule. However, such an update does not automatically preserve the conditional mean, i.e., the denoiser of a fixed target distribution. We therefore theoretically derive new position-wise target distributions for which the modified denoiser is exact. Furthermore, we derive conditions under which the position-wise target distributions match a global target distribution. We test our method on popular Masked Diffusion Language Models (MDLMs) and Uniform-State Diffusion Models (USDMs) across unsafe continuation and jailbreak settings, and show that achieves a better balance between safety, generation quality, and inference cost than existing methods.
Figures & tables
| Method | RTP | BeaverTails | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE | |
| Unmodified | 32.0 | 32.0 | ||||||||
| Full SAD | 32.0 | 32.0 | ||||||||
| SADDER | 32.0 | 32.0 | ||||||||
| SADDER + warm-up | 32.0 | 32.0 | ||||||||
| CSD † | 61.9 | 55.0 | ||||||||
| Method | DIJA | PAD | XSTest | ||||||
|---|---|---|---|---|---|---|---|---|---|
| HB ASR % | LG unsafe % | Harmful PPL | NFE | HB ASR % | LG unsafe % | Harmful PPL | NFE | WG refusal % | |
| Dream-Instruct | |||||||||
| Unmodified | 91.7 | 116.0 | |||||||
| Full SAD | 91.7 | 116.0 | |||||||
| SADDER (selective) | 91.7 | 116.0 | |||||||
| SADDER + warm-up | 91.7 | 116.0 | |||||||
Appendix figures & tables35 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Meaning |
|---|---|
| Reference prompt and its harmful and safe responses. | |
| Prompt length, response length , and response truncation cap; . | |
| Numbers of harmful and safe examples used to estimate the centroids. | |
| Noised sequence, clean sequence, and one-hot clean token at position . | |
| Vocabulary, sequence length, and special mask token. | |
| Number of reverse updates, update index, corresponding noise time, and admitted intervention indices. |
| Symbol | Meaning |
|---|---|
| Data distribution underlying the pretrained denoiser and unsafe reference set used by the algorithm, respectively. | |
| Forward corruption kernel, used to weight clean unsafe references given the noised state. | |
| Data denoiser at position , estimated by the pretrained model. | |
| Unsafe denoiser, approximated by a weighted mixture of unsafe references. | |
| Data posterior over the entire clean sequence. | |
| Oracle unsafe-membership function and its posterior mean . |
| Parameter | Setting |
|---|---|
| Continuation sampling | 32 new tokens; 32 reverse steps; temperature 1; seeds 42, 43, 44. |
| Jailbreak sampling | 128 nominal steps; nominal length 128; temperature 1; seeds 42, 43, 44, except the explicitly labeled one-seed pilot. DIJA fills existing template spans. |
| Unsafe set | Continuation: up to 2,000 responses from the matching dataset after exact prompt-overlap exclusion. Jailbreak: documented 357-response WildJailbreak set. |
| Direction construction | Clean-reference response means. Later jobs use all valid reference rows; the selected earlier LLaDA/RTP selective row uses the 256-reference direction protocol. |
| Centered selection | Strict score threshold on masked editable positions. |
| Remasking | Off for the core method; top- uses ; aligned remasking reopens all positive-score revealed positions. |
| Model | Parameter | Values |
| LLaDA-Base | Strength | |
| Layer | ||
| Window | , , | |
| Warm-up | ||
| BoN / FK budget | ||
| Dream-Base | Strength |
| Model | Data | Method | Last step | Reopening | |||
|---|---|---|---|---|---|---|---|
| LLaDA | RTP | Full SAD | – | 3000 | 7 | 0 | none |
| RTP | SADDER (selective) | 31 † | 100 | 15 | 0 | none | |
| RTP | SADDER + warm-up | 24 | 3000 | 15 | 8 | none | |
| LLaDA | BT | Full SAD | – | 3000 | 15 | 0 | none |
| BT | SADDER (selective) | 31 | 3000 | 15 | 0 | none | |
| BT | SADDER + warm-up | 16 | 3000 | 15 | 8 | none |
| Method | RTP | BeaverTails | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE | |
| Unmodified | 32.0 | 32.0 | ||||||||
| Full SAD | 32.0 | 32.0 | ||||||||
| SADDER (selective) | 32.0 | 32.0 | ||||||||
| SADDER + warm-up | 32.0 | 32.0 | ||||||||
| CSD † | 61.9 | 55.0 | ||||||||
| Method | RTP | BeaverTails | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE | |
| Unmodified | 32.0 | 32.0 | ||||||||
| Full SAD | 32.0 | 32.0 | ||||||||
| SADDER (selective) | 32.0 | 32.0 | ||||||||
| SADDER + warm-up | 32.0 | 32.0 | ||||||||
| CSD † | 60.2 | 55.8 | ||||||||
| Dataset | Method | Setting |
|---|---|---|
| RTP | Full SAD | |
| SADDER | ||
| SADDER w/ top-1 remasking | ||
| SADDER w/ aligned remasking | ||
| SADDER + warm-up + aligned remasking | ; | |
| CSD † | , |
| Dataset | Method | Setting |
|---|---|---|
| RTP | Full SAD | |
| SADDER | ||
| SADDER w/ top-1 remasking | ||
| SADDER w/ aligned remasking | ||
| SADDER + warm-up | ; none | |
| CSD † | , |
| Method | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE |
| RTP | |||||
| Unmodified | 32.0 | ||||
| Full SAD | 32.0 | ||||
| SADDER (selective) | 32.0 | ||||
| SADDER w/ top-1 remasking | 47.0 | ||||
| SADDER w/ aligned remasking | 46.6 | ||||
| Method | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE |
| RTP | |||||
| Unmodified | 32.0 | ||||
| Full SAD | 32.0 | ||||
| SADDER | 32.0 | ||||
| SADDER w/ top-1 remasking | 47.0 | ||||
| SADDER w/ aligned remasking | 44.8 | ||||
| Model/data | Method | benign PPL | benign BERT |
|---|---|---|---|
| LLaDA/RTP | SADDER (selective) | ||
| SADDER + warm-up | |||
| LLaDA/BT | SADDER (selective) | ||
| SADDER + warm-up | |||
| Dream/RTP | SADDER (selective) | ||
| SADDER + warm-up |
| SADDER variant | vs full SAD | vs random selection | vs random reopening |
|---|---|---|---|
| RTP | |||
| Selective | — | ||
| + top-1 remasking | — | ||
| + aligned remasking | — | ||
| + warm-up + aligned | — | ||
| BeaverTails | |||
| SADDER variant | vs full SAD | vs random selection | vs random reopening |
|---|---|---|---|
| RTP | |||
| Selective | — | ||
| + top-1 remasking | |||
| + aligned remasking | |||
| + warm-up | — | ||
| BeaverTails | |||
| Method | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE |
|---|---|---|---|---|---|
| RTP | |||||
| BoN-2 | 64 | ||||
| BoN-4 | 128 | ||||
| BoN-8 | 256 | ||||
| FK-2 | 64 | ||||
| FK-4 | 128 | ||||
| Method | Unsafe % | Harmful PPL | Benign PPL | Benign BERT | NFE |
|---|---|---|---|---|---|
| RTP | |||||
| BoN-2 | 64 | ||||
| BoN-4 | 128 | ||||
| BoN-8 | 256 | ||||
| FK-2 | 64 | ||||
| FK-4 | 128 | ||||
| Model/data | Method | Unsafe % | Unsafe-prompt PPL | NFE |
|---|---|---|---|---|
| Dream/BT | BoN-2 | 64 | ||
| Dream/RTP | BoN-2 | 64 | ||
| SADDER + BoN-2 | 64 | |||
| LLaDA/BT | BoN-2 | 64 | ||
| SADDER + BoN-2 | 64 | |||
| LLaDA/RTP | BoN-2 | 64 |
| Method | DIJA | PAD | XSTest | ||||||
|---|---|---|---|---|---|---|---|---|---|
| HB ASR % | LG unsafe % | Harmful PPL | NFE | HB ASR % | LG unsafe % | Harmful PPL | NFE | WG refusal % | |
| LLaDA-Instruct | |||||||||
| Unmodified | 91.7 | 116.0 | |||||||
| Full SAD | 91.7 | 116.0 | |||||||
| SADDER (selective) | 91.7 | 116.0 | |||||||
| SADDER + warm-up | 91.7 | 116.0 | |||||||
| Method | Safe: over-refusal% | SD | Unsafe: refusal% | SD |
| LLaDA-Instruct | ||||
| Unmodified | 0.9 | 1.0 | ||
| Full SAD | 1.1 | 1.3 | ||
| SADDER (selective) | 0.8 | 0.3 | ||
| SADDER + warm-up | 0.7 | 0.0 | ||
| CSD † | 0.8 | 1.0 | ||
| Method | Safe prompts | Unsafe prompts |
|---|---|---|
| LLaDA-Instruct | ||
| Full SAD | ||
| SADDER (selective) | ||
| SADDER + warm-up | ||
| CSD † | ||
| DiffuGuard (full) | ||
| Safe prompts | Unsafe prompts | |||||
|---|---|---|---|---|---|---|
| Method | Over-refusal% | Harmful% | Refusal% | Harmful% | ||
| Unmodified | 603 | 585 | ||||
| Full SAD | 603 | 585 | ||||
| SADDER (selective) | 644 | 584 | ||||
| SADDER + warm-up | 710 | 592 | ||||
| CSD † | 589 | 585 | ||||
| Safe prompts | Unsafe prompts | |||||
|---|---|---|---|---|---|---|
| Method | Over-refusal% | Harmful% | Refusal% | Harmful% | ||
| Unmodified | 629 | 600 | ||||
| Full SAD | 619 | 600 | ||||
| SADDER (selective) | 562 | 572 | ||||
| SADDER + warm-up | 709 | 597 | ||||
| CSD † | 630 | 600 | ||||
| Method | Safe prompts | Pairs | Unsafe prompts | Pairs |
|---|---|---|---|---|
| Full SAD | 600 | 585 | ||
| SADDER (selective) | 579 | 581 | ||
| SADDER + warm-up | 593 | 581 | ||
| CSD † | 588 | 585 | ||
| DiffuGuard (full) | 603 | 585 | ||
| DiffuGuard (gen) ( ) | 589 | 585 |
| Method | Safe prompts | Pairs | Unsafe prompts | Pairs |
|---|---|---|---|---|
| Full SAD | 619 | 600 | ||
| SADDER (selective) | 532 | 572 | ||
| SADDER + warm-up | 602 | 597 | ||
| CSD † | 629 | 600 | ||
| DiffuGuard (full) | 629 | 600 | ||
| DiffuGuard (gen) ( ) | 629 | 600 |
| Method | DIJA | PAD | XSTest | ||||||
|---|---|---|---|---|---|---|---|---|---|
| HB ASR % | LG unsafe % | Harmful PPL | NFE | HB ASR % | LG unsafe % | Harmful PPL | NFE | Over-refusal % | |
| LLaDA-Instruct | |||||||||
| Unmodified | 91.7 | 116.0 | |||||||
| Full SAD | 91.7 | 116.0 | |||||||
| SADDER (selective) | 91.7 | 116.0 | |||||||
| SADDER + warm-up | 91.7 | 116.0 | |||||||
| DIJA | PAD | |||||
|---|---|---|---|---|---|---|
| Method | Harmful% | Refusal% | Harmful% | Refusal% | ||
| Unmodified | 300 | 300 | ||||
| Full SAD | 300 | 300 | ||||
| SADDER (selective) | 300 | 300 | ||||
| SADDER + warm-up | 300 | 300 | ||||
| CSD † | 300 | 300 | ||||
| DIJA | PAD | |||||
|---|---|---|---|---|---|---|
| Method | Harmful% | Refusal% | Harmful% | Refusal% | ||
| Unmodified | 300 | 300 | ||||
| Full SAD | 300 | 300 | ||||
| SADDER (selective) | 300 | 300 | ||||
| SADDER + warm-up | 300 | 300 | ||||
| CSD † | 300 | 300 | ||||
| Comparison | harmful% | refusal% | Pairs |
|---|---|---|---|
| LLaDA / DIJA | |||
| Selective vs. full SAD | 300 | ||
| Selective vs. random | 300 | ||
| Warm-up vs. full SAD | 300 | ||
| Warm-up vs. random | 300 | ||
| LLaDA / PAD | |||
| Method | HB full | HB fills | LG full | LG fills | WG full | WG fills |
|---|---|---|---|---|---|---|
| Unmodified | ||||||
| Full SAD | ||||||
| SADDER (selective) | ||||||
| SADDER + warm-up | ||||||
| CSD † | ||||||
| DiffuGuard (full) |
| Method | HB full | HB fills | LG full | LG fills | WG full | WG fills |
|---|---|---|---|---|---|---|
| Unmodified | ||||||
| Full SAD | ||||||
| SADDER (selective) | ||||||
| SADDER + warm-up | ||||||
| CSD † | ||||||
| DiffuGuard (full) |
| Comparison | HB | LG | WG |
|---|---|---|---|
| LLaDA | |||
| Selective vs Unmodified | |||
| Selective vs Full SAD | |||
| Selective vs Random selection | |||
| Warm-up vs Unmodified | |||
| Warm-up vs Full SAD | |||
| Method | Duo | UDLM | NFE | ||
|---|---|---|---|---|---|
| Unsafe | Benign BERT | Unsafe | Benign BERT | ||
| Unmodified | 128 | ||||
| SAD | |||||
| 128 | |||||
| 128 | |||||
| 128 | |||||
Diffusion Model Guidance
Diffusion model guidance steers denoising toward desired conditions, rewards, constraints, or away from unwanted concepts.
See all 370 papers