通过速度编辑实现安全的少步生成
Safe Few-Step Generation via Velocity Editing
摘要
流匹配技术最近成为文本到图像生成领域的一种有效方法,它能够通过较少的采样步骤实现高质量的生成效果。随着这些模型被越来越多地应用于实际场景中,确保生成内容的安全性与无敏感性就变得至关重要。然而,如何将安全处理与概念去除方法适配到这种新的生成框架中仍然是一个挑战。传统方法大多依赖多次去噪步骤中的迭代轨迹调整,或者基于CLIP模型的提示嵌入处理方式。这些设计方式在流匹配-Based文本到图像生成过程中带来了诸多问题:有限的采样步骤限制了迭代修正的效果,而现代上下文感知文本编码器则降低了基于嵌入处理的有效性。本文提出了VESFlow一种无需训练的安全处理方法,它能够在极少的采样步骤下实现安全输出。利用流匹配模型能够学习到速度信息这一特性,我们可以通过安全的后验条件直接修改速度场。VESFlow能够将轨迹引导至安全结果,同时保持提示条件的不变。基于VESFlow在良性提示下不会改变输出的事实,我们进一步引入了基于风险评分的过滤机制,从而减少计算成本,同时保留良性提示的生成效果。在此基础上,我们又提出了VESFlow+,这是一种更强大的版本,它不仅将速度向安全方向调整,还会将其从不安全方向推开。实验结果表明,VESFlow+能够去除目标概念,使得NudeNet在Ring-A-Bell模型上的攻击成功率降至6.3%,在MMA-Diffusion模型上则降至6.8%。同时,它还能在良性提示下保持良好的生成效果。
English Abstract
Flow matching has recently emerged as a strong paradigm for state-of-the-art text-to-image (T2I) generation, enabling high-quality generation with a small number of sampling steps. As these models are increasingly integrated into real-world applications, ensuring safe and non-sensitive content generation has become a critical requirement. However, adapting safety and concept removal methods to this new generation framework remains an open challenge. Specifically, prior methods largely rely on iterative trajectory steering across a number of denoising steps or on CLIP-centric prompt embedding manipulation. These design assumptions pose fundamental bottlenecks for safety in flow matching-based T2I generation, where limited sampling steps constrain iterative correction and modern context-aware text encoders diminish the effectiveness of embedding-level interventions. In this paper, we propose VESFlow, a training-free safety method tailored to flow matching with extremely few sampling steps. Leveraging the fact that flow matching models learn the marginal velocity, we directly edit the velocity field via a safe-conditional posterior. VESFlow steers the trajectory toward safe outputs while leaving the conditioning prompt unchanged. Building on the observation that VESFlow leaves outputs unchanged under benign prompts, we further introduce a risk score-based filtering that bypasses velocity editing to reduce computational cost while preserving benign prompt generation. Based on this filtering, we propose VESFlow+, a stronger variant of VESFlow that not only edits the velocity toward the safe direction, but also pushes it away from the unsafe direction. Experimental results show that VESFlow+ removes the target concept, reducing the attack success rate by NudeNet to 6.3% on Ring-A-Bell and 6.8% on MMA-Diffusion on the 4-step MeanFlow model, while preserving fidelity on benign prompts.