SAFETY-GUIDED FLOW (SGF): A UNIFIED FRAMEWORK FOR NEGATIVE GUIDANCE IN SAFE GENERATION
Mingyu Kim, Young-Heon Kim, Mijung Park
International Conference on Learning Representations 2026 · Oral
Overview
The proliferation of powerful generative models, particularly diffusion models, has introduced significant challenges related to the generation of unsafe, harmful, or unwanted content. These models, often trained on vast, uncurated internet datasets, are susceptible to producing outputs ranging from inappropriate imagery to undesirable style memorization, such as replicating copyrighted artworks without explicit prompting. This talk introduces the Safety-Guided Flow (SGF), a novel and unified framework designed to address these safety concerns by incorporating negative guidance into the generative process. SGF provides a principled mathematical foundation for steering generative models away from unsafe regions of the data distribution, moving beyond the heuristic-based approaches common in prior work.

Key moments
- 0:00 Motivation: Unsafe content and memorization in diffusion models
- 2:20 Introducing Safety-Guided Flow (SGF) for negative guidance
- 3:30 MMD potential unifies existing methods, defines steering direction
- 4:50 Theoretical insight: Early guidance is most effective
- 6:10 Qualitative results: Avoiding memorization, maintaining quality
- 6:40 Quantitative results: Improved safety and diversity metrics
- 7:50 Q&A: Avoiding semantic regions, not just specific samples
- 8:40 Q&A: Scaling and computational cost of negative samples
SAFETY-GUIDED FLOW (SGF): A UNIFIED FRAMEWORK FOR NEGATIVE GUIDANCE IN SAFE GENERATION
Speakers: Mingyu Kim, Young-Heon Kim, Mijung Park
Conference: ICLR 2026
YouTube: https://slideslive.com/39062178
Overview
The proliferation of powerful generative models, particularly diffusion models, has introduced significant challenges related to the generation of unsafe, harmful, or unwanted content. These models, often trained on vast, uncurated internet datasets, are susceptible to producing outputs ranging from inappropriate imagery to undesirable style memorization, such as replicating copyrighted artworks without explicit prompting. This talk introduces the Safety-Guided Flow (SGF), a novel and unified framework designed to address these safety concerns by incorporating negative guidance into the generative process. SGF provides a principled mathematical foundation for steering generative models away from unsafe regions of the data distribution, moving beyond the heuristic-based approaches common in prior work.
Presented by Mingyu Kim, this work, a collaboration with Young-Heon Kim and Mijung Park, tackles two fundamental questions in safe generation: "where should we push?" and "when should guidance be applied?". By leveraging the concept of Maximum Mean Discrepancy (MMD) potential, SGF not only unifies existing methods like Shield Diffusion and Safe Denoiser under a single theoretical umbrella but also offers a provably optimal schedule for applying negative guidance, emphasizing the critical importance of early intervention in the generation process. This research represents a significant step towards building more controllable and responsible generative AI systems, ensuring both safety and high-quality output.
The significance of SGF lies in its ability to provide a robust, theoretically grounded solution to a pressing issue in AI ethics and deployment. By offering a unified perspective and a data-driven approach to negative guidance, it enables practitioners to mitigate risks associated with unsafe content generation more effectively. The framework’s emphasis on early guidance also provides crucial insights into the dynamics of generative processes, suggesting that strategic interventions at the initial stages can have a disproportionately large impact on the final output's safety and quality, thereby optimizing computational resources and improving overall model behavior.
Background
▶ Watch: Motivation: Unsafe content and memorization in diffusion models (0:00)
The rapid advancements in generative AI, particularly with diffusion models like Stable Diffusion, have revolutionized content creation. However, this power comes with inherent risks. These models are typically trained on massive, often uncurated datasets scraped from the internet, which inevitably contain biases, harmful content, and copyrighted material. Consequently, diffusion models can inadvertently generate:
- Awkward and Harmful Content: Images depicting violence, nudity, or other inappropriate themes, even without explicit prompts, due to their exposure to such data during training.
- Memorization and Style Copying: The tendency to reproduce specific images or artistic styles from the training data, sometimes without any relevant prompt. A striking example mentioned is Stable Diffusion 1.4 generating images very similar to Munch's "The Scream" without any specific keyword, indicating a form of "memorization" or strong stylistic bias.
These issues stem from the model's inability to distinguish between "safe" and "unsafe" data regions during inference, treating both as equally valid outputs of its learned distribution. Addressing this requires methods to "steer" the generation process away from these unsafe regions.
Prior work has attempted to tackle this problem, primarily through two distinct approaches:
- Shield Diffusion: This method employs a geometric repulsion strategy. It defines "balls" of a certain radius around known negative (unsafe) data points. If a generated sample (
x_hat_0) comes too close to an unsafe point (i.e., enters its "ball"), it is geometrically pushed back outside. The magnitude of this push is just enough to exit the unsafe region. While effective, the radius of these balls is a crucial hyperparameter, making the method reliant on heuristic tuning.
- Safe Denoiser: This concurrent work adopts a more probabilistic approach to safety. It modifies the denoising process by incorporating an "unsafe term" into the Tweedie formula, which describes the score function of the data distribution. The unsafe term is estimated using kernel density estimation (KDE) on negative samples, treating safe and unsafe distributions as mutually exclusive. Interestingly, the final corrective term (
delta x_t) shares structural similarities with Shield Diffusion. However, Safe Denoiser also relies on a heuristic early stopping mechanism with two distinct guidance terms, indicating a lack of a principled schedule for applying guidance.
Both Shield Diffusion and Safe Denoiser, despite their contributions, are characterized by their reliance on heuristics—arbitrary design choices or manually tuned parameters (like the radius in Shield Diffusion or the early stopping criteria in Safe Denoiser). This heuristic dependency makes these methods less robust, harder to generalize, and potentially suboptimal. The core problem, therefore, is the absence of a unified, mathematically principled framework that can justify where to push samples away from unsafe regions and when to apply this guidance optimally. This gap motivates the development of Safety-Guided Flow (SGF), aiming to provide a theoretical foundation for these design choices.
Key Findings
▶ Watch: MMD potential unifies existing methods, defines steering direction (3:30)
The Safety-Guided Flow (SGF) framework introduces several pivotal contributions that significantly advance the field of safe generative AI:
- Unified Framework via MMD Potential: SGF successfully unifies prior heuristic-based negative guidance methods, specifically Shield Diffusion and Safe Denoiser, under a single, mathematically principled framework. This unification is achieved by leveraging the Maximum Mean Discrepancy (MMD) potential to define the steering direction away from unsafe data. The gradient of this MMD potential provides a data-driven, theoretically sound mechanism for repulsion.
- Recovery of Prior Methods: The talk demonstrates formally (via Proposition 1 and Proposition 2) that the gradient of the MMD potential, under specific conditions, directly recovers the corrective terms used in both Safe Denoiser and Shield Diffusion. This establishes SGF not merely as an alternative, but as a foundational theory from which existing effective strategies emerge as special cases.
- Principled Guidance Schedule (Early Guidance is Optimal): SGF provides a theoretical answer to the crucial question of when to apply negative guidance. Through Theorem 2, the framework establishes a "critical time window" for safe guidance, proving that negative guidance is most effective when applied at early time steps in the generative process. This insight leads to a theoretically grounded and empirically strong early stopping strategy, demonstrating that for a fixed guidance budget, applying it earlier always improves safety.
- Improved Safety and Quality: Empirically, SGF consistently outperforms existing methods in terms of both safety and generation quality. Qualitative results demonstrate its ability to avoid memorization while maintaining prompt adherence and generating diverse outputs. Quantitative evaluations show a significant reduction in Attack Success Rate (ASR) for unsafe content generation (e.g., nudity), averaging a 20% reduction compared to baselines, while simultaneously improving diversity metrics like FID and recall.
Technical Deep Dive
▶ Watch: Qualitative results: Avoiding memorization, maintaining quality (6:10)
The Safety-Guided Flow (SGF) framework is built upon the idea of steering a pre-trained generative flow with negative guidance. This approach aims to maintain the original generation trajectory while robustly diverting it from undesirable regions of the data distribution.
The core dynamic of SGF is represented by an equation with two main components:
dx_t = f_theta(x_t, t) dt + lambda_t * g(x_t, t) dt
- Pre-trained Flow (
f_theta): This term represents the main generation trajectory. It is derived from a diffusion or flow model pre-trained on the source and target data distributions. This component is responsible for the high-quality, diverse content generation that diffusion models are known for.
- **Negative Guidance Term (
lambda_t * g(x_t, t)):** This is the crucial safety mechanism.lambda_tis a time-dependent scaling factor, andg(x_t, t)is the negative guidance vector that pushes the samplex_taway from the unsafe region. The innovation of SGF lies in how this guidance termg(x_t, t)is constructed in a principled, data-driven manner.
Constructing Negative Guidance via MMD Potential
SGF unifies the definition of the steering direction using the Maximum Mean Discrepancy (MMD) potential. MMD is a statistical distance metric used to measure the difference between two probability distributions. In SGF, it's repurposed to quantify the "distance" between the current generated sample x_t (or its distribution) and the distribution of known unsafe data points (D_unsafe).
The empirical MMD between a sample x_t and a set of negative samples Y = {y_1, ..., y_N} is defined using a kernel density estimation approach:
MMD(x_t, D_unsafe) = E_y[k(x_t, y)] - 0.5 * E_y'[E_y[k(y', y)]] (simplified for conceptual understanding here, the actual form for a single point x_t comparing to a distribution often focuses on the first term or a variant).
More precisely, the MMD potential is treated as a measure of how "close" x_t is to the unsafe data distribution. To move away from this unsafe region, SGF takes the gradient of this MMD potential with respect to x_t. This gradient points in the direction of increasing "unsafeness," so taking the negative gradient provides the desired repulsive force:
g(x_t, t) = -nabla_x MMD_potential(x_t, D_unsafe)
This approach provides a principled, data-driven way to define the steering direction, as the gradient naturally pushes samples away from regions where the MMD potential is high (i.e., regions close to unsafe data).
Unifying Prior Methods
A significant theoretical contribution of SGF is its ability to recover existing negative guidance methods as special cases:
- Proposition 1 (Recovery of Safe Denoiser): The talk states that the MMD gradient recovers the Safe Denoiser's corrective term. Specifically, the gradient of the MMD potential can be shown to approximate
x_t - E[y | y in D_unsafe], which is structurally similar to the unsafe expectation term used in Safe Denoiser. This demonstrates that Safe Denoiser's probabilistic guidance can be understood as an approximation of the MMD gradient.
- Proposition 2 (Recovery of Shield Diffusion): Under certain conditions (e.g., using a specific kernel and a single negative sample
y_k), the MMD gradient becomes proportional tox_t - y_k. This is precisely the geometric repulsion vector used in Shield Diffusion, which pushesx_taway from the negative pointy_k. This shows that Shield Diffusion's geometric repulsion is also a specific instance of MMD gradient-based guidance.
These propositions establish SGF as a powerful unifying framework, providing a mathematical justification for the mechanisms employed by previous heuristic-driven methods.
Optimal Guidance Schedule: The Importance of Early Guidance
Beyond defining where to push, SGF also addresses when to apply guidance optimally. Theorem 2 formalizes the concept of a "critical time window" for safe guidance, providing a theoretical answer to this timing question.
The theorem describes how the error (e.g., proximity to unsafe regions) evolves over time, both with and without guidance. It highlights two key terms in the error equation:
- Natural Diffusion Term: Represents the inherent evolution of the sample without guidance. If a sample starts near an unsafe region, this term can amplify that error over time, causing unsafe content to "grow" naturally.
- Negative Guidance Term: Represents the cumulative correction applied by the SGF.
The key insight from Theorem 2 is the weighting term associated with the guidance. This term demonstrates that the influence of negative guidance is significantly larger at early time steps and decreases as the generation progresses.
The intuition behind this is compelling:
- Early Stages: At the beginning of the generation process, the sample (
x_t) is typically a noisy, high-level representation. Small changes or pushes at this stage can profoundly affect the entire structural and semantic outcome of the generated image. The "shape" is very rough and flexible. - Later Stages: As the generation progresses, the sample becomes increasingly refined and detailed. The "shape" is almost fixed. Applying guidance at this late stage has very little effect on the overall structure and may even introduce artifacts or "break" fine details, leading to lower quality outputs.
Based on this theoretical foundation, SGF demonstrates that for a fixed budget of guidance (e.g., a certain number of guidance steps or computational cost), moving the guidance application to earlier time steps consistently improves safety outcomes. This leads to the recommendation of an early stopping strategy for negative guidance, where the guidance is concentrated at the beginning of the sampling process and potentially reduced or eliminated later.
Experimental Setup & Results
▶ Watch: Quantitative results: Improved safety and diversity metrics (6:40)
The effectiveness of Safety-Guided Flow (SGF) was rigorously evaluated through both qualitative and quantitative experiments, comparing it against existing baselines like Shield Diffusion and Safe Denoiser. The experiments focused on two critical aspects: avoiding memorization/style copying and preventing the generation of harmful content (specifically nudity), while maintaining overall generation quality and diversity.
Qualitative Results: Avoiding Memorization
To demonstrate SGF's ability to prevent memorization, the iconic painting "The Scream" by Edvard Munch was used as a negative example.
- Observation: When a standard Stable Diffusion model is prompted, it tends to copy the style or even specific elements of "The Scream," indicating undesirable memorization from its training data, even without explicit mention of the artwork.
- SGF Performance: In contrast, SGF successfully avoided this memorization. The generated outputs were diverse and did not replicate the specific style or imagery of "The Scream." Crucially, SGF still followed the given prompt well, demonstrating its ability to simultaneously achieve both safety (avoiding memorization) and high generation quality. This highlights SGF's capacity to steer away from specific undesirable content while preserving the model's creative capabilities.
Quantitative Results: Nudity Detection (Safety)
For quantitative evaluation of safety, the generation of nudity was used as a benchmark for harmful content. The primary metric employed was Attack Success Rate (ASR), which measures the proportion of generated images that are classified as unsafe (e.g., nude). Lower ASR indicates better safety performance.
- Comparison: SGF (represented by blue bars) was compared against Safe Denoiser (yellow bars) across various benchmarks (specific datasets or prompt categories, though not detailed in the transcript, implied by "all benchmark").
- Performance: SGF consistently achieved a lower ASR across all evaluated benchmarks. The results showed a significant improvement, with SGF reducing the average ASR by approximately 20% compared to Safe Denoiser. This robust quantitative evidence underscores SGF's superior ability to prevent the generation of unsafe content.
Quantitative Results: Diversity and Quality
Beyond safety, SGF also evaluated its impact on the diversity and overall quality of generated images, especially in the context of the proposed early stopping strategy. Metrics like FID (Fréchet Inception Distance) and recall were likely used, with lower FID indicating higher quality and higher recall indicating better diversity or coverage of the target distribution.
- Comparison of Guidance Schedules: The experiments compared "full guidance" (orange) with "early stopping" (blue) for both SGF and Shield Diffusion.
- Impact of Early Stopping: The results indicated that the early stopping strategy significantly improved both FID and recall for both methodologies (SGF and Shield Diffusion). This empirically validated the theoretical finding that early guidance is more effective, leading to better quality and diversity outcomes compared to applying guidance uniformly throughout the generation process.
- Overall Performance: Furthermore, SGF consistently outperformed Shield Diffusion in terms of both quality (lower FID) and diversity (higher recall), reinforcing its superior overall performance as a negative guidance framework.
Scaling with Number of Negative Samples
An important practical consideration for any data-driven guidance method is its scalability with the number of negative samples. The use of MMD potential, which involves kernel density estimation, could potentially become computationally expensive with a very large negative dataset.
- Findings: The experiments showed that SGF's performance was maintained (i.e., did not degrade) when using above 500 negative data points. Below this threshold, performance could degrade, indicating the importance of a sufficiently representative negative dataset.
- Computational Cost: Regarding the computational resources, the evaluation of the negative guidance term was found to be "not expensive" relative to the overall computation for the Neural Function Evaluation (NFE) steps in the diffusion process. This suggests that while the number of negative samples is important for performance, the computational overhead introduced by SGF's guidance mechanism is relatively minor.
In summary, the experimental results provide strong evidence for SGF's efficacy. It not only offers a principled unification of existing methods but also delivers tangible improvements in safety, quality, and diversity, particularly when leveraging its theoretically grounded early stopping strategy.
Practical Implications
▶ Watch: Q&A: Scaling and computational cost of negative samples (8:40)
The Safety-Guided Flow (SGF) framework offers several significant practical implications for practitioners, infrastructure teams, model builders, and deployers working with generative AI.
- Principled Approach to Safety: SGF moves beyond ad-hoc heuristics by providing a mathematically grounded method for negative guidance. This means model builders can rely on a more robust and predictable mechanism for preventing unsafe content, rather than constantly tuning hyperparameters or relying on empirical rules of thumb. This reduces the trial-and-error often associated with safety filters.
- Improved Control and Predictability: By unifying existing methods and offering a clear direction for steering (via MMD gradient), SGF gives deployers greater control over the output of generative models. The ability to precisely define "unsafe" regions through a negative dataset allows for more targeted intervention, leading to outputs that better align with safety guidelines while preserving creative freedom.
- Optimized Resource Utilization with Early Guidance: The theoretical and empirical validation of early stopping guidance is a major win for efficiency. Infrastructure teams and model deployers can allocate computational resources more effectively by concentrating guidance at the initial, more impactful stages of generation. This reduces the computational overhead of continuous guidance throughout the entire sampling process, potentially leading to faster inference times or the ability to apply stronger guidance within the same computational budget.
- Enhanced Model Quality and Diversity: The findings that early guidance improves both FID (quality) and recall (diversity) are critical. This implies that implementing SGF, particularly with an optimized guidance schedule, doesn't just make models safer; it can also lead to better overall generative performance. This addresses a common concern that safety measures might excessively constrain creativity or degrade output quality.
- Data-Driven Customization: The framework's reliance on a "negative dataset" for defining unsafe regions allows for flexible and context-specific customization. Practitioners can curate negative datasets relevant to their specific use cases (e.g., avoiding specific corporate branding, culturally inappropriate imagery, or proprietary styles). The discussion about avoiding "semantic regions" (like nudity as a concept) rather than just specific images highlights the potential for more abstract safety definitions, provided the negative dataset is sufficiently representative of that concept. However, this also poses a challenge: acquiring and maintaining high-quality, comprehensive negative datasets can be resource-intensive.
Tradeoffs and Limitations:
- Negative Data Collection: The effectiveness of SGF heavily depends on the quality and comprehensiveness of the negative dataset. Identifying and curating a sufficiently diverse and representative set of "unsafe" examples, especially for abstract concepts like "nudity" or "violence," can be challenging and time-consuming. An incomplete negative dataset could lead to blind spots where the model still generates unsafe content not covered by the examples.
- Scalability for Extreme Datasets: While the talk notes that performance is maintained above 500 negative data points and computation is not expensive, the theoretical complexity of MMD calculations can scale with the number of negative samples. For extremely large-scale applications with millions of negative examples, further optimizations or approximation techniques for MMD might be necessary.
- Defining "Unsafe": The definition of "unsafe" can be subjective and context-dependent. While SGF provides the mechanism, the responsibility for defining what constitutes unsafe content still lies with the human operators, requiring careful ethical and legal considerations.
- Potential for Adversarial Exploitation: While not explicitly discussed in the talk, any safety mechanism could potentially be reverse-engineered or exploited by adversarial prompts designed to bypass the guidance. Continuous monitoring and updates to both the models and safety frameworks remain crucial.
In essence, SGF provides a robust, theoretically sound, and practically efficient framework for building safer generative AI. It empowers practitioners with better tools to manage the risks of harmful content, optimize computational resources, and ultimately deploy more responsible and higher-quality AI systems.
Key Takeaways
- Unified Framework for Negative Guidance: SGF unifies existing heuristic-based negative guidance methods (Shield Diffusion, Safe Denoiser) under a single, mathematically principled framework using MMD potential.
- Principled Steering Direction: The gradient of the MMD potential provides a data-driven, theoretically justified direction for steering generative samples away from unsafe regions defined by a negative dataset.
- Early Guidance is Optimal: SGF theoretically proves (via Theorem 2) that negative guidance is most effective when applied at early time steps in the generative process, leading to a powerful early stopping strategy.
- Improved Safety and Quality: Empirically, SGF significantly reduces the Attack Success Rate (ASR) for unsafe content (e.g., 20% average reduction for nudity) while simultaneously improving generation quality and diversity (FID and recall).
- Avoids Memorization: SGF effectively prevents undesirable memorization and style copying from training data, as demonstrated by qualitative results with examples like "The Scream."
- Practical Scalability: The framework performs well with a moderate number of negative samples (performance maintained above 500 points) and introduces negligible computational overhead, making it practical for deployment.
About the Speaker(s)
The talk was presented by Mingyu Kim, who is credited as the lead speaker for this research. He is joined in this joint work by Young-Heon Kim and Mijung Park. The affiliations of the speakers are not explicitly mentioned in the provided transcript, but their work is presented at ICLR, a premier conference in machine learning, indicating their expertise in the field of AI and generative models.
Reviews
→ Top-rated talks at International Conference on Learning Representations 2026
All talks from International Conference on Learning Representations 2026