arXiv:2502.20623cs.CRcs.CV2025-02被引 8

通过微调文本编码器实现安全图像生成,不降质且防有害输出。

SafeText: Safe Text-to-image Models via Aligning the Text Encoder

  • 改用微调文本编码器而非扩散模块来对齐安全策略。
  • 对恶意提示嵌入向量大幅调整,安全提示几乎不变。
  • 在对抗攻击下仍有效,优于六种现有方法。

文本到图像模型在面对不安全提示时可能生成有害图像,带来显著的安全与社会风险。对齐方法旨在修改这些模型,确保即使在不安全提示下也仅生成无害图像。典型文本到图像模型包含两个主要组件:1)文本编码器和2)扩散模块。现有对齐方法主要聚焦于修改扩散模块以防止有害图像生成,但这常导致安全提示下的生成质量严重下降。本文提出SafeText,一种新型对齐方法,通过微调文本编码器而非扩散模块实现对齐。通过调整文本编码器,SafeText显著改变不安全提示的嵌入向量,同时最小化对安全提示的影响。结果是,扩散模块对不安全提示生成无害图像,同时保持安全提示下的图像质量。我们在多个安全与不安全提示数据集上评估SafeText,包括通过越狱攻击生成的数据。结果表明,SafeText能有效防止有害图像生成,对安全提示影响极小,且性能优于六种现有对齐方法。代码与数据将在论文接受后公开。

原文摘要 · Abstract (English)

Text-to-image models can generate harmful images when presented with unsafe prompts, posing significant safety and societal risks. Alignment methods aim to modify these models to ensure they generate only non-harmful images, even when exposed to unsafe prompts. A typical text-to-image model comprises two main components: 1) a text encoder and 2) a diffusion module. Existing alignment methods mainly focus on modifying the diffusion module to prevent harmful image generation. However, this often significantly impacts the model's behavior for safe prompts, causing substantial quality degradation of generated images. In this work, we propose SafeText, a novel alignment method that fine-tunes the text encoder rather than the diffusion module. By adjusting the text encoder, SafeText significantly alters the embedding vectors for unsafe prompts, while minimally affecting those for safe prompts. As a result, the diffusion module generates non-harmful images for unsafe prompts while preserving the quality of images for safe prompts. We evaluate SafeText on multiple datasets of safe and unsafe prompts, including those generated through jailbreak attacks. Our results show that SafeText effectively prevents harmful image generation with minor impact on the images for safe prompts, and SafeText outperforms six existing alignment methods. We will publish our code and data after paper acceptance.

文本生成安全对齐扩散模型图像生成

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