Prompt-aware classifier free guidance for diffusion models

Xuanhao Zhang, Chang LiarXiv 2025 · DOI

TL;DR

Most diffusion models rely on a fixed "guidance scale" (CFG) to balance prompt alignment with image quality, but a one-size-fits-all scale often leads to artifacts or washed-out results. This paper introduces a prompt-aware framework that uses a lightweight predictor to adaptively select the optimal guidance scale for every individual prompt, improving fidelity and alignment without retraining the underlying diffusion model.

What Problem Does This Paper Address?

Classifier-Free Guidance (CFG) is the "secret sauce" behind the success of models like DALL-E and Stable Diffusion. It works by pushing the model’s output away from a generic "unconditional" prediction and toward the specific "conditional" prompt. However, the strength of this push—the guidance scale ($w$)—is typically treated as a static hyperparameter (often set to 7.5 or 5.0).

The authors point out a major flaw: different prompts have different "difficulties." A simple prompt like "a white car" might look best at a low scale to avoid oversaturation, while a complex, multi-object description like "a delicious fruit plate in a silver bowl with grapes, bananas, and peaches" requires a higher scale to ensure the model actually renders every requested detail. Using a fixed scale across these diverse inputs leads to a sub-optimal trade-off between image realism (fidelity) and how well the image matches the text (alignment).

Methods

The researchers propose a three-stage pipeline to make guidance "smart":

Overview of the training data generation (left) and the internal architecture of the lightweight MLP predictor (right).
  1. Guidance-based Dataset Generation: They first "probe" the behavior of pretrained models (SDXL for images, AudioLDM2 for audio). They take a corpus of prompts and generate multiple samples for each using a range of different guidance scales. Each sample is then scored using automated "oracle" metrics like CLIP (for alignment), ImageReward (for human preference), and KID (for fidelity).
  2. Lightweight Agent Score Estimator: Instead of running the expensive diffusion process multiple times at inference to find the best scale, they train a tiny MLP (only ~4M parameters). This predictor takes two inputs:
  3. Semantic Embeddings: High-level meaning from CLIP or CLAP.
  4. Linguistic Complexity: Statistical features like prompt length, entropy, and "modifier diversity." The predictor learns to estimate the quality scores for any given prompt across the entire range of possible scales.

  5. Prompt-based Guidance for Enhanced Sampling: At inference time, the user provides a prompt. The lightweight predictor instantly suggests the "optimal" scale ($w^*$) by maximizing a utility function that balances the predicted metrics while staying reasonably close to a "safe" anchor scale to avoid extreme outliers.

The inference-time sampling process using the predicted optimal guidance scale to guide the diffusion reverse process.

Datasets

The authors validated their approach across two different modalities:

  • Images: Used MSCOCO 2014 for training the predictor and evaluation.
  • Audio: Used AudioCaps to demonstrate that the framework generalizes beyond just visual data.
  • Backbones: They applied their method to SDXL 1.0 (image) and AudioLDM2 (audio), showing it works as a "plug-and-play" enhancement for state-of-the-art pretrained models.

Key Insights and Ideas

  • Guidance as a Variable, Not a Constant: The most significant insight is that the guidance scale is a powerful, underutilized lever. By treating it as an inference-time variable rather than a training-time constant, we can squeeze more performance out of existing models.
  • Linguistic Complexity Matters: The paper highlights that semantic meaning isn't the only thing that dictates the "correct" scale; the structural complexity of the sentence (how many adjectives, how long the string is) is a strong signal for how much guidance the model needs.
  • The "Surrogate" Efficiency: The authors proved that a very small neural network can effectively "mimic" the preferences of much larger, computationally expensive evaluation suites. This allows for "optimal" scale selection in milliseconds, adding negligible overhead to the generation process.

Key Results

The prompt-aware method consistently outperformed "Vanilla CFG" (fixed scale) across multiple metrics:

  • Image Generation (MSCOCO): The method achieved a lower FID (30.74 vs 31.04), indicating better distributional fidelity, and a higher CLIP score (0.33 vs 0.31), indicating better text-image alignment.
  • Audio Generation (AudioCaps): The framework showed improvements across perceptual quality (PQ) and semantic correspondence (PC) metrics, proving the method is modality-agnostic.
  • Qualitative Improvements: The adaptive scale prevents the "washed-out" look in simple prompts and ensures all objects are present in complex ones, effectively smoothing out the "failure modes" of fixed CFG.

Limitations and Future Work

  • Metric Dependency: The framework's "intelligence" is only as good as the metrics used to train the predictor. If CLIP or ImageReward have biases, the predictor will inherit them.
  • Anchor Regularization: The authors use a penalty term to keep the suggested scale near a "default" value. While this prevents total failures, it might also limit the model from exploring highly unconventional (but potentially better) scales.
  • Future Directions: The authors suggest exploring more "principled criteria" for balancing the trade-offs between diversity and alignment. They also aim to test the framework on more ambiguous or "noisy" prompts to see how robust the scale selection remains under uncertainty.

Summary updated

BibTeX
@misc{zhang2025prompt,
  author = {Xuanhao Zhang and Chang Li},
  title = {{Prompt-aware classifier free guidance for diffusion models}},
  year = {2025},
  eprint = {2509.22728},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.22728},
}
Figure