SP-Guard: Selective Prompt-adaptive Guidance for Safe Text-to-Image Generation

Sumin Yu, Taesup Moon · 2025

Read SP-Guard: Selective Prompt-adaptive Guidance for Safe Text-to-Image Generation by Sumin Yu, Taesup Moon (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2511-11014.txt.

Introduction

Sumin Yu and Taesup Moon present SP-Guard, a safety method for models that turn text prompts into pictures. Such models can easily be asked to make harmful images, so guardrails are needed at the time of use. Older guards apply the same push to every prompt and to the whole image, which can spoil safe parts.

SP-Guard first judges how harmful a prompt looks, then masks the push so it acts only on unsafe regions. Strength follows the judged risk, so mild prompts are left mostly alone. Tests show safer images than prior methods with less unwanted change, which points to clearer and more controlled generation.

Catalog record

CREATORSumin Yu, Taesup Moon
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE27 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2511-11014

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

SP-Guard: Selective Prompt-adaptive Guidance for Safe Text-to-Image Generation Sumin Yu, Taesup Moon Abstract While diffusion-based T2I models have achieved remarkable image generation quality, they also enable easy creation of harmful content, raising social concerns and highlighting the need for safer generation. Existing inference-time guiding methods lack both adaptivity—adjusting guidance strength based on the prompt—and selectivity—targeting only unsafe regions of the image. Our method, SP-Guard, addresses these limitations by estimating prompt harmfulness and applying a selective guidance mask to guide only unsafe areas. Experiments show that SP-Guard generates safer images than existing methods while minimizing unintended content alteration. Beyond improving safety, our findings highlight the importance of transparency and controllability in image generation. WARNING : This paper contains AI-generated images that may be offensive. Sensitive contents are masked. [orcid=0009-0008-9752-0112, [email protected], url=https://sumin-yu.github.io, ] [orcid=0000-0002-9257-6503 , [email protected], url=https://mindlab-snu.notion.site/taesup-moon, ] *1 keywords Risk Management for Trustworthy AI ,Safe Generative AI ,Text-to-Image Diffusion Model ,Safe Image Generation † † copyrightyear: 2025 † † copyright: Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). † † venue: TRUST-AI: The European Workshop on Trustworthy AI. Organized as part of the European Conference of Artificial Intelligence - ECAI 2025. October 2025, Bologna, Italy. † † address: Department of Electrical and Computer Engineering, Seoul National University, Seoul, South Korea † † address: IPAI / ASRI / INMC, Seoul National University, Seoul, South Korea † † corresp: Corresponding author. 1 Introduction The rapid advancements in text-to-image (T2I) diffusion models 25 ; 26 have enabled the generation of high-quality images based on textual inputs. However, the extensive training data often contain unsafe content and inherent biases 25 ; 29 , posing significant risks of generating unexpected unsafe images 3 . There are also concerns about malicious users exploiting model vulnerabilities to create harmful images by generating attacking prompts 32 ; 34 ; 35 . To mitigate these risks, existing defenses fall into two main categories. Detection-based methods 20 ; 25 ; 35 attempt to identify harmful images, but often suffer from false positives that block benign content 23 . Removal-based methods intervene before or during generation by adjusting the diffusion process at inference time 27 , editing model weights 10 ; 11 , or optimizing prompts 33 . Most existing methods struggle to handle multiple harmful concepts simultaneously. Weight-editing and prompt-based approaches require retraining for new unsafe concepts. In contrast, inference-time methods enable safe generation through lightweight manipulations. One notable approach in this category is Safe Latent Diffusion (SLD) 27 , which utilizes classifier-free guidance to adjust noise estimates away from unsafe concept directions, even when multiple concepts are present. Despite its effectiveness, we observe that SLD sometimes fails to remove harmfulness from images, even under maximum guidance (SLD-max). Moreover, its guidance is applied inconsistently across prompts, i.e. , some prompts become sufficiently safe while others remain unsafe with the same configuration – see Fig. 1 . In light of these limitations, we propose SP-Guard , an inference-time method emphasizing the importance of selective and prompt-adaptive safe guidance to prevent unsafe image generation. We suspect that the reason SLD fails is that it does not reflect how unsafe the generated image will be. Therefore, before presenting our method in detail, we underscore the importance of adapting safety guidance ( i.e. , unsafe concept removal) to each individual prompt. We demonstrate this in Section 2.2 through a comparative analysis of images generated in a straightforward experiment. SP-Guard , detailed in Section 2.3 , is based on the intuition that the similarity between the noise predictions conditioned on the prompt and those conditioned on unsafe concepts can serve as a proxy for estimating the unsafe degree of the generated image. Specifically, SP-Guard proactively estimates the unsafe degree of a prompt and provides safe guidance during inference. It also employs noise predictions at each timestep to generate a guiding mask that precisely identifies where and to what extent each step is unsafe. Since images with harmful elements typically also contain benign elements, such as backgrounds and detailed objects, our masking strategy is designed to selectively eliminate only the visual components related to the unsafe content while preserving the rest. The effectiveness of SP-Guard is shown in Fig. 1 . While SLD yields inconsistent results under the same guidance level ( i.e. , SLD-medium in the second row), due to the varying degrees of prompt harmfulness, SP-Guard consistently produces safe images regardless of the initial prompt harmfulness. Moreover, SP-Guard employs a precise masking strategy that selectively captures regions associated with unsafe concepts, whereas SLD often applies guidance more broadly, affecting unrelated areas and resulting in images that diverge from the original intent (third row). Figure 1 : Selectivity and adaptivity of SP-Guard . SLD lacks an adaptive mechanism and requires different hyperparameter sets depending on the prompt; SLD-medium is sufficient for the right prompt, while SLD-max is necessary for the left prompt. Furthermore, SLD-max applies the safety guidance throughout the entire image, as shown in the guiding mask where yellow ( \scriptstyle\approx\ 1 ) and blue ( \scriptstyle\approx\ 0 ) indicate the extent of guidance, often altering the low-level semantics of the original image. In contrast, SP-Guard selectively targets the unsafe part of the images, providing an appropriate level of safety guidance adaptively for each prompt to ensure safe image generation, without changing the semantics too radically. In Section 3 , we conduct both quantitative and qualitative evaluations of SP-Guard on four benchmark datasets. Our findings indicate that SP-Guard achieves a lower detection rate of unsafe content, effectively preserving the integrity of the original image content. Qualitative analyses further verify that SP-Guard consistently converts unsafe elements into safe content, regardless of the potential harm of the prompt. Furthermore, SP-Guard maintains image fidelity and text alignment comparable to SD, supporting its practicality. The underlying idea of prompt-adaptive and selective guidance opens up new opportunities for broader applications in safe and controllable image generation. Moreover, by concretely analyzing the limitations of previous approaches and highlighting the importance of estimating the prompt-specific potential harmfulness, SP-Guard contributes to the transparency and controllability of safe image generation. We further elaborate on these aspects in Section 4 . 2 Method 2.1 Preliminaries Diffusion-based T2I and Classifier-Free Guidance. Diffusion models 31 are generative models that create samples from Gaussian noise, progressively denoising based on a learned data distribution. The model iteratively predicts an estimate of the noise to be removed. For text-based image generation 25 ; 26 , the estimated noises are conditioned on the text prompt. Classifier-free guidance approach 16 allows conditioning without an additional pre-trained classifier, training the model with or without text prompts randomly to handle both conditional and unconditional images. During inference, the model uses noise estimates \mathbf{\tilde{\epsilon}_{\theta}} at each steps formulated as follows: \displaystyle\mathbf{\tilde{\epsilon}}_{\theta}(\mathbf{z}_{t},\mathbf{c}_{p}):=\mathbf{\epsilon}_{\theta}(\mathbf{z}_{t})+s_{g}(\mathbf{\epsilon}_{\theta}(\mathbf{z}_{t},\mathbf{c}_{p})-\mathbf{\epsilon}_{\theta}(\mathbf{z}_{t})), (1) where \mathbf{z}_{t} is the latent variable at timestep t , and \mathbf{c}_{p} is the text embedding for the prompt p . s_{g} is the guidance scale that controls the strength of conditioning. Semantic and Safe Guidance at Inference. Controlling T2I models to faithfully reflect user intentions in generated images remains a challenging task. One line of research addresses this challenge by classifier-free-guidance to enable semantic control at inference time 4 ; 27

Read the complete text