Token Perturbation Guidance for Diffusion Models

Javad Rajabi, Soroush Mehraban, Seyedmorteza Sadat, Babak Taati

Abstract

Token Perturbation Guidance (TPG) is a novel, training-free method that significantly enhances the image quality and prompt alignment of diffusion models. By shuffling internal token representations during the denoising process, TPG generates a guidance signal that mimics the effectiveness of Classifier-Free Guidance (CFG) without requiring specialized training or conditional inputs. This paper details the TPG mechanism, its geometric properties, and its performance across various state-of-the-art architectures.

Introduction

In the field of generative modeling, Classifier-Free Guidance (CFG) has become the gold standard for ensuring that diffusion models adhere to user-provided text prompts. However, CFG possesses two significant limitations: it requires the model to be explicitly trained with a "null condition" (randomly dropping the text prompt), and it is primarily designed for conditional generation.

Researchers have sought "training-free" alternatives, such as Self-Attention Guidance (SAG) and Perturbed Attention Guidance (PAG), which manipulate internal attention maps to create guidance signals. While useful, these methods often lead to over-smoothed images or poor alignment with complex prompts because their guidance signals do not geometrically align with the denoising direction as effectively as CFG. Token Perturbation Guidance (TPG) addresses this gap by providing a universal guidance mechanism that works for both conditional and unconditional models without additional training.

Methodology: Token Perturbation Guidance

The core of TPG is a simple yet effective two-pass approach executed at each denoising step. During a standard step, the model performs its usual forward pass. In the second pass, TPG "perturbs" the intermediate hidden representations, or tokens, within the denoiser network.

Visual comparison of denoising trajectories across different guidance methods (CFG, PAG, SEG, TPG) over various timesteps.

The perturbation involves a norm-preserving shuffling operation that reorders tokens along the spatial or sequence dimension. Because shuffling is a linear, orthonormal operation, it preserves the statistical properties (the L2 norm) of the tokens. This prevents the model from drifting into "garbage" data ranges while disrupting local structures enough to create a meaningful "bad" version of the prediction. By subtracting the output of this "shuffled" pass from the "standard" pass, the model identifies features essential for a coherent image. This difference acts as the guidance signal, pushing the sampling process toward sharper, more semantically consistent results.

Key Insights and Geometric Analysis

A primary contribution of this work is the analysis of the geometry of TPG guidance vectors. The authors found that TPG’s guidance is nearly orthogonal to the predicted noise, a property it shares with CFG. In contrast, other training-free methods often "oppose" the denoising direction too directly, which explains their tendency to produce blurry or over-smoothed results.

Geometric analysis of guidance vectors: (a) cosine similarity between guidance and noise, (b) cosine similarity between guided and unguided noise, and (c) L2 norm of the guidance vector.

Frequency analysis further reveals that TPG, like CFG, injects strong low-frequency signals in the early stages of denoising to establish global structure and shifts to high-frequency modifications later to refine fine details. TPG is also architecture-agnostic; it works effectively on U-Net-based models like Stable Diffusion 2.1 and newer Diffusion Transformers (DiTs) like Stable Diffusion 3. For DiTs, shuffling only a small fraction of tokens before each block and "unshuffling" them afterward proved highly effective.

Experimental Evaluation

TPG was evaluated using the MS-COCO 2014 validation set, generating 30,000 samples for quantitative metrics such as Fréchet Inception Distance (FID) and CLIP scores. The method was tested as a plug-and-play module on Stable Diffusion XL (SDXL), Stable Diffusion 2.1, and Stable Diffusion 3.

Key results include:

  • Unconditional Generation: On SDXL, TPG improved the FID from a baseline of 124.04 to 69.31, nearly a 2x improvement. On SD 2.1, it achieved an FID of 16.69, outperforming PAG (21.30) and SEG (20.98).
  • Conditional Generation: TPG closely matched the performance of CFG in both prompt alignment and image quality, demonstrating its viability as an alternative when CFG training is unavailable.
  • Visual Quality: Qualitative results show that TPG-guided models produce significantly more realistic textures, such as human faces and complex patterns, compared to the repetitive or abstract textures seen in unguided models.

Limitations and Conclusion

Despite its performance gains, TPG shares a common drawback with CFG and PAG: computational overhead. Requiring two forward passes per denoising step roughly doubles the sampling time. Additionally, TPG's performance is bound by the underlying base model's learned distribution; it cannot generate concepts the model has never seen.

In conclusion, Token Perturbation Guidance offers a powerful, training-free way to boost the performance of diffusion models. By leveraging the simple geometric property of token shuffling, it provides a universal guidance signal that rivals the gold standard of CFG. Future work will focus on optimizing the shuffling strategy and reducing the number of function evaluations to speed up inference.

Summary updated

BibTeX
@inproceedings{rajabi2025token,
  author = {Javad Rajabi and Soroush Mehraban and Seyedmorteza Sadat and Babak Taati},
  title = {{Token Perturbation Guidance for Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=OQFfM96ZcD},
}
Figure