Guiding a Diffusion Model by Swapping Its Tokens

Weijia Zhang, Yuehao Liu, Shanyan Guan, Wu Ran, Yanhao Ge +2 more
4/9/2026
cs.CV

No official code found. Best implementation: VISION-SJTU/SSG (39 stars, last commit 2026-06-16).

Abstract

Classifier-Free Guidance (CFG) is a widely used inference-time technique to boost the image quality of diffusion models. Yet, its reliance on text conditions prevents its use in unconditional generation. We propose a simple method to enable CFG-like guidance for both conditional and unconditional generation. The key idea is to generate a perturbed prediction via simple token swap operations, and use the direction between it and the clean prediction to steer sampling towards higher-fidelity distributions. In practice, we swap pairs of most semantically dissimilar token latents in either spatial or channel dimensions. Unlike existing methods that apply perturbation in a global or less constrained manner, our approach selectively exchanges and recomposes token latents, allowing finer control over perturbation and its influence on generated samples. Experiments on MS-COCO 2014, MS-COCO 2017, and ImageNet datasets demonstrate that the proposed Self-Swap Guidance (SSG), when applied to popular diffusion models, outperforms previous condition-free methods in image fidelity and prompt alignment under different set-ups. Its fine-grained perturbation granularity also improves robustness, reducing side-effects across a wider range of perturbation strengths. Overall, SSG extends CFG to a broader scope of applications including both conditional and unconditional generation, and can be readily inserted into any diffusion model as a plug-in to gain immediate improvements.

View on arXivView PDF

Code Implementations(1)

VISION-SJTU/SSGCommunity25%

[CVPR 2026 Oral] Guiding a Diffusion Model by Swapping Its Tokens

390Shell, PythonApr 16, 20264 months ago

Similar Papers

Cite this paper

@article{zhang2026guiding,
  title  = {Guiding a Diffusion Model by Swapping Its Tokens},
  author = {Weijia Zhang and Yuehao Liu and Shanyan Guan and Wu Ran and Yanhao Ge and Wei Li and Chao Ma},
  year   = {2026},
  eprint = {2604.08048},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2604.08048v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2604.08048.svg)](https://codeofpaper.com/paper/2604.08048)

Discussion