---
title: Dynamic Negative Guidance (DNG)
url: https://www.emergentmind.com/topics/dynamic-negative-guidance-dng
type: topic
---

# Dynamic Negative Guidance (DNG)

Dynamic Negative Guidance (DNG) is a class of techniques for generative models that dynamically adapts the repulsive signal steering the model away from unwanted outputs, artifacts, or constraint-violating regions. Unlike standard negative guidance or negative prompting—which employ static, globally applied negative signals—DNG modulates guidance strength or target content adaptively at each generation step based on state, time, local uncertainty, or external feedback. DNG methods have been adopted across masked diffusion language models, text-to-image diffusion, few-step flow-matching architectures, engineering design generators, and artifact-mitigation pipelines, offering improved safety, fidelity, controllability, and sample quality relative to static baselines.

## 1. Core Principles and Definitions

Dynamic Negative Guidance builds upon conventional classifier-free guidance (CFG), which linearly interpolates conditional (desired) and unconditional (neutral/negative) model branches for controllable sampling. DNG enhances this by introducing dynamism to the negative branch, including:

- **Adaptive context selection:** Rather than a fixed unconditional input (e.g., a null prompt or blank mask), DNG selects a partial or state-specific negative context at each generation step—commonly focusing repulsion where the model is least certain or where unwanted artifacts are detected [2505.20199].
- **State- and time-dependent scaling:** The strength of negative guidance is modulated as a function of the generative trajectory (e.g., denoising steps, attention activations, or posterior estimates), ensuring stronger repulsion in ambiguous or risky regions and tapering off where the model is certain [2410.14398, 2508.10931].
- **External signal integration:** DNG may interleave reward models, classifiers, or vision-language model (VLM) queries to dynamically discover which features/concepts to repel, based on real-time feedback [2412.19637, 2510.26052].

Standard CFG, NASA, and NAG utilize static guidance. In contrast, DNG's dynamic, context-aware negative signal yields targeted constraint enforcement and improved sample quality.

## 2. Mathematical Formulations and Algorithms

DNG methods adopt distinct formulations depending on model class and domain. Principal variants include:

- **Adaptive Classifier-Free Guidance via Dynamic Low-Confidence Masking:** For masked diffusion language models, DNG constructs the unconditional branch by selectively remasking low-confidence tokens at each generation step, defining a binary mask $M_t$ over filled positions with lowest softmax confidence. The guidance update becomes $x_{t-1} = x_t + \alpha_t (f_\theta(x_t|y) - f_\theta(x_t^U))$ where $x_t^U$ is the masked input [2505.20199].
- **Posterior-weighted Dynamic Scaling:** In diffusion models, the negative guidance term $\lambda(t,x_t)$ is adjusted at every denoising timestep according to the estimated posterior probability of the forbidden class, using recursive Bayes updates along the discrete Markov chain. The effective score is $s_{DNG}(x_t, t) = s_\theta(x_t, t) - \lambda(t, x_t)[s_{\theta,Red}(x_t, t) - s_\theta(x_t, t)]$ [2410.14398].
- **Attention-space Value Sign Flip (VSF):** In few-step image or video diffusion, negative prompt value vectors are dynamically sign-flipped in attention computations, scaling by actual image-to-negative-token attention weights. The update at each layer is $Z_{VSF} = A^+ V^+ - \alpha A^- V^-$ (adaptive per step and location) [2508.10931].
- **Learned Dynamic Negative Embeddings:** Reward-guided learning frameworks (e.g., ReNeg) optimize a negative embedding vector in the CLIP text encoder space—globally or per-prompt—by gradient feedback from a scalar reward model, updating $n$ to maximize the expected downstream human-alignment reward for generated images [2412.19637].
- **VLM-Queried Dynamic Negative Prompting:** At specified denoising steps, DNG samples the intermediate image, queries a VLM for context-specific negative prompts, and uses these dynamically for negative guidance during subsequent steps [2510.26052].
- **Score sharpening along artifact directions:** In artifact mitigation, DNG subtracts out score components along directions identified as leading to hallucinations, $s_{DNG}(x,t) = s_\theta(x,t) - \lambda(t)\langle s_\theta(x,t), \hat u\rangle\hat u$ [2510.05356].

These approaches share a general form: at each generative step, determine the negative signal to apply (by mask, scaling, projection, or external model) based on the instantaneous state.

## 3. Model Classes and Integration Strategies

DNG is instantiated in a range of architectures:

- **Masked and iterative language models:** Dynamic remasking is used to localize negative guidance to low-confidence spans [2505.20199].
- **Score-based diffusion and DDPMs/DDIMs:** Posterior-tracked negative guidance regulates repulsive force at each denoising timestep, supporting class-removal and feature suppression [2410.14398, 2510.05356].
- **Transformer attention networks in image/video synthesis:** Attention-based dynamic guidance (such as VSF) acts at the token and layer level, supporting real-time adaptation in few-step (1–8 steps) or flow-matching models [2508.10931].
- **Generative adversarial and VAE frameworks for engineering and design:** Negative data (constraint-violating samples) provide dynamic, zone-specific repulsion in training objectives, improving constraint satisfaction [2306.15166].
- **Plug-and-play in popular diffusion pipelines:** In Stable Diffusion and cross-attention architectures, DNG can be implemented via attention kernel modifications, learned negative prompt embeddings, or VLM interleaving, often with modest or negligible overhead [2412.19637, 2508.10931, 2510.26052].

Notably, DNG introduces minimal runtime increase (typically <10%) and does not require retraining in most variants.

## 4. Empirical Benchmarks and Performance

DNG methods consistently outperform static negative guidance and unconditioned sampling on metrics such as safety, diversity, constraint satisfaction, alignment, and image quality.

Selected results:

| Model/Dataset           | Baseline             | Static Guidance | DNG / Dynamic    | Improvement                                    |
|------------------------|----------------------|-----------------|------------------|------------------------------------------------|
| LLaDA-8B (GPQA)        | 26.1%                | 29.4%           | 33.3%            | +3.9 pts over CFG [2505.20199]                 |
| LLaDA-8B (Sudoku)      | 35.0%                | 34.0%           | 42.0%            | +8.0 pts                                       |
| Stable Diffusion 3.5   | NegScore ~0.19–0.38  |                 | VSF: 0.545       | +0.2–0.4 vs NASA/NAG [2508.10931]              |
| MNIST (class removal)  |                      |                 | DNG: <1% rate    | Best KL/FID at high safety [2410.14398]        |
| HPSv2 (ReNeg global)   | null-text baseline   | +4–6 points     |                  | Superior human-alignment [2412.19637]          |
| TopologyGAN            | v.f. error 10.4%     |                 | DNG: 8.8%        | –15% error [2306.15166]                        |
| ImageNet-1k (DNG)      | IS=34.24             | IS=83.19        | IS=88.49         | Highest IS/precision [2510.05356]              |
| Ring-a-Bell/P4D (ASR)  | –                    |                 | ASR↓ to ~0.01    | Maintains FID/CLIP under VLM-DNP [2510.26052]  |

DNG's ability to sharpen repulsive signals along “risky” features or regions and adaptively tune guidance yields better Pareto frontiers for safety-vs-fidelity and constraint-vs-diversity, narrowing the gap to strong autoregressive or supervised baselines.

## 5. Identifying and Targeting Undesirable Features

Central to DNG is the identification of where and how to apply negative guidance:

- **Model uncertainty:** Low softmax confidence identifies ambiguous tokens for targeted corrective masking [2505.20199].
- **Class/posterior tracking:** Recursive Bayes filtering provides state-aware strength for concept suppression [2410.14398].
- **Artifact direction discovery:** PCA, classifier-based separation, or domain heuristics select vectors to “sharpen” out hallucination-prone semantics [2510.05356].
- **Reward feedback:** Human-preference reward models optimize negative embeddings for perceptual alignment [2412.19637].
- **Vision-language feedback:** Dynamic visual inspection yields context-aware negative prompts, reducing collateral suppression [2510.26052].
- **Attention weights:** Image-to-negative attention dynamic in transformer layers guides where negative values exert most impact [2508.10931].

A plausible implication is that DNG’s adaptability enables fine-grained constraint enforcement, making it robust to concept drift, mode collapse, and distribution shifts.

## 6. Limitations, Hyperparameters, and Extensions

DNG introduces new design choices, including mask fraction (ρ), guidance scale (α or λ), query intervals, and thresholds. Empirical studies find:

- Optimal ρ ≈ 0.7 for masking low-confidence tokens; too low yields static guidance, too high degrades context [2505.20199].
- Guidance scales must be moderate; large values harm fluency or recall [2505.20199, 2508.10931].
- In posterior-tracked methods, hyperparameters such as temperature (τ) and offset (δ) require tuning for each domain [2410.14398].
- In artifact-mitigation DNG, artifact direction $\hat u$ must be well-chosen to avoid unintended diversity loss [2510.05356].
- VLM-based DNG induces runtime overhead due to repeated queries, but this is offset by sharply improved safety-fidelity trade-offs [2510.26052].
- All DNG approaches require access to appropriate negative data, attribute directions, or feedback signals.

Future extensions include multi-vector (multi-artifact) DNG, joint positive/negative dynamic schedules, adaptive guidance scaling, and tighter theoretical analysis of convergence and approximation error. Applicability to non-diffusion models, hybrid architectures, and reinforcement learning remains an open direction.

## 7. Domain-Specific and Theoretical Insights

DNG’s impact is robust across language, vision, and design domains:

- **Engineering design:** DNG/NDGM methods use negative data as explicit repellent, dramatically reducing constraint violations (e.g., by 97% in synthetic problems) while retaining mode coverage [2306.15166].
- **Language generation:** DNG localizes corrective guidance to uncertain tokens, outperforming static CFG in logical reasoning and planning tasks [2505.20199].
- **Image and video generative diffusion:** DNG achieves higher safety at maintained image fidelity, prevents over-correction, and enables context-specific, fine-grained artifact removal [2410.14398, 2508.10931, 2510.26052].
- **Hallucination suppression:** DNG “sharpens” the score field specifically in low-density, high-risk regions, unlike global variance filtering or static classifier guidance [2510.05356].

The theoretical underpinning of DNG is minimizing (or dynamically modulating) mass in invalid/out-of-support regions, via explicit divergence terms, dynamic conditional guidance, or directionally targeted score adjustment. This framework generalizes naturally to settings where negative examples or artifact signals can be flexibly defined and leveraged within the generative process.

Source: https://www.emergentmind.com/topics/dynamic-negative-guidance-dng