arXiv:2608.17067cs.AI2026-08

用提示词优化防生成有害图像,无需模型修改

DiSCO: Defending text-to-image generation through distribution-guided contrastive prompt optimization

论文配图:DiSCO: Defending text-to-image generation through distribution-guided contrastive prompt optimization
图 1 · 摘自论文原文
  • 通过对比安全与不安全图像池,动态优化提示词后缀
  • 在红队攻击下使有害生成率降低37.7%和25.13%
  • 纯黑盒部署,适配任何文本到图像系统

随着文本到图像生成模型的发展,其安全性问题日益突出,尤其在暴力、裸露等不适宜工作场合(NSFW)内容生成方面。现有防御多基于白盒假设,依赖文本编码器优化、权重编辑或推理时干预,难以扩展至专有模型。基于大语言模型提示重写等黑盒方法虽具更广适用性,但在我们识别出的“良性对抗”情形下失效:即提示语义上安全,却仍触发有害生成,源于模型学习的数据分布。本文提出DiSCO,一种零样本、严格黑盒的防御机制,完全在提示层运作,可即插即用,无需模型重训练、微调或内部访问。DiSCO通过束搜索进行分布引导的后缀扩展,并利用目标模型自身生成的安全与不安全图像池进行对比评分,迭代自适应反馈直至生成安全内容。我们在I2P基准上验证,DiSCO在多种红队攻击下持续提升未防护及已防护模型的安全性,分别实现37.7%和25.13%的有害生成率降低,同时保持语义保真度并提升图像连贯性。作为黑盒、架构无关模块,DiSCO可无须修改模型直接应用于任意文本到图像系统。

原文摘要 · Abstract (English)

As text-to-image generative models advance, they raise critical safety concerns, particularly the generation of Not-Safe-For-Work (NSFW) content such as violence and nudity, further exacerbated by red-teaming adversarial attacks. Existing defenses predominantly operate under white-box assumptions, relying on text encoder optimization, weight editing, or inference-time intervention, and fundamentally cannot scale to proprietary models. Black-box alternatives based on LLM prompt rewriting offer broader applicability, yet fail in a critical regime we identify as the \textit{benign adversarial} problem: prompts that are linguistically safe but still trigger harmful generation due to the model's learned data distribution. We propose DiSCO, a zero-shot, strictly black-box defense that operates entirely at the prompt level as a plug-and-play module, requiring no model retraining, fine-tuning, or access to model internals. DiSCO performs distribution-guided suffix expansion via beam search, optimized through contrastive scoring over safe and unsafe image pools generated by the target model itself, with iterative adaptive feedback until safe content is produced. We demonstrate that DiSCO consistently enhances the safety of both undefended and defended models on the I2P benchmark under multiple red-teaming attacks, achieving 37.7% and 25.13% ASR reduction, respectively, while maintaining semantic fidelity and improving image coherence. As a black-box, architecture-agnostic module, DiSCO can be readily applied to any text-to-image system without necessitating any changes to the model itself.

文本生成安全防御提示工程黑盒

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。