Growth Inhibitors for Suppressing Inappropriate Image Concepts in Diffusion Models

## Abstract

Abstract. Text-to-image diffusion models have shown the ability to learn a diverse range of concepts. However, it is worth noting that they may also generate undesirable outputs, consequently giving rise to significant security concerns. Specifically, issues such as Not Safe for Work (NSFW) content and potential violations of style copyright may be encountered. Since image generation is conditioned on text, prompt purification serves as a straightforward solution for content safety. Similar to the approach taken by LLM, some efforts have been made to control the generation of safe outputs by purifying prompts. However, it is also important to note that even with these efforts, non-toxic text still carries a risk of generating non-compliant images, which is referred to as implicit unsafe prompts .
Furthermore, some existing works fine-tune the models to erase undesired concepts from model weights.
This type of method necessitates multiple training iterations whenever the concept is updated, which can be time-consuming and may potentially lead to catastrophic forgetting.
To address these challenges, we propose a simple yet effective approach that incorporates non-compliant concepts into an erasure prompt.
This erasure prompt proactively participates in the fusion of image spatial features and text embeddings.
Through attention mechanisms, our method is capable of identifying feature representations of non-compliant concepts in the image space. We re-weight these features to effectively suppress the generation of unsafe images conditioned on original implicit unsafe prompts.
Our method exhibits superior erasure effectiveness
while achieving high scores in image fidelity
compared to the state-of-the-art baselines. WARNING: This paper contains model outputs that may be offensive.

## 1. Introduction

In recent years, diffusion models (Ho et al., ; Liu et al., ; Sohl-Dickstein et al., ; Mansimov et al., ) have demonstrated outstanding image generation capabilities, enabling the creation of highly sophisticated and diverse digital media (Saharia et al., ; Nichol et al., ; Ramesh et al., ).
However, due to training on vast and unfiltered data of varying quality (Rombach et al., ; Schuhmann et al., ),
diffusion models inevitably learn unsafe concepts, such as copyrighted content (Somepalli et al., ; Shan et al., ) and Not Safe For Work (NSFW) content, which will cause serious downstream risks
(Somepalli et al., ; Wang et al., ; Liang et al., ).

For text-to-image diffusion models, due to the guiding role of prompts, it is straightforward to consider adjusting them to avoid the generation of non-compliant content mentioned above.
In fact, in the field of large language models (LLM) (Touvron et al., ; Brown et al., ; Li and Liang, ; Wen et al., ), there have been numerous works addressing the issue of toxic text and proposing various solutions to solve it.
Similarly, within the diffusion model domain, analogous efforts have emerged with the objective of mitigating the impact of inappropriate or unsafe words in prompts. These efforts entail employing
techniques such as censoring negative targets from text embeddings and preprocessing prompts with language models.
However, it is important to note that while these methods ensure the semantic safety of prompts, the possibility of generating non-compliant images still persists.
We refer to these non-toxic prompts as implicit unsafe prompts.

Unfortunately, many of the prompts leading to NSFW content are implicit unsafe prompts, including symbols, cryptic words, and references to scenes like ”beach” or ”bedroom,” as well as character descriptions like ”sexy”. The I2P dataset (Schramowski et al., ), containing a significant number of implicit and explicit unsafe prompts, exemplifies these characteristics and is currently widely utilized for testing the erasure capabilities of different methods.
For style content, some descriptive prompts can also lead to the generation of images with similar styles. A typical example is that, based on the prompt ”a painting of starry night” an image in Van Gogh’s style will be generated even without mentioning his name.
Another prevalent method for tackling the generation of non-compliant content is model fine-tuning, which leverages the concept of classifier-free guidance (Ho and Salimans, ; Kawar et al., ; Sun et al., ) to strive for a safe output by navigating away from the negative space or converging towards the positive space within the semantic domain. Nonetheless, this approach is time-consuming, as it necessitates fine-tuning the model each time the definition of non-compliant content is updated. Moreover, changes in parameters can potentially result in catastrophic forgetting, thereby compromising the model’s overall performance.

To this end, we propose a training-free approach to Erase non-compliant concepts conditioned on Implicit Unsafe Prompts (EIUP). Specifically, during the diffusion of the original implicit unsafe prompt, we additionally introduce an erasure prompt containing the concept of non-compliance, such as ”nude”, while engaging in attention computation in the image space to obtain the unsafe features. We visualized these features and found that the unsafe region became clear and focused along with the image during diffusion, as shown in Figure 1.
Subsequently, these features are integrated into the attention maps of the original prompt, allowing for flexible weight adjustment to effectively suppress their influence.
In addition to effectively addressing implicit prompts, our proposed EIUP demonstrates its general applicability for all prompt types, including explicit prompts and those that are inherently safe. For explicit unsafe prompts, our approach demonstrates its capability to extract potentially inappropriate or unsafe regions, facilitating subsequent processing. Meanwhile, when handling safe prompts, it is able to preserve prompts’ semantics without destroying the quality of the image.
In general, our proposed EIUP is capable of pinpointing inappropriate or unsafe features and suppressing them in real-time during the diffusion process, which enables effortless deployment for mitigating non-compliant concepts. To the best of our knowledge, our work is the first to manipulate attention maps to solve the problem of non-compliant concepts.
Extensive experiments demonstrate that EIUP has superior NSFW and stylistic erasure capabilities for implicit unsafe prompts, and at the same time it is able to avoid damage to other concepts, maintaining excellent image fidelity and semantic similarity.
Our contributions are summarized as follows:

- •
During the diffusion process of the implicit unsafe prompt, we additionally introduce an erasure prompt for attention computation, to accurately obtain the unsafe features in the image space.
- •
Leveraging the extracted unsafe features, we selectively inject them into the attention maps of the original prompt and re-weight them. This effectively suppresses the impact of them, resulting in the generation of safe images.
- •
Extensive experiments are conducted to demonstrate the exceptional erasure capabilities of our proposed EIUP across any prompt types, including explicit and implicit prompts, as well as absolutely safe prompts.
Moreover, our approach achieves superior results on fidelity scores and red-teaming assessments.

## 2. Preliminary and Related Work

### 2.1. Diffusion Models and Potential Risks

Diffusion Models. DMs construct a Markov chain to learn the underlying distribution of training data. Given a schedule $\{\beta_{t}\}_{t=1}^{T}$, a real image $\mathbf{x}_{0}\sim p_{\text{data}}(\mathbf{x}):=q(\mathbf{x})$ is gradually injected by a series of Gaussian noises, eventually conforming a standard Gaussian distribution. This forward process can obtain the posterior probability as follows:

$$ (1) $\displaystyle q(\mathbf{x}_{t}|\mathbf{x}_{t-1})$ $\displaystyle:=\mathcal{N}(\mathbf{x}_{t};\sqrt{1-\beta_{t}}\mathbf{x}_{t-1}, \beta_{t}\mathbf{I}),$ $\displaystyle q(\mathbf{x}_{T}|\mathbf{x}_{0})$ $\displaystyle\approx\mathcal{N}(\mathbf{x}_{T};\mathbf{0},\mathbf{I}).$ $$

The subsequent reverse process, parameterized by $\theta$, starts from pure Gaussian noise $p(\mathbf{x}_{T})=\mathcal{N}(\mathbf{0},\mathbf{I})$ and iteratively denoises it over multiple times to reconstruct the original image $x_{0}$ as follows:

$$ (2) $p_{\boldsymbol{\theta}}(\mathbf{x}_{0:T})=p(\mathbf{x}_{T})\prod_{t=1}^{T}p_{ \boldsymbol{\theta}}(\mathbf{x}_{t-1}|\mathbf{x}_{t}).$ $$

To decrease the overall overhead, Latent Diffusion Model (LDM) (Rombach et al., ) operates in the latent variable space (Esser et al., ; Karras et al., ; Li et al., ) rather than the pixel space. Mapping the image $x$ to the latent representation $z_{t}=\mathcal{E}(x)$ with a powerful pre-trained auto-encoder $\mathcal{E}$, such as VAE (Kingma and Welling, ; Frans et al., ), makes it more conducive to capture meaningful features.
For text-to-image generation, the model takes the embeddings $c$ from a text prompt $p$ as an additional condition during training and then learns to predict the noise $\epsilon_{\theta}(z_{t},c,t)$. In conjunction with the above, the loss function is defined as:

$$ (3) $\mathcal{L_{LDM}}=\mathbb{E}_{z_{t}\in\mathcal{E}(x),t,c,\epsilon\sim\mathcal{ N}(0,1)}[\|\epsilon-\epsilon_{\theta}(z_{t},c,t)\|_{2}^{2}],$ $$

where $\epsilon\sim\mathcal{N}(\mathbf{0},\mathbf{I})$ and $t\sim\mathcal{U}(\{1,\ldots,T\})$.

Potential Risks. Diffusion models (DMs) have emerged as an advanced and sophisticated approach to image generation through incremental noise addition. However, trained on large amounts of unfiltered training data, DMs may generate problematic content, such as NSFW images and copyright issues, and can lead to catastrophic consequences.
For example, Korshunov and Marcel () highlighted the social risk of tarnishing the reputation of celebrities by replacing their faces with those in pornographic videos.
Additionally, Schramowski et al. () noted the potential association between the words Japan and nudity, while also highlighted that DMs could produce inappropriate images under certain prompts.
For copyright issues, the influx of fake paintings created by DMs into the market has affected people’s judgment and disrupted the market order (Shan et al., ).

### 2.2. Toxic-Clean Prompt Optimization

Given the significance of text in generating images, many efforts have been made to purify prompts to generate safe content images in text-to-image DMs.
Li et al. () adopts soft-weighted regularization and inference-time text embeddings optimization to remove unwanted content from text embeddings. Wu et al. () proposes a universal prompt optimizer by training the language model with reward score.

In fact, undesirable biases and toxicity in the text have been studied a lot for generative language models (Schick et al., ; Dathathri et al., ; Santos et al., ; Welbl et al., ; Wu et al., ).
As illustrated by Schick et al. (), non-compliant content can easily be generated using only words that are perfectly safe by themselves. Similarly, for prompts that do not contain any unsafe words, there is still a probability of generating non-compliant images due to the hidden scenes and character information. For instance, the prompt ”a girl lying on the beach” could generate an image of a nude girl. Without mentioning ”Van Gogh”, a prompt such as ”a painting of a starry night” is most likely to lead to his style.
Thus, the task of erasing non-compliant concepts for implicit unsafe prompts poses a greater challenge.
In this work, we aim to suppress the undesirable target generation from implicit unsafe prompts.

### 2.3. Erasing Concepts

Recently, a handful of studies targeted erasing concepts in DMs, primarily through three types of methods, i.e., dataset filtering, fine-tuning, and intervening in the inference process.

Dataset Filtering.
Previous works on dataset filtering
directly remove specific images in the training dataset and then retrain the model from scratch (Nichol et al., ; Schuhmann et al., ; Mishkin et al., ; sd2). While straightforward, this approach demands substantial resources and may lead to unforeseen consequences (O’Connor, ).

Fine-tuning. Another type of methods involves fine-tuning the model to erase concepts(Zhang et al., ; Heng and Soh, ; Kim et al., ; Gandikota et al., ; Wu et al., ) . Studies such as
ESD (Gandikota et al., ), Ablating Concepts (Kumari et al., ), and SDD (Kim et al., ) focus on the distinction between noises specific to the target concepts and those without condition. DT (Ni et al., ) uses scrambled grid to reconstruct the correlation between undesired concepts and their corresponding image domain. Furthermore, some studies have integrated the method of machine unlearning (MU) (Bourtoule et al., ), which refers to the challenge of reducing the impact of specific data points in a pre-trained model. SalUn (Fan et al., ) applies weight saliency to direct MU’s attention toward specific model weights about targets. Drase-Diff (Wu et al., ) formulates the unlearning problem as a constrained problem, aiming to preserve the utility of the diffusion model on the remaining data and scrub the information associated with forgetting data by deviating the learnable generative process from the ground-truth denoising procedure.
However, approaches involving fine-tuning can be time-consuming and may result in the model misunderstanding concepts during weight adjustment, potentially leading to catastrophic forgetting.
For instance, we find that ESD usually generates forest images to avoid nude image generation, as shown in Figure 7, and this loss of other semantics also suggests that fine-tuning is not precise enough. In contrast, our model does not require modifying model weights, thus avoiding potential harm to the model. Beyond this, we can also achieve efficiency and maintain similar semantics.

Inference Intervention. The third type of approaches involves intervening in the inference process. It is typically achieved by modifying the outputs through a classifier (Rando et al., ; Bedapudi, ) or providing guidance during inference (Schramowski et al., ).
One notable characteristic of such approaches is their plug-and-play nature, which eliminates the need for additional training and facilitates convenient deployment and testing.
In this work, we adjust the attention map to guide the inference process and thus avoid the necessity for training, which also shows the advantages of plug-and-play.
Additionally, our proposed EIUP is demonstrated to easily counteract the damage caused by corrupted prompts compared to other approaches.

## 3. Method

Our goal is to erase non-compliant concepts such as NSFW content and art style issues in the unsafe images that are generated from implicit unsafe prompts. To achieve this, we propose a training-free approach (EIUP) that localizes and extracts the attention features of non-compliant concepts in the latent image space (Section 3.1) and selectively suppresses their impact in intermediate results to ensure precise erasure of non-compliant regions (Section 3.2).
Figure 2 illustrates our complete process.
During the target localization and attention feature Adjustment stages, we inject the attention map of the target token obtained from the erasure prompt into $M$, the attention maps of the original prompt, and re-weight it to obtain $\widehat{M}$. By multiplying $\widehat{M}$ with the updated V, we obtain the safe output.
Our approach is shown to be non-invasive for benign prompts and effective for both implicit and explicit unsafe prompts (Section 3.3).

Figure: Figure 2. Overview of EIUP. In the target localization stage, we fuse Q from image latent variables with an additional K from the erasure prompt to obtain the corresponding attention map, $M^{*}$. In the attention feature adjustment stage, we inject the attention map of the target token in $M*$ before the [EOT] position of M, which is obtained by fusing K from the original prompt and the same Q. Then we re-weight the attention map of the target token to suppress the unsafe features to obtain $\widehat{M}$. Finally, we multiply the updated V with $\widehat{M}$ to obtain the safe output.
Refer to caption: x2.png

### 3.1. Target Localization

During the noise prediction process in DMs, the two modalities of text and image interact, where the visual spatial features and the text embeddings are fused in Cross-attention layers(Hertz et al., ).
According to the attention mechanism, learned linear layers $\ell_{Q}(\cdot),\ell_{K}(\cdot),\ell_{V}(\cdot)$ are used to obtain Q, K and V.
Q comes from projecting the image latent variables $z_{t}$ to a query matrix through $\ell_{Q}(z_{t})$.
K and V come from projecting text embedding $c$ to a key matrix and a value matrix through $\ell_{k}(c)$ and $\ell_{V}(c)$, respectively.
Thus, the formula for the attention maps $M$ is obtained as:

$$ (4) $M=\text{Softmax}\left(\frac{QK^{T}}{\sqrt{d}}\right),$ $$

where d represents the latent projection dimension of the key and value.
The attention maps can capture the pixel weights of each token, which we refer to as the feature of that token in the image space.
Next, the weighted result $A=M\times V$ will update the spatial features.
Typically, in Stable Diffusion (SD), the maximum number of tokens is 77.
Assuming there is a text encoder $\Gamma$ turning input prompt $p$ into text embeddings $c=\Gamma(p)$, the full attention maps of
$p$ can be denoted as
$M_{t}=\{{m}_{SOT},{m}_{0},\cdots,{m}_{|{p}|-1},{m}_{EOT}\}$,
where the length of ${m}_{EOT}$ is $N-|{p}|-2$
and the remaining tokens are 1.

To obtain the target region of non-compliant concepts in image space, we additionally input undesirable concepts like ”nude” in the form of erasure prompts $p^{*}$, which are later encoded into text embeddings $c^{*}$.
Each time computing the attention maps between the original embeddings $c$ and latent variable $z_{t}$, the attention maps between $c$ and $z_{t}$ will also be computed as follows:

$$ (5) ${M^{*}}=\mathrm{Softmax}\left(\frac{Q{K^{*}}^{T}}{\sqrt{d}}\right)=\mathrm{ Softmax}\left(\frac{\ell_{Q}(z_{t})\ell_{K}({\boldsymbol{c^{*}}})^{T}}{\sqrt{d }}\right).$ $$

This allows us to capture the manifestation of the erasure concept in the intermediate results and accurately locate it in the spatial features of the image.

We plotted the average attention maps for visualization.
Figure 1 shows the attention maps of the original prompt and erasure prompt. We can observe that target token nude in the erasure prompt is visually reflected, which is denoted as
${m}_{0}^{*}$.
Besides, the more closely the pixels match the description of the token, the more pronounced their representation is on the image, from where the conclusion that a strong correlation with the center position of the image is obtained. Observing the diffusion process, we also find that the target object and the image become gradually clearer together.

### 3.2. Attention Feature Adjustment

As we mentioned above,
attention encapsulates the overall compositional information, so manipulating it can lead to changes in the output.
One way is to re-weight the original attention maps by multiplying a weight value $w$ for the target token.
If this weight value is negative, it will guide the corresponding features in the attention map to weaken; otherwise, it will strengthen these features.

To intuitively demonstrate the effect of attention re-weighting, we provide an example with an explicit unsafe prompt.
Let $p$=”A painting of a nude person”, whose attention maps are $M_{t}=\{{m}_{SOT},\\
{m}_{a},{m}_{paiting},{m}_{of},{m}_{a},{m}_{nude},{m}_{person},{m}_{EOT}\}$.
To reduce the negative influence of token nude, we use a negative weight value $w$ to weaken it,
obtaining new attention maps
$M_{t}=\{{m}_{SOT},{m}_{a},{m}_{paiting},\\
{m}_{of},{m}_{a},w\cdot{m}_{nude},{m}_{person},{m}_{EOT}\}$
. The girls are wearing clothes in the left of Figure 3.

Figure: Figure 3. Left: for explicit unsafe prompt, directly re-weighting the unsafe token with a negative value can change the output. Right: for implicit unsafe prompt, it is hard to find unsafe tokens, we observe that re-weighting ”on” affects the whole region corresponding to the girl, and re-weighting ”girl” affects the girl’s face.
Refer to caption: x3.png

A naive approach for erasing the target is to directly weaken the attention maps of tokens, whose distribution is similar to the attention map of the unsafe token in the erasure prompt.
Unfortunately, as non-compliant concepts may appear implicitly in tokens related to scenes and character features, the quality and semantics of the image will be severely compromised.
In other words, the presence of non-compliant concepts in local regions is not convincing. This method leads to worse results as shown in the right of Figure 3. Re-weighting token ”on”, whose attention map is the most similar to the target token ”nude”, affects the whole region corresponding to the girl, and re-weighting token ”girl” only affects the girl’s face.

So, how to precisely suppress the target region? Though we individually analyzed the attention map of each token in Section 3.1, all tokens collectively contribute to the overall effect in the diffusion process.
Based on this condition, we inject the attention map of the target token from the erasure prompt into the original prompt and weaken the influence of its region, thus achieving the precise erasure of the undesirable concept based on the premise of precise localization. The injection operation re-extracts the information inherent in the image space without affecting the semantics of the subsequently generated images. More details about the generality will be discussed in Section 3.3.
We can weaken the influence of the target location we have identified, thereby changing the attributes of the output image.

Specifically, having obtained the attention maps of the original prompt
$M_{t}$ and the attention maps of ${M}_{t}^{*}$,
we first insert the attention maps of the unsafe tokens
$\{{m}_{0}^{*},\cdots,{m}_{|{p}|-1}^{*}\}$ from ${M}_{t}^{*}$ into the position before ${m}_{EOT}$ in $M_{t}$.
Then we can get
$M_{t}^{inject}=\{{m}_{SOT},{m}_{0},\cdots,{m}_{|{p}|-1},{m}_{0}^{*},\cdots,{m}
_{|{p}|-1}^{*},{m}_{EOT}\}$.
Next, we weaken the target tokens in $M_{t}^{inject}$ with a weight sequence $W$, which sets the position of the target tokens to a negative value $w$, and $1$ for all other positions. Finally, the result
$\widehat{M}_{t}=\{{m}_{SOT},{m}_{0},\cdots,{m}_{|{p}|-1},\\
w\cdot{m}_{0}^{*},\cdots,w\cdot{m}_{|{p}|-1}^{*},{m}_{EOT}\}$
replace the original attention maps $M_{t}$.
If there are multiple concepts, the result will be
$\widehat{M}_{t}=\{{m}_{SOT},{m}_{0},\cdots,\\
{m}_{|{p}|-1},{w_{1}}\cdot{m}_{0}^{1},\cdots,{w_{1}}\cdot{m}_{|{p}|-1}^{1},{w_
{2}}\cdot{m}_{0}^{2},\cdots,{w_{2}}\cdot{m}_{|{p}|-1}^{2},\cdots,{m}_{EOT}\}$, which means we can inject more attention maps of undesirable concepts into $M_{t}$ and re-weight different values for them.
To match the dimensions and align text features with image features, we also place target concept $p_{erase}$ after $p_{origin}$ to recalculate $\widehat{V}$. Finally, we obtain $A_{t}=\widehat{M}_{t}\times\widehat{V}$ as shown in the bottom of Figure 2.

### 3.3. Analysis

Furthermore, we consider the broad applicability of this approach. It is challenging for both humans and generative models to find out at a glance whether text without obvious unsafe words will generate non-compliance images and require intervention while generation. Therefore, we expect the model to preserve the complete semantics when encountering an absolutely safe prompt and achieve erasure effects on unsafe prompts.

The specific mechanism of how the adjustment method operates is demonstrated in Figure 4.
In the scenario where the user inputs an absolutely safe prompt, the original prompt and erasure prompt point to different areas, and the erasure prompt falls into the non-compliant space.
The attention map obtained by the target token in the erasure prompt is sparse and has very small values. Thus its overall impact is minimal, and injecting it does not affect the output.
We can observe that the direction of generation gradually moves away from the unsafe space.
On the other hand, both explicit and implicit unsafe prompts inputted by users fall into the non-compliant space, and the attention feature adjustment method moves the diffusion process away from this space. It should be noted that even in the scenario where the user inputs an explicit unsafe prompt with inappropriate words, the target token in the erasure prompt still obtains attention similar to the inappropriate words in the original prompt. This accurately identifies the focused region and erases the target in the overall image space.

Figure: Figure 4. Elicitation Mechanisms. We successfully guide the diffusion process (indicated by the dashed arrow) of Gaussian noise away from the non-compliant concepts (indicated by the red region). The (a) represents the case of explicit and implicit unsafe prompts, where both the original prompt (indicated by the blue arrow) and the erasure prompt (indicated by the red arrow) fall in the red region. The (b) represents the case of an absolutely safe prompt, with the origin prompt and erasure prompt falling in different regions.
Refer to caption: x4.png

## 4. Experiment

In this section, we conduct empirical evaluations to examine the effectiveness of our method.

### 4.1. Setup

As a plug-and-play method, we choose to conduct all our experiments on Stable Diffusion $v1.4$ (CompVis, ), which has been open-sourced on Huggingface (huggingface, ). The diffusion process has 50 steps and starts adjusting from the first step. The guidance scale of SD is set to $7.5$, following the convention in most works (Schramowski et al., ; Gandikota et al., ; Kumari et al., ).

Baselines.
We will use the previous methods as baselines for comparison: SD $v1.4$ (CompVis, ) indicates the base model;
SLD (Schramowski et al., ) guides away from unsafe content during inference;
for fine-tuning methods, we choose ESD-u (Gandikota et al., ), which fine-tune the parameters of the cross-attention parts, respectively.

Figure: Figure 5. Top: erasure results of SLD, ESD-u, and EIUP on I2P dataset for each body part. Bottom: the erasure results of the three methods for the Red-Teaming evaluation testset. Overall, EIUP has the best performance.
Refer to caption: x5.png

Figure: Figure 6. Erase non-compliant concepts in Implicit unsafe prompt. The first row of prompts mainly reflects the effect of related words on nudity . The second row mainly embodies the effect of symbols on nudity. The third line mainly embodies the erasure effect of violence and horror.
Refer to caption: x6.png

Figure: Figure 7. Erasure results of different methods for ”a photo of a person without clothes”. We find that SLD fails to fully erase the concept of nudity, ESD leads to irrelevant images, such as forests and bedrooms, and EIUP performs the best.
Refer to caption: x7.png

Figure: Figure 8. Style erasure with EIUP. EIUP can handle prompts that implicitly contain style information as (a), as well as prompts that explicitly contain style information as (b).
Refer to caption: x8.png

Figure: Figure 9. Multi-concept erasure with EIUP. The first row shows the erasure of ”nude” and ”horror.” The second row shows the erasure of ”nude” and ”Van Gogh”. The far-right column displays the results of single-concept erasure.
Refer to caption: x9.png

### 4.2. Erasure of NSFW Content

We use the Inappropriate Image Prompts (I2P) dataset (Schramowski et al., ) to validate the effectiveness of our proposed EIUP. It collects 4703 unsafe prompts and provides seeds, which can lead to the generation of inappropriate images related to hate, harassment, violence, self-harm, sexual content, shocking images, illegal activity. The frequent words in these prompts do not have a clear correlation with inappropriate images, and only $1.5\%$ of the prompts are classified as toxic by the PERSPECTIVE API (conversationai, ). This also emphasizes that banning dangerous words simply cannot suppress the generation of non-compliant content, making the handling of implicit unsafe prompts crucial.

Following the previous works
(Gandikota et al., ; Schramowski et al., ), we generate a corresponding image for each prompt and seed in the I2P dataset, then use ”nude” as the erasure prompt to suppress
this NSFW concept. Subsequently, we evaluate the proportion of nude images generated from the I2P dataset using pre-trained NudeNet classifiers (Bedapudi, ). The erasure ratios for different body parts exposed are presented at the top of Figure 5.
Compared to other methods, our method covers more exposed body parts, especially in female private areas such as ”female breast” and ”female genitalia”, and the reason for the relatively poor erasure effect on male nudity may be attributed to the SD model’s training dataset and confusion about the concept.

In addition, we demonstrate superior erasure effectiveness for non-compliant concepts about nude, violent and horror conditioned on implicit unsafe prompts as shown in Figure 6.
For explicit unsafe prompts, we generate images with the prompt ”a photo of a person without clothes” and results are shown in Figure 7. We observed that SLD cannot completely erase the nudity concept, while ESD, although effective in erasing, may lead to the appearance of other semantic concepts unrelated to ”person”, such as forests and bedrooms. And our method performs the best.

Red-Teaming Evaluation.
Red-teaming (Tsai et al., ; Rando et al., ; Chin et al., ; Mehrabi et al., ; Zhang et al., ) is a process of evaluating methods to reveal potential weaknesses and vulnerabilities, with the goal of improving the security, reliability, and efficiency of the method. This evaluation typically involves simulating the behavior of attackers to test the system’s defense capabilities and assess its response to various security threats.

To test our method’s resistance to interference in complex prompt scenarios, we use Ring-A-Bell (Tsai et al., ) for evaluation. This is a model-agnostic red teaming tool for text-to-image DMs, which can prepare the entire dataset of prompts needed for evaluation without prior knowledge of the target model. Specifically, Ring-A-Bell first extracts the overall representation of sensitive and inappropriate concepts, and then automatically injects them into the base prompt to form a problematic prompt. This completely black-box approach is beneficial for a fair evaluation of the model.

We continue to use ”nude” as the erasure prompt, apply to the 95 inappropriate prompts obtained from Ring-A-Bell (including explicit and implicit unsafe prompts), and generate 10 images for each prompt. At this stage, we introduce the Q16 classifier (Schramowski et al., ), which can detect a wide range of unsafe content, working in conjunction with NudeNet. If either classifier issues a warning, we classify the image as unsafe. All images generated from the SD v1.4 model with this dataset are unsafe and we assess other models’ performance based on SD1.4 as shown in Figure 5. Overall, our method stands out the most, validating its reliability and robustness for corrupted prompts. However, through analyzing cases that did not pass the evaluation, we observed limitations in covering side nudity and male upper body.

Figure: Figure 10. The first row of the results shows the choice of injection positions. Each group of images corresponds to the original image generated by SD, the image generated by EIUP with injection before [EOT], and the image generated by EIUP with injection after [SOT]. It is clear that placing the injection before [EOT] has minimal impact on the quality of the generated images. The second row of results shows the impact of choosing different weight values. As the weight values decrease (ranging from -3 to -10), the people in the images gradually become more conservatively dressed.
Refer to caption: x10.png

### 4.3. Erasure of Style

To safeguard copyrights and prevent the model from replicating artists’ styles, erasing style is important. In this section, we conducted experiments on style erasure effects. We utilized the artist’s name as the erasure prompt to identify the features requiring suppression during the diffusion process. Unlike the NSFW task, which involves a single target token, the style erasure task includes the same number of target tokens as the length of the artist’s name. These tokens’ corresponding attention maps were injected before the [EOT] token, suppressing the features with identical weight values.
We focused on two easily imitated artists, ”Monet” and ”Van Gogh.” As mentioned in Section 1, ”a painting of starry night” can result in images similar to Van Gogh’s style. We initially experimented with this implicitly unsafe prompt and concluded, as shown in Figure 8(a), that it could be effectively erased. Subsequently, we formulated the prompt ”a painting of […] in […] style,” where the first […] represents the object to be generated, and the second […] denotes the artist’s name. Figure 8(b) demonstrates Van Gogh’s rough and powerful brushstrokes are replaced by other styles, while Monet’s hazy works become clearer.

### 4.4. Erasure of Multiple Concepts

This section describes the results on multi-concept erasure. Based on the NSFW and style tasks, we divided the tasks into those involving multiple NSFW concepts simultaneously and those involving both NSFW and style concepts. Here, we assigned corresponding weight values to each concept to provide different safety indexes for each concept. We show the erasure effects of ”nude” and ”horror,” as well as the erasure effects of ”nude” and ”Van Gogh,” in the first and second rows of Figure 9, respectively.
In addition to generating results for multi-concept erasure, we conducted experiments to erase individual concepts separately, as shown on the right.
Our proposed EIUP method demonstrated excellent results in both scenarios, highlighting its effectiveness in complex scenes.

### 4.5. Injection Positions and Weight Values

Injection Positions.
In Section 3.2, we discussed the process of injecting the attention map of the target token into the attention maps of the original prompt before the [EOT] token.
For the sake of semantic coherence, we need to place it near the tokens of the original prompt. Placing it after [SOT] and before [EOT] are the two most appropriate options. We compared these two options and show the results in the first row of Figure 10. The order of images in each group corresponds to: the original image generated by SD, the image generated by EIUP with injection before [EOT], and the image generated by EIUP with injection after [SOT]. We clearly found that placing the injection before [EOT] minimally affects image quality, while placing it after [SOT] leads to large areas of solid color in the image. Consequently, we choose to place the injection before [EOT].

Scale of Erasure.
Weight values play a crucial role in adjusting the degree of concept erasure. Prior to conducting the experiment, we assign negative weight values for each concept to suppress them during the diffusion stage. For NSFW concepts, we generally use weight values ranging from -20 to -3, while for style concepts, we generally use weight values ranging from -1 to 0. Therefore, in multi-concept erasure, different target tokens will be suppressed to different degrees, with higher suppression observed as weight values decrease.
As shown in the second row of Figure 10, we demonstrate the effects of choosing different weight values.
As weight values decrease(ranging from -3 to -10), people in the image are gradually dressed in more clothes.
In the experiments mentioned above, we used a weight value of -10 for nudity erasure and -0.5 for style erasure. In the Red-teaming experiments from Section 4.2, some problematic samples identified can be addressed by decreasing the weight values. However, it should be noted that blindly decreasing weight values may lead to a risk of deteriorating image quality.

**Table 1. The FID and CLIP score of COCO-30K.**
| Method | FID${\downarrow}$ | CLIP score${\uparrow}$ |
| --- | --- | --- |
| SD v1.4 | 14.30 | 0.2626 |
| SLD | 18.22 | 0.2543 |
| ESD-u | 17.34 | 0.2381 |
| EIUP (Ours) | 13.30 | 0.2590 |

### 4.6. Image Fidelity Preserving

In this section, we discuss the performance of our EIUP in image fidelity and text alignment.
To assess these aspects, we employ the MS-COCO captions dataset and utilize two metrics: FID (Heusel et al., ), which quantifies the distance between real and generated images, and CLIP score (Hessel et al., ), which measures the alignment of the generated images with their corresponding descriptions.
Results are presented in Table 1.
It can be observed that our method maintains consistency between image semantics and descriptions, while achieving the best results in fidelity, reducing the FID metric from $14.30$ to $13.30$. In all, EIUP achieves the goal of erasing target concepts and preserving the semantics of other elements

## 5. Conclusion

This paper proposes a plug-and-play, training-free method to erase non-compliant concepts during the diffusion process. Except for the original prompt, we additionally use an erasure prompt containing non-compliant concepts and calculate the attention maps to extract its features in the image space. Then, by injecting these features into the attention maps of the original prompt and reducing their impact, we successfully erase unwanted concepts. Our method achieves superior erasure effectiveness and image fidelity compared to existing methods. Besides, our evaluations in the Red-teaming assessment show that our method exhibits strong resistance to interference and robustness.

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 5
presentation: 2
questions: 1. Could the authors clarify the purpose of the SOT and EOT tokens?
2. In Section 4, line 260, how are the starting and ending positions determined?
soundness: 3
strengths: 1. This work addresses a significant issue by reducing the generation of NSFW content.
2. Extensive visualizations illustrate the effectiveness of GIE.
summary: This paper proposes GIE, a method for eliminating NSFW content in diffusion models. The authors leverage the attention map of target concepts, reweighting them to synthesize "growth inhibitors" that represent undesired content. These reweighted attention maps are then injected into the diffusion process. Additionally, an adaptor is trained to determine the suppression scale dynamically. GIE outperforms eight baseline methods and effectively removes implicit concepts like "nude."
weaknesses: 1. The writing is somewhat difficult to follow in certain sections. See questions.

2. There is a lack of ablation studies on each component of GIE, such as the role of the adaptor.

3. The paper does not discuss or compare with related methods like the one proposed in [1], which also targets implicit concept removal in diffusion models.

[1] Implicit Concept Removal of Diffusion Models, ECCV 2024.

I will consider increasing the score if my concerns are addressed.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 2
questions: 1) Proposed method contradicts with the statement in Line 252: "A naive approach to erasure is to weaken tokens whose attention maps are similar to the extracted features. Unfortunately, this method might not work because...". The reason is the following:
- First, original Attention Map Groups are injected with the Growth Inhibitor I.
- Second, the attended representation MV is calculated based on injected Attention Map Group M'.
- As a result, Final output of Cross-Attention is calculated with M'V.
- In SD v1.4, Value (V) is a linear projection of token embeddings c.
- Considering all of these mentioned properties, the final output reduces to calculating Final Output = (M_[SOT] x V) + ... + (M*_[target_concept] x V) + (M_[EOT] x V)
- As this final output calculation demonstrates, (M*_[target_concept] x V) directly corresponds to weakening every single token embedding -- since V is a function of token embedding c.

It would be good to clarify this. 

2) What happens when the concept prompt has more than 1 tokens? For example, when erasing the concept of Van Gogh, the token embeddings has the form <c_[SOT], c_[Van], c_[Gogh], c_[EOT] >. How to reduce c_[Van], c_[Gogh] into one, unified representation? Is Simultaneous Suppression of Multiple Concepts strategy described in Section 4.3 applied here?
soundness: 2
strengths: 1) The proposed method doesn't require any fine-tuning concentrated on cross-attention layers -- which is the general methodology in the recent works in concept erasing literature, therefore, this work distinguishes itself from the other works.
2) By training a Suppression Scale Adapter, the proposed method does not require additional training/finetuning for each different concepts.
3) As shown in some qualitative experiments, after concept erasing operation, most of the spatial details are preserved -- especially when compared to other methods.
summary: Authors focuses on a concept erasing problem which is caused by explicit NSFW prompts and importantly implicit unsafe prompts. Authors propose to inject "Growth Inhibitors", which is a slice of attention map group of target concept, to current attention map group. The re-weighting scheme of "Growth Inhibitors" are provided by proposed Suppression Scale Adapter.
weaknesses: 1) There is no clear declaration of why injected Growth Inhibitors I is inserted right before [EOT]. There is no ablation study on the position of Growth Inhibitors. More clarifications and motivations behind this, and ablations will help us to understand the proposed method better.

2) No quantitative experimentation on multi-concept erasing. Furthermore, no qualitative results for more than 2 concept erasing. This makes it difficult to assess the real performance of this method.

3) Qualitative results shows that, proposed method can only erase semantic concept up to a certain extend. For instance, in Figure 7 Bottom row, when erasing Van Gogh and Nude concepts, the resultant image still preserves the style of Van Gogh depicted by the color schema. This problem is also seen in Figure 13.

---

confidence: 4
contribution: 4
initial_rating: 6
presentation: 3
questions: - In line 415 (416?), how could the CLIP model be leveraged to determine whether specific objects exist in the generated images?
- Do the NSFW removal rates used as a metric refer to the ratio averaged over test prompts calculated using NudeNet?
soundness: 3
strengths: - The main strength of the proposed method is that it does not require fine-tuning, which is highly beneficial in terms of efficiency. Additionally, the method is widely applicable to architectures similar to Stable Diffusion.
- Most of the proposed methods are based on observations that support the validity of the approach.
- Compared to the baselines, GIE erases the harmful and other concepts exceptionally well.
summary: This paper proposes a new method GIE that injects growth inhibitors into the attention map to erase certain harmful concepts. The method can be applied without fine-tuning, with the injection level controlled by an auxiliary network. Experimental results show the effectiveness of GIE in erasing nude concepts while preserving the image quality.
weaknesses: - While most methods are based on observations, I feel the paper lacks *sufficient intuition* or theoretical justification for each proposed method. How does inserting an attention map for concept erasure lead to the removal of specific concepts? What is the meaning of these new attention maps in M_replace? How does this reweighted attention map function as a growth inhibitor? It is good that you avoid the naive approach of simply suppressing the most related attention map, but since your solution deviates from previous attention modulation methods, while we can see that it works, it is challenging to understand why it works so effectively.
- It appears that the adapter learns a function to map intermediate values to suppression values. However, intermediate values vary significantly with different text prompts. Although the authors demonstrate the generalizability of learned prompts, it is questionable whether training the adapter on a limited dataset will generalize effectively when the test set encompasses a broader range of concepts.
- The model's applicability is currently limited to Stable Diffusion 1.4. Since the method relies on the *specific architecture*, I believe additional experiments on different Stable Diffusion models would better showcase its effectiveness.
- This also relates to weakness #3: although GIE is effective and efficient, it requires a *high level of engineering*, such as designing an adaptive model and correctly injecting features. The optimal range of weights (w), suppression levels, and injection positions might vary depending on the target concepts or diffusion models. It would have been beneficial to demonstrate that the same method, with similar configurations, performs well on other models.

---

confidence: 2
contribution: 3
initial_rating: 5
presentation: 3
questions: see weakness
soundness: 3
strengths: - The writing is clear and easy to follow.
- The discussed topic and motivation are both innovative and significant.
- The proposed method can erase inappropriate concepts from text-to-image diffusion models without the need for fine-tuning.
summary: The paper presents a novel approach for erasing inappropriate concepts from text-to-image diffusion models without the need for fine-tuning. The authors identify that these models, while capable of generating sophisticated images, can inadvertently produce content that is ethically and legally problematic, such as NSFW material and copyright-infringing styles. The proposed method GIE addresses this by injecting growth inhibitors based on identified features related to inappropriate concepts during the diffusion process. An adapter is also trained to infer the suppression scale, accommodating varying degrees of inappropriateness. The paper claims that GIE effectively captures subtle word manifestations at the image level, enabling precise erasure of target concepts without affecting other concepts or image quality.
weaknesses: - Some previous works on LLMs for enhancing diffusion models, such as [1][2][3][4], should be included in the related work section.
- I'm curious about the explicit or implicit damage to the model itself when inappropriate concepts are removed. Generally, inappropriate concepts may not be entirely independent of some "appropriate concepts." This analysis needs to be considered.
- What is the cost of using GPT-4o for data processing in this paper? For instance, the expenses and time involved. Such information should be listed to provide valuable insights to the community.





[1] SUR-adapter: Enhancing text-to-image pre-trained diffusion models with large language models

[2] PromptCrafter: Crafting Text-to-Image Prompt through Mixed-Initiative Dialogue with LLM

[3] LLM Blueprint: Enabling Text-to-Image Generation with Complex
and Detailed Prompts.

[4] LLM-grounded Diffusion: Enhancing Prompt Understanding of Text-to-Image Diffusion Models with Large Language Models.

Meta-review: **Summary of the Paper**   
This paper introduces GIE, a method for erasing harmful or inappropriate concepts, including implicit NSFW content, from text-to-image diffusion models. Rather than requiring additional fine-tuning, GIE directly modifies the model’s diffusion process by injecting “growth inhibitors,” subsets of reweighted attention maps associated with unwanted concepts. These adjusted attention signals guide the diffusion model in suppressing specific content while preserving overall image quality. Experimental results demonstrate that GIE eliminates problematic visual elements, such as nude representations, without degrading other aspects of the generated images.

**Strengths:**  
* The proposed method achieves effective concept removal, including implicit NSFW content, without the need for fine-tuning.   
* The approach leverages a suppression scale adapter, enabling flexible, dynamic control over erasure intensity across various architectures.   
* The authors provide extensive qualitative results that show preserved spatial details and superior concept removal compared to baseline methods.

**Weaknesses:**   
* The adapter’s generalizability to target concepts that differ significantly from those seen during training remains uncertain, potentially requiring retraining and limiting its applicability across a broader concept space.   
* The paper lacks sufficient descriptions and motivations for specific components of the proposed method, such as structure markers and attention maps. However, the authors provided comprehensive explanations during the rebuttal period, addressing these concerns.   
* The experiments did not include essential evaluations, such as ablation studies, assessments across various model versions, and multi-concept erasing experiments. In response, the authors conducted and presented additional experiments during the rebuttal phase.
   
**Main Reasons for the Decision**   
The paper tackles a critical problem, erasing NSFW content from text-to-image diffusion models and offering a novel approach that differentiates it from prior methods. Reviewers initially raised concerns about the lack of an ablation study, evaluations of different models, and more precise explanations of the proposed method. However, the authors provided comprehensive clarifications during the rebuttal phase and conducted additional experiments. These efforts have alleviated the primary reservations, leaving the reviewers in agreement that the paper now offers both conceptual advancements. Given the strengthened evidence, improved clarity, and responsiveness to feedback, the consensus is that the paper merits acceptance.

Decision: Accept (Poster)