发现扩散模型会生成有害文字,提出针对性微调方案
Beautiful Images, Toxic Words: Understanding and Addressing Offensive Text in Generated Images
- 仅微调模型中负责文本生成的层,避免影响图像质量
- 现有方法无法阻止有害文字生成,且损害正常文本表现
- 发布开源评测基准 ToxicBench,支持多维度评估
当前主流扩散模型(DMs)能生成高度逼真的图像。尽管已有研究成功缓解了视觉层面的不安全内容,我们识别出一种新威胁:图像中嵌入了不适宜工作场合(NSFW)的文字,如侮辱性语言、种族歧视用语和性暗示词汇,对用户构成显著风险。实验表明,所有主流扩散模型(如 SD3、SDXL、Flux、DeepFloyd IF)均存在此问题。现有针对视觉内容的缓解技术在防止有害文字生成方面无效,且严重损害正常文本生成能力。为此,我们提出一种新微调策略,仅针对模型中的文本生成层。构建安全微调数据集时,将每个含 NSFW 提示的输入配对生成两张图:一张保留原始有害词,另一张则以精心设计的无害替代词替换,其余内容保持不变。通过该数据集训练后,模型可有效规避有害文字生成,同时保持良性内容与整体图像质量。为推动该领域研究,我们发布了 ToxicBench——一个开源基准,包含自建微调数据集、一组恶意提示、新评估指标及完整评估流程,可同时衡量图像与文本的不适宜性、文本准确性和图像质量。该基准旨在引导未来对文本到图像模型中 NSFW 文字生成的缓解工作,促进其安全部署。
原文摘要 · Abstract (English)
State-of-the-art Diffusion Models (DMs) produce highly realistic images. While prior work has successfully mitigated Not Safe For Work (NSFW) content in the visual domain, we identify a novel threat: the generation of NSFW text embedded within images. This includes offensive language, such as insults, racial slurs, and sexually explicit terms, posing significant risks to users. We show that all state-of-the-art DMs (e.g., SD3, SDXL, Flux, DeepFloyd IF) are vulnerable to this issue. Through extensive experiments, we demonstrate that existing mitigation techniques, effective for visual content, fail to prevent harmful text generation while substantially degrading benign text generation. As an initial step toward addressing this threat, we introduce a novel fine-tuning strategy that targets only the text-generation layers in DMs. Therefore, we construct a safety fine-tuning dataset by pairing each NSFW prompt with two images: one with the NSFW term, and another where that term is replaced with a carefully crafted benign alternative while leaving the image unchanged otherwise. By training on this dataset, the model learns to avoid generating harmful text while preserving benign content and overall image quality. Finally, to advance research in the area, we release ToxicBench, an open-source benchmark for evaluating NSFW text generation in images. It includes our curated fine-tuning dataset, a set of harmful prompts, new evaluation metrics, and a pipeline that assesses both NSFW-ness and text and image quality. Our benchmark aims to guide future efforts in mitigating NSFW text generation in text-to-image models, thereby contributing to their safe deployment.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。