Diffusion Models interview question

Deep LearningDiffusion ModelsMultimodalmedium

A retailer's Stable Diffusion 1.5 pipeline uses classifier-free guidance, ε̂ = ε_uncond + w·(ε_cond − ε_uncond), with w = 7.5. For one latent element at one step, the model predicts ε_uncond = 0.20 and ε_cond = 0.35. What is ε̂, and which statement about how CFG is trained and used is correct?

  1. Aε̂ = 0.20 + 7.5 × 0.35 = 2.825; the unconditional prediction comes from a second, separately trained model that never sees any text, and a negative prompt is appended to the positive prompt with a minus sign.
  2. Bε̂ = 0.20 + 7.5 × (0.35 − 0.20) = 1.325; one network learns both branches because the prompt is replaced by a null prompt about 10% of the time in training, and a negative prompt replaces the unconditional branch.
  3. Cε̂ = 0.20 + 7.5 × (0.35 − 0.20) = 1.325; the unconditional branch needs no training because an empty prompt encodes to all zeros, and a negative prompt is added as a third branch with weight −w on top of the other two.
  4. Dε̂ = 0.20 + (0.35 − 0.20) / 7.5 = 0.22; a larger scale shrinks the step toward the prompt to prevent oversaturation, and during training the prompt is replaced by a null prompt in about 10% of the steps.
Show the answer and explanation

Correct answer: B, ε̂ = 0.20 + 7.5 × (0.35 − 0.20) = 1.325; one network learns both branches because the prompt is replaced by a null prompt about 10% of the time in training, and a negative prompt replaces the unconditional branch.

Explanation Diffusion Models

Classifier-free guidance (Ho and Salimans, 2022) runs the same denoiser twice per step, with and without the prompt, and extrapolates from the unconditional prediction toward the conditional one:

ε̂ = ε_uncond + w·(ε_cond − ε_uncond) = 0.20 + 7.5 × 0.15 = 1.325

With w = 1 you get the plain conditional prediction; w > 1 pushes further in the direction the prompt adds, improving prompt adherence at the cost of diversity (and oversaturated images at very high w).

Training. No second model is needed: the caption is replaced by a null condition with a small probability (10% for Stable Diffusion 1.5; other models use other rates), so one network learns both the conditional and the unconditional prediction. In SD 1.5 the unconditional branch uses the frozen text encoder's output for the empty prompt, which is not a vector of zeros; the U-Net learns to handle it like any other prompt.

Negative prompts. At sampling, the unconditional branch is simply computed with the negative prompt instead of the empty one: ε̂ = ε_neg + w·(ε_cond − ε_neg). The update moves away from the negative concept and toward the prompt at no extra cost, still with two passes per step.

MistakeResult
dropping the difference: 0.20 + 7.5 × 0.352.825
dividing by w instead of multiplying0.22

Dividing by the scale would make a larger w weaker, the opposite of how CFG behaves.

Interview tip: some papers write the same rule as (1 + w)·ε_cond − w·ε_uncond, so "w" differs by 1 between conventions; always check which one a library uses.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Deep Learning questions

  1. An LLM interpretability team trains a sparse autoencoder (SAE) on residual-stream activations of size 4,096, with a 65,536-unit ReLU code layer and an L1…
  2. As an ablation, you delete every self-attention sublayer from a trained BERT-style encoder but keep the token and position embeddings, the feed-forward (FFN)…
  3. A grocery chain trains a CNN to grade bananas on a conveyor belt as unripe, ripe or overripe from camera images. Which augmentation is most likely to hurt the…
  4. In a deep MLP with sigmoid activations, the error signal reaching the first layer's weights has passed through ten sigmoid derivatives. Ignoring the weight…
  5. A teammate multiplies a recommender's training loss by 100 so the dashboard shows larger numbers. For one weight the gradient has been steady at g = 0.004 per…