PromptSafe:面向安全文本到图像生成的门控提示微调
PromptSafe: Gated Prompt Tuning for Safe Text-to-Image Generation
AI总结:
提出门控提示微调框架 PromptSafe,通过纯文本软嵌入与推理时门控机制自适应调节防御强度,在保持良性生成质量的同时实现SOTA安全防护,并具备强泛化与抗攻击能力。
摘要:
文本到图像(T2I)模型展现出了卓越的生成能力,但仍然容易生成不安全(NSFW)内容,例如暴力或露骨的图像。尽管近期的内容审核工作引入了通过在输入后附加防御标记来进行软提示引导微调的方法,但这些方法通常依赖于大规模精选的图文数据集,并在推理时应用静态的、一刀切的防御策略。然而,这不仅导致了高昂的计算成本和良性图像质量的下降,而且对现实世界提示词中多样且细微的安全需求适应能力有限。为了解决这些挑战,我们提出了 PromptSafe,这是一个门控提示微调框架,它将轻量级的纯文本监督软嵌入与推理时的门控控制网络相结合。我们不再使用昂贵的图文数据集进行训练,而是首先使用 LLM 将不安全的提示词重写为语义对齐但安全的替代词,从而构建一个高效的纯文本训练语料库。在此基础上,我们优化了一个通用的软提示,在扩散去噪过程中排斥不安全嵌入并吸引安全嵌入。为了避免过度抑制良性提示词,我们引入了一种门控机制,该机制根据估计的提示词毒性自适应地调整防御强度,从而将防御强度与提示词风险对齐,确保对有害输入提供强力保护的同时保持良性生成质量。在多个基准和 T2I 模型上的广泛实验表明,PromptSafe 实现了 SOTA 的不安全生成率(2.36%),同时保持了高保真度的良性生成。此外,PromptSafe 展现出对未见有害类别的强大泛化能力、跨扩散模型架构的鲁棒可迁移性,以及在自适应对抗攻击下的弹性,凸显了其在安全和可扩展部署中的实用价值。
英文摘要:
Text-to-image (T2I) models have demonstrated remarkable generative capabilities but remain vulnerable to producing not-safe-for-work (NSFW) content, such as violent or explicit imagery. While recent moderation efforts have introduced soft prompt-guided tuning by appending defensive tokens to the input, these approaches often rely on large-scale curated image-text datasets and apply static, one-size-fits-all defenses at inference time. However, this results not only in high computational cost and degraded benign image quality, but also in limited adaptability to the diverse and nuanced safety requirements of real-world prompts. To address these challenges, we propose PromptSafe, a gated prompt tuning framework that combines a lightweight, text-only supervised soft embedding with an inference-time gated control network. Instead of training on expensive image-text datasets, we first rewrite unsafe prompts into semantically aligned but safe alternatives using an LLM, constructing an efficient text-only training corpus. Based on this, we optimize a universal soft prompt that repels unsafe and attracts safe embeddings during the diffusion denoising process. To avoid over-suppressing benign prompts, we introduce a gated mechanism that adaptively adjusts the defensive strength based on estimated prompt toxicity, thereby aligning defense intensity with prompt risk and ensuring strong protection for harmful inputs while preserving benign generation quality. Extensive experiments across multiple benchmarks and T2I models show that PromptSafe achieves a SOTA unsafe generation rate (2.36%), while preserving high benign fidelity. Furthermore, PromptSafe demonstrates strong generalization to unseen harmful categories, robust transferability across diffusion model architectures, and resilience under adaptive adversarial attacks, highlighting its practical value for safe and scalable deployment.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。