Simple Algorithm
Deep Learning · Emergence · 28 min

Guidance & Conditioning

Classifier and classifier-free guidance, autoguidance and steering generation with text and images.

Sample a conditional diffusion model exactly as it was trained, and its images often follow the prompt only loosely. So most text-to-image systems spend a second network evaluation per step and push the prediction away from an unconditional one. This trick, guidance, works remarkably well, and it provably does not sample the distribution it was derived from.

What you’ll learn

  • Compare the ways a condition enters a denoiser (adaptive normalization, cross-attention, concatenation, zero-initialized control branches), and prove that a zero-initialized branch leaves a pretrained model unchanged yet receives gradient.
  • Derive classifier guidance from Bayes' rule and the perturbed-Gaussian reverse step, and explain what the gradient scale does to fidelity and diversity.
  • Derive classifier-free guidance from an implicit classifier, compute guided predictions in both common conventions, and explain why large guidance oversaturates.
  • Prove in a Gaussian example that guided sampling does not sample the tilted target, and assess guidance intervals and autoguidance.

Getting the condition into the network

A conditional denoiser estimates the score of pt(x∣c)p_t(\mathbf x\mid c), the noised data restricted to condition cc (a class, a caption, a depth map). Bayes' rule pt(x∣c)=pt(c∣x) pt(x)/p(c)p_t(\mathbf x\mid c)=p_t(c\mid\mathbf x)\,p_t(\mathbf x)/p(c) splits that score in two, because p(c)p(c) does not depend on x\mathbf x:

∇xlog⁡pt(x∣c)=∇xlog⁡pt(x)⏟unconditional score+∇xlog⁡pt(c∣x)⏟classifier on noisy inputs\nabla_{\mathbf x}\log p_t(\mathbf x\mid c)=\underbrace{\nabla_{\mathbf x}\log p_t(\mathbf x)}_{\text{unconditional score}}+\underbrace{\nabla_{\mathbf x}\log p_t(c\mid\mathbf x)}_{\text{classifier on noisy inputs}}
Conditioning can estimate the left side directly, by training on pairs (x,c)(\mathbf x,c). Guidance, the subject of the rest of this lesson, reweights the two terms on the right. Here tt indexes noise levels, and ϵθ(xt,t,c)\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,c) is the conditional noise predictor of Diffusion Models.
MechanismHow cc entersTypical conditionsExamples
Embedding with adaptive normalizationcc is embedded and added to the step embedding; each block regresses a scale and shift applied after normalization, AdaGN⁡(h,y)=ys⊙GroupNorm⁡(h)+yb\operatorname{AdaGN}(\mathbf h,\mathbf y)=\mathbf y_s\odot\operatorname{GroupNorm}(\mathbf h)+\mathbf y_bclass labels, pooled text embeddings, noise levelADM (Dhariwal & Nichol, 2021); DiT's adaLN-Zero (Peebles & Xie, 2023)
Cross-attentionimage positions query the token vectors of a text encoderpromptslatent diffusion, Imagen
Concatenationan image-shaped condition is stacked onto the noisy input's channelslow-resolution image, masksuper-resolution stages of cascades; inpainting
Control brancha trainable copy of the encoder reads a spatial condition and adds its features back through zero-initialized 1×11\times1 convolutionsedges, depth, pose, segmentationControlNet (Zhang, Rao & Agrawala, 2023)
Systems combine them: Imagen adds a pooled text embedding to the step embedding and cross-attends to the full token sequence. For class conditioning in a transformer, Peebles & Xie found adaLN-Zero better than in-context tokens or cross-attention, which also added about 15% to the compute. ControlNet's role in image translation is described in Conditional GANs & Image-to-Image Translation.

ControlNet and adaLN-Zero share one design rule: a new pathway starts as a no-op. DiT regresses, besides a scale and shift, a gate α\boldsymbol\alpha on each residual branch and initializes it to zero, so every block begins as the identity. ControlNet locks the pretrained network and connects the trainable copy through convolutions whose weights and biases start at zero, so on the first step the system is exactly the pretrained model, whatever the condition. Why does such a branch ever learn?

Classifier guidance

Classifier guidance (Dhariwal & Nichol, 2021, building on Sohl-Dickstein et al., 2015, and Song et al., 2021) uses the classifier term directly. Train a classifier pϕ(c∣xt,t)p_\phi(c\mid\mathbf x_t,t) on images noised to every level (an ordinary classifier has never seen such inputs), then bias every reverse step toward images it assigns to class cc.

DerivationA Gaussian step, tilted by a classifier
  1. p(xt−1∣xt,c)=Z pθ(xt−1∣xt) pϕ(c∣xt−1),pθ(xt−1∣xt)=N(μ,Σ)p(\mathbf x_{t-1}\mid\mathbf x_t,c)=Z\,p_{\boldsymbol\theta}(\mathbf x_{t-1}\mid\mathbf x_t)\,p_\phi(c\mid\mathbf x_{t-1}),\qquad p_{\boldsymbol\theta}(\mathbf x_{t-1}\mid\mathbf x_t)=\mathcal N(\boldsymbol\mu,\Sigma)

    The class-conditional reverse step is the unconditional one reweighted by the classifier at the new point, with a normalizer ZZ:

  2. log⁡pϕ(c∣xt−1)≈(xt−1−μ)⊤g+const\log p_\phi(c\mid\mathbf x_{t-1})\approx(\mathbf x_{t-1}-\boldsymbol\mu)^\top\mathbf g+\text{const}

    The step is narrow, so over its width the log-classifier is nearly linear: expand it to first order around μ\boldsymbol\mu, with g=∇xlog⁡pϕ(c∣x)∣x=μ\mathbf g=\nabla_{\mathbf x}\log p_\phi(c\mid\mathbf x)\big|_{\mathbf x=\boldsymbol\mu}:

  3. −12(x−μ)⊤Σ−1(x−μ)+(x−μ)⊤g=−12(x−μ−Σg)⊤Σ−1(x−μ−Σg)+const ⟹ xt−1∼N(μ+Σg, Σ)-\tfrac12(\mathbf x-\boldsymbol\mu)^\top\Sigma^{-1}(\mathbf x-\boldsymbol\mu)+(\mathbf x-\boldsymbol\mu)^\top\mathbf g=-\tfrac12(\mathbf x-\boldsymbol\mu-\Sigma\mathbf g)^\top\Sigma^{-1}(\mathbf x-\boldsymbol\mu-\Sigma\mathbf g)+\text{const}\ \Longrightarrow\ \mathbf x_{t-1}\sim\mathcal N(\boldsymbol\mu+\Sigma\mathbf g,\ \Sigma)

    Add the Gaussian's log-density and complete the square. The product is again Gaussian with the same covariance and a shifted mean:

  4. ϵ^(xt)=ϵθ(xt,t)−s1−αˉt  ∇xtlog⁡pϕ(c∣xt)\hat{\boldsymbol\epsilon}(\mathbf x_t)=\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t)-s\sqrt{1-\bar\alpha_t}\;\nabla_{\mathbf x_t}\log p_\phi(c\mid\mathbf x_t)

    In practice a gradient scale ss multiplies the shift, giving N(μ+s Σg,Σ)\mathcal N(\boldsymbol\mu+s\,\Sigma\mathbf g,\Sigma). Since s∇log⁡pϕ(c∣x)=∇log⁡(pϕ(c∣x)s/Z′)s\nabla\log p_\phi(c\mid\mathbf x)=\nabla\log\big(p_\phi(c\mid\mathbf x)^s/Z'\big), a scale s>1s>1 guides toward a sharpened classifier. For deterministic samplers the same correction is made on the noise prediction, using the score form of Diffusion Models:

In practice the scale mattered more than the derivation suggests. Guiding an unconditional ImageNet model with s=1s=1 produced samples to which the classifier gave about 50% probability for the requested class, yet which did not look like that class; s=10s=10 fixed it. Guiding a model that was already class-conditional worked best:

ImageNet 256×256256\times256Scale ssFID ↓Inception Score ↑Precision ↑Recall ↑
Unconditional modelnone26.2139.700.610.63
Unconditional model1012.0095.410.760.44
Conditional modelnone10.94100.980.690.63
Conditional model14.59186.700.820.52
Conditional model109.11283.920.880.32
From Dhariwal & Nichol (2021), Table 4. Guidance raises precision and Inception Score and lowers recall: fidelity bought with diversity. FID, which penalizes both failures, is best at a moderate scale (the metrics are defined in Evaluating Generative Models). These results are the "beat GANs" of the paper's title: the guided conditional model's 4.59 against BigGAN-deep's 6.95 at this resolution.
Check your understanding

Why can't classifier guidance simply use an off-the-shelf ImageNet classifier?

  1. Its gradient with respect to the input image cannot be computed
  2. Guidance needs ∇log⁡p(c∣xt)\nabla\log p(c\mid\mathbf x_t) at every noise level, and a classifier trained on clean images gives meaningless predictions and gradients on heavily noised inputs
  3. The classifier must share the diffusion model's weights
  4. Classifier gradients are zero for correctly classified images
Show the answer

B. Guidance needs ∇log⁡p(c∣xt)\nabla\log p(c\mid\mathbf x_t) at every noise level, and a classifier trained on clean images gives meaningless predictions and gradients on heavily noised inputs

The correction uses the classifier on xt\mathbf x_t, which for most of the chain is mostly noise. Dhariwal & Nichol trained classifiers on the same noising distribution as the diffusion model. Training-free variants instead apply a clean-image classifier or loss to the denoised estimate x^0(xt)\hat{\mathbf x}_0(\mathbf x_t) and backpropagate through the denoiser, as diffusion posterior sampling does for inverse problems (Chung et al., 2023).

Classifier-free guidance

Classifier guidance needs a second network trained on noisy data, and stepping along a classifier's input gradient resembles an adversarial attack on it, which raised the question whether its gains on classifier-based scores such as Inception Score and FID reflected better images at all. Classifier-free guidance (Ho & Salimans, 2022) removes the classifier. One network ϵθ(xt,t,c)\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,c) is trained as usual, except that cc is replaced by a null token ∅\varnothing with probability puncondp_{\text{uncond}}, so it also learns the unconditional prediction ϵθ(xt,t,∅)\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,\varnothing).

DerivationGuidance with an implicit classifier
  1. pti(c∣x)∝pt(x∣c)pt(x)⟹∇xlog⁡pti(c∣x)=−ϵ∗(x,t,c)−ϵ∗(x,t,∅)1−αˉtp^{i}_t(c\mid\mathbf x)\propto\frac{p_t(\mathbf x\mid c)}{p_t(\mathbf x)}\quad\Longrightarrow\quad\nabla_{\mathbf x}\log p^{i}_t(c\mid\mathbf x)=-\frac{\boldsymbol\epsilon^*(\mathbf x,t,c)-\boldsymbol\epsilon^*(\mathbf x,t,\varnothing)}{\sqrt{1-\bar\alpha_t}}

    Bayes' rule defines a classifier from the two densities the network models, and its score is a difference of their scores; with exact noise predictors ϵ∗=−1−αˉt ∇log⁡pt\boldsymbol\epsilon^*=-\sqrt{1-\bar\alpha_t}\,\nabla\log p_t:

  2. ∇log⁡pt(x∣c)+w ∇log⁡pti(c∣x)=(1+w) ∇log⁡pt(x∣c)−w ∇log⁡pt(x)\nabla\log p_t(\mathbf x\mid c)+w\,\nabla\log p^{i}_t(c\mid\mathbf x)=(1+w)\,\nabla\log p_t(\mathbf x\mid c)-w\,\nabla\log p_t(\mathbf x)

    Apply classifier guidance with weight ww to the conditional model, using this implicit classifier:

  3. ϵ~θ=(1+w) ϵθ(xt,t,c)−w ϵθ(xt,t,∅)=ϵθ(xt,t,∅)+γ(ϵθ(xt,t,c)−ϵθ(xt,t,∅))\tilde{\boldsymbol\epsilon}_{\boldsymbol\theta}=(1+w)\,\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,c)-w\,\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,\varnothing)=\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,\varnothing)+\gamma\big(\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,c)-\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,\varnothing)\big)

    Multiply by −1−αˉt-\sqrt{1-\bar\alpha_t} and substitute the network for the exact predictors. This is Ho & Salimans's guided prediction; the second form, with scale γ=1+w\gamma=1+w, is the one most software and later papers use:

  4. Read as a density, the guided score belongs to pt(x∣c)1+wpt(x)−w∝pt(x∣c) pti(c∣x)wp_t(\mathbf x\mid c)^{1+w}p_t(\mathbf x)^{-w}\propto p_t(\mathbf x\mid c)\,p^i_t(c\mid\mathbf x)^w: the conditional tilted toward points the implicit classifier finds unambiguous, the reading taken in the Artificial Intelligence course's Deep Layer lesson on diffusion. Two caveats: a trained network's difference ϵθ(⋅,c)−ϵθ(⋅,∅)\boldsymbol\epsilon_{\boldsymbol\theta}(\cdot,c)-\boldsymbol\epsilon_{\boldsymbol\theta}(\cdot,\varnothing) need not be the gradient of any classifier, and, as the next step proves, the sampler does not reach the tilted density anyway.

Predict before you look

At one pixel, the conditional prediction is ϵθ(xt,t,c)=0.3\boldsymbol\epsilon_{\boldsymbol\theta}(\mathbf x_t,t,c)=0.3 and the unconditional one is 0.50.5. With Ho & Salimans's w=3w=3 (scale γ=4\gamma=4), what is the guided noise estimate at that pixel?

Show the answer

-0.3

(1+w) 0.3−w 0.5=1.2−1.5=−0.3(1+w)\,0.3-w\,0.5=1.2-1.5=-0.3, or equivalently 0.5+4 (0.3−0.5)=−0.30.5+4\,(0.3-0.5)=-0.3. The condition moved the prediction by −0.2-0.2; guidance multiplies that difference by γ=4\gamma=4, landing outside the interval between the two predictions. Guidance extrapolates.

Ho & Salimans's ImageNet 64×6464\times64 sweep shows the trade-off cleanly (puncond=0.1p_{\text{uncond}}=0.1; 0.1 and 0.2 performed about equally, 0.5 worse). FID, which rewards both fidelity and coverage, is best with a little guidance and then degrades, while Inception Score, which rewards confident, class-typical images, rises throughout:

  • w=0w=0: FID 1.80, IS 53.7
  • w=0.1w=0.1: FID 1.55, IS 66.1
  • w=1w=1: FID 12.6, IS 170.1
  • w=4w=4: FID 26.2, IS 260.2

Text-to-image systems typically run far stronger guidance than the FID optimum, trading coverage for prompt adherence and polish: Imagen relied on large guidance weights, and Lin et al. (2024) used γ=7.5\gamma=7.5 in their Stable Diffusion experiments. Two practical variants follow from the formula. A negative prompt replaces the unconditional prediction with the prediction for an unwanted description, so every step moves away from it. And since each step costs two evaluations, guidance distillation (Meng et al., 2023) trains a student that takes ww as an input and reproduces the guided output in one evaluation (Few-Step Generation).

What guidance samples, and better guides

The tilted-density reading suggests that guided sampling draws from π(x)∝p0(x∣c)γ p0(x)1−γ\pi(\mathbf x)\propto p_0(\mathbf x\mid c)^{\gamma}\,p_0(\mathbf x)^{1-\gamma}, γ=1+w\gamma=1+w. It does not. At each noise level the sampler follows γ∇log⁡pt(x∣c)+(1−γ)∇log⁡pt(x)\gamma\nabla\log p_t(\mathbf x\mid c)+(1-\gamma)\nabla\log p_t(\mathbf x), but that is not the score of π\pi blurred to the same noise level: tilting and adding noise do not commute (Chidambaram et al., 2024). A one-dimensional Gaussian example makes the gap exact.

DerivationGuided probability flow for Gaussians
  1. sγ(x;σ)=−γ x−mv+σ2−(1−γ) xu+σ2=−a(σ) x+b(σ),a(σ)=γv+σ2+1−γu+σ2s_\gamma(x;\sigma)=-\gamma\,\frac{x-m}{v+\sigma^2}-(1-\gamma)\,\frac{x}{u+\sigma^2}=-a(\sigma)\,x+b(\sigma),\qquad a(\sigma)=\frac{\gamma}{v+\sigma^2}+\frac{1-\gamma}{u+\sigma^2}

    Use the noise-level form of the probability-flow ODE, dx/dσ=−σ s(x;σ)dx/d\sigma=-\sigma\,s(x;\sigma), for data blurred to p(x;σ)=p0∗N(0,σ2)p(x;\sigma)=p_0*\mathcal N(0,\sigma^2) (the form that The Design Space of Diffusion Models works with). Let the unconditional density be N(0,u)\mathcal N(0,u) and the conditional N(m,v)\mathcal N(m,v). Blurring adds σ2\sigma^2 to each variance, so the guided score is linear in xx:

  2. ln⁡V(0)=ln⁡σmax⁡2−γln⁡v+σmax⁡2v−(1−γ)ln⁡u+σmax⁡2u → σmax⁡→∞  γln⁡v+(1−γ)ln⁡u\ln V(0)=\ln\sigma_{\max}^2-\gamma\ln\frac{v+\sigma_{\max}^2}{v}-(1-\gamma)\ln\frac{u+\sigma_{\max}^2}{u}\ \xrightarrow{\ \sigma_{\max}\to\infty\ }\ \gamma\ln v+(1-\gamma)\ln u

    The ODE dx/dσ=σ (a(σ)x−b(σ))dx/d\sigma=\sigma\,(a(\sigma)x-b(\sigma)) is linear, so Gaussian inputs give Gaussian outputs, and the variance VV of the samples obeys dV/dσ=2σa(σ)VdV/d\sigma=2\sigma a(\sigma)V. Integrate from σmax⁡\sigma_{\max}, where sampling starts from N(0,σmax⁡2)\mathcal N(0,\sigma_{\max}^2), down to 00:

  3. Vguided=vγu1−γversusVπ=(γv+1−γu)−1V_{\text{guided}}=v^{\gamma}u^{1-\gamma}\qquad\text{versus}\qquad V_{\pi}=\Big(\frac{\gamma}{v}+\frac{1-\gamma}{u}\Big)^{-1}

    So the guided sampler outputs a variance that interpolates the two variances geometrically, while the tilted target, a product of Gaussian densities raised to the powers γ\gamma and 1−γ1-\gamma, interpolates their precisions arithmetically:

  4. For v≠uv\neq u the two agree only at γ=0\gamma=0 and γ=1\gamma=1: ln⁡Vguided\ln V_{\text{guided}} is linear in γ\gamma while ln⁡Vπ\ln V_\pi is strictly convex, so for every γ>1\gamma>1 at which the target is normalizable the sampler is narrower than the target. With u=1u=1, v=0.25v=0.25 and w=2w=2, the sampler's standard deviation is 0.253/2=0.1250.25^{3/2}=0.125, while the tilted target's is 0.1≈0.32\sqrt{0.1}\approx0.32: for v<uv<u the guided variance shrinks exponentially in ww, the target's only like 1/w1/w. Bradley & Nakkiran (2024) solved the case u=2u=2, v=1v=1 in closed form, 21−γ2^{1-\gamma} against 2/(γ+1)2/(\gamma+1), and integrating the ODE numerically reproduces vγu1−γv^\gamma u^{1-\gamma}. ■\blacksquare

The gap is not a Gaussian quirk. If two classes have disjoint supports, p(c∣x)p(c\mid\mathbf x) is 0 or 1, so the tilted target equals the plain conditional for every w>0w>0. Yet Chidambaram et al. (2024) prove, for two classes on mirror-image disjoint intervals, that guided probability flow with large ww lands, with probability 1−e−Ω(w)1-e^{-\Omega(w)}, within a relative distance O(1/ln⁡w)O(1/\sqrt{\ln w}) of the class's outermost point, far from the other class, and that with any nonzero score error a large enough ww pushes samples off the support altogether. For Gaussian mixtures, Wu et al. (2024) prove, under conditions on the mixture, that guidance raises the classifier's confidence in the samples under both DDPM and DDIM sampling and lowers their differential entropy under DDIM; with three aligned components, they find that strong guidance with discretized sampling can split one component in two. Bradley & Nakkiran (2024) show that guidance interacts differently with stochastic and deterministic samplers, and that in the continuous-time limit stochastic guided sampling is equivalent to a conditional denoising step alternated with Langevin corrector steps on a sharpened, powered distribution.

Two refinements, both found by measuring where guidance helps:

  • Guidance intervals (Kynkäänniemi et al., 2024). Guidance at high noise levels drives samples toward a handful of template compositions per prompt, at low noise levels it is largely unnecessary, and only in between does it help. Applying it only for σ∈(0.19,1.61]\sigma\in(0.19,1.61] improved the largest EDM2 model's ImageNet-512 FID from 1.81 to 1.40, and saves the second evaluation elsewhere.
  • Autoguidance (Karras et al., 2024). Guide the model D1D_1 with a deliberately worse version of itself, D0D_0, smaller and trained for less time but with the same conditioning: Dw=wD1+(1−w)D0D_w=wD_1+(1-w)D_0, where w=1w=1 means no guidance. A finite network trained by score matching spreads probability into regions it has not learned well; a weaker model makes the same kind of errors more strongly, so extrapolating away from it pulls samples toward well-learned regions without CFG's class-driven narrowing. On ImageNet-512 with EDM2-S, FID went from 2.56 unguided and 2.23 with CFG to 1.34 (1.25 with EDM2-XXL), and an unconditional model, which CFG cannot guide at all, went from 11.67 to 3.86.

Key takeaways

  • Bayes' rule splits the conditional score: ∇log⁡pt(x∣c)=∇log⁡pt(x)+∇log⁡pt(c∣x)\nabla\log p_t(\mathbf x\mid c)=\nabla\log p_t(\mathbf x)+\nabla\log p_t(c\mid\mathbf x). Conditions enter by adaptive normalization, cross-attention, concatenation or zero-initialized control branches, which start as no-ops yet receive gradient.
  • Classifier guidance shifts each Gaussian reverse step's mean by sΣ∇log⁡pϕ(c∣x)s\Sigma\nabla\log p_\phi(c\mid\mathbf x) using a classifier trained on noisy inputs; s>1s>1 targets a sharpened classifier, raising precision and lowering recall.
  • Classifier-free guidance trains one network with condition dropout and samples with ϵ~=(1+w)ϵ(xt,c)−wϵ(xt,∅)\tilde{\boldsymbol\epsilon}=(1+w)\boldsymbol\epsilon(\mathbf x_t,c)-w\boldsymbol\epsilon(\mathbf x_t,\varnothing), at two evaluations per step; FID is best at small ww, and large ww oversaturates unless thresholded or rescaled.
  • Guided samplers do not sample the tilted target: for Gaussians, guided probability flow outputs variance vγu1−γv^\gamma u^{1-\gamma} instead of (γ/v+(1−γ)/u)−1(\gamma/v+(1-\gamma)/u)^{-1}, and with disjoint classes samples drift to the far edges of the support.
  • Guiding only at middle noise levels, or guiding with a weaker copy of the model itself (autoguidance), improves quality while giving up less diversity than plain CFG.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Two classes have disjoint supports, so p(c∣x)∈{0,1}p(c\mid\mathbf x)\in\{0,1\}. As the guidance weight ww grows, what happens to the tilted target p(x∣c) p(c∣x)wp(\mathbf x\mid c)\,p(c\mid\mathbf x)^w, and to guided samples?

  1. Both stay the same: guidance has no effect when classes do not overlap
  2. Both concentrate on the class's most typical point, its mode
  3. The target narrows toward the boundary between the classes, and samples follow it
  4. The target is unchanged for every w>0w>0, but guided samples drift toward the far edge of the class's support
Show the answer

D. The target is unchanged for every w>0w>0, but guided samples drift toward the far edge of the class's support

Raising a 0/1 likelihood to any positive power changes nothing, so the tilted target is the plain conditional. Guided probability flow, however, uses noised scores, for which tilting and noising do not commute, and it pushes samples away from the other class, toward extreme points (Chidambaram et al., 2024).

Question 2

Where in the sampling chain did Kynkäänniemi et al. (2024) find classifier-free guidance useful?

  1. At high noise levels, where it fixes the composition, and nowhere else
  2. At middle noise levels; at high noise it collapses compositions toward templates, and at low noise it adds little
  3. At low noise levels only, where it sharpens fine detail
  4. Uniformly: the benefit is the same at every noise level
Show the answer

B. At middle noise levels; at high noise it collapses compositions toward templates, and at low noise it adds little

Limiting guidance to a middle interval of σ\sigma kept the variety of compositions that high-noise guidance destroys, and improved ImageNet-512 FID from 1.81 to 1.40 for the largest EDM2 model, while saving network evaluations outside the interval.

Question 3

What does autoguidance use in place of CFG's unconditional prediction?

  1. A smaller, less-trained version of the same model with the same conditioning
  2. A noise-aware classifier's gradient
  3. The prediction for a negative prompt
  4. The same model evaluated at a higher noise level
Show the answer

A. A smaller, less-trained version of the same model with the same conditioning

Extrapolating from a weaker copy, Dw=wD1+(1−w)D0D_w=wD_1+(1-w)D_0, removes the errors the two share in kind, improving image quality without CFG's narrowing toward class-typical images. It also works for unconditional models, where CFG has nothing to contrast against.

Question 4

A ControlNet branch is connected to a frozen diffusion model through 1×11\times1 convolutions initialized to zero. What is true at the first training step?

  1. The combined model's output is random, because the branch is untrained
  2. No parameter can ever learn, because every gradient through a zero layer is zero
  3. The output equals the pretrained model's, the zero convolutions' weights get nonzero gradients, and the branch's own weights start receiving gradient once those weights move
  4. The frozen model's weights are updated first, then the branch's
Show the answer

C. The output equals the pretrained model's, the zero convolutions' weights get nonzero gradients, and the branch's own weights start receiving gradient once those weights move

∂L/∂W=(∂L/∂y) h⊤\partial\loss/\partial W=(\partial\loss/\partial\mathbf y)\,\mathbf h^\top is nonzero because the branch's features h\mathbf h are nonzero, while ∂L/∂h=W⊤(⋯ )\partial\loss/\partial\mathbf h=W^\top(\cdots) vanishes only until WW leaves zero. Training thus starts from the pretrained behavior exactly.

Further reading

  • P. Dhariwal & A. Nichol, "Diffusion models beat GANs on image synthesis," NeurIPS (2021).
  • J. Ho & T. Salimans, "Classifier-free diffusion guidance," arXiv:2207.12598 (2022); a short version appeared at the NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications.
  • L. Zhang, A. Rao & M. Agrawala, "Adding conditional control to text-to-image diffusion models," ICCV (2023).
  • T. Karras, M. Aittala, T. Kynkäänniemi, J. Lehtinen, T. Aila & S. Laine, "Guiding a diffusion model with a bad version of itself," NeurIPS (2024).
  • M. Chidambaram, K. Gatmiry, S. Chen, H. Lee & J. Lu, "What does guidance do? A fine-grained analysis in a simple setting," NeurIPS (2024).