用强化学习让扩散模型生成更安全图像,不删内容也能防色情
ShieldDiff: Suppressing Sexual Content Generation from Diffusion Models through Reinforcement Learning
- 通过设计含CLIP与裸露检测的奖励函数,微调扩散模型
- 在多个数据集上有效减少色情生成,同时保持图像质量
- 对恶意提示有更强鲁棒性,适合需要安全生成的场景
随着生成式AI的发展,文本到图像(T2I)模型具备生成多样化内容的能力,但生成内容难以完全控制,存在生成不适内容的风险。本文聚焦于在不降低图像质量的前提下,通过强化学习微调预训练扩散模型,消除T2I模型生成不适宜工作场所(NSFW)内容的能力。提出的方法采用定制化奖励函数,结合CLIP和裸露检测奖励,去除模型中与裸露相关的视觉表示,同时保留语义一致性。该方法使模型对恶意提示更具鲁棒性,因为不安全特征已在潜在空间被抑制。在多个数据集上的实验表明,该方法在减少不当内容生成的同时,保持良性图像及恶意提示生成图像的高保真度。相较于五种现有SOTA方法,本方法在去除色情内容与保持图像质量方面表现相当,并在最新的黑盒攻击模型下展现出更优鲁棒性。所提方法可作为语义相关安全对齐的抗NSFW生成基准。
原文摘要 · Abstract (English)
With the advance of generative AI, the text-to-image (T2I) model has the ability to generate various contents. However, the generated contents cannot be fully controlled. There is a potential risk that T2I model can generate unsafe images with uncomfortable contents. In our work, we focus on eliminating the NSFW (not safe for work) content generation from T2I model while maintaining the high quality of generated images by fine-tuning the pre-trained diffusion model via reinforcement learning by optimizing the well-designed content-safe reward function. The proposed method leverages a customized reward function consisting of the CLIP (Contrastive Language-Image Pre-training) and nudity rewards to prune the nudity contents that adhere to the pret-rained model and keep the corresponding semantic meaning on the safe side. In this way, the T2I model is robust to unsafe adversarial prompts since unsafe visual representations are mitigated from latent space. Extensive experiments conducted on different datasets demonstrate the effectiveness of the proposed method in alleviating unsafe content generation while preserving the high-fidelity of benign images as well as images generated by unsafe prompts. We compare with five existing state-of-the-art (SOTA) methods and achieve competitive performance on sexual content removal and image quality retention. In terms of robustness, our method outperforms counterparts under the SOTA black-box attacking model. Furthermore, our constructed method can be a benchmark for anti-NSFW generation with semantically-relevant safe alignment.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。