4.5.14 · D1Generative Models

Foundations — Classifier-free guidance

1,781 words8 min readBack to topic

This page assumes you know nothing about the notation in Classifier-free guidance. We will build every letter, every subscript, and every operator from scratch, in an order where each idea leans only on the ones before it. If a symbol appears in the parent note, it is defined here first.


1. What is a diffusion model even doing?

Before any symbol, picture the process it lives in.

Figure — Classifier-free guidance

Every symbol in the parent note is a label somewhere on this forward-and-backward pipeline. Let's name the pieces.


2. The building blocks, in order

2.1 — an image written as a list of numbers

Picture: a photo is a grid of pixels; unroll that grid into one long line of numbers. That line is .

Why the topic needs it: guidance manipulates images, and to do maths on an image we must treat it as a vector of numbers.

2.2 The subscript — how noisy the image is

Picture: a dial from clean (small ) to snow (big ). = the image when the dial sits at 500.

2.3 — the noise itself

Picture: the exact snow pattern sitting on top of the clean image. If you knew perfectly, you could subtract it and recover the clean picture.

Why the topic needs it: modern diffusion models don't predict the clean image directly — they predict the noise . Guessing the static and removing it is easier to train.

2.4 — the model's guess of the noise

Picture: a machine with millions of adjustable knobs (). You feed it a noisy image; out comes its best guess of the static, .

2.5 — the conditioning (your prompt)

Picture: a sticky note taped to the model's input saying "make it a golden retriever."

2.6 — the empty conditioning

Picture: the same sticky-note slot, but the note is blank.

Why the topic needs it: classifier-free guidance is entirely built on comparing two runs — one with the note () and one with the blank note ().

Figure — Classifier-free guidance

3. The three operations guidance performs on vectors

Now that is a vector (a list of numbers), we combine two such vectors. Three simple operations do all the work.

3.1 Vector subtraction — "the difference the prompt makes"

Why subtraction and not something else? Subtraction isolates only what the prompt added. Whatever both runs agree on cancels out; what's left, , is a direction — an arrow pointing "toward more prompt-ness."

Figure — Classifier-free guidance

3.2 Scaling by — the "prompt volume knob"

Picture: is an arrow; is that same arrow stretched to times its length.

  • : arrow vanishes → ignore prompt.
  • : normal conditional generation.
  • : overshoot past the conditional → stronger prompt adherence (see Prompt engineering).

3.3 Vector addition — assembling the guided guess

Multiply out and you land on the parent's boxed formula:


4. Two more symbols the parent leans on

4.1 — the "score"

Picture: a hilly landscape where height = "how realistic." The score is the arrow telling you which way is uphill. This is the heart of Score-based diffusion models, and it links to noise via — the score points opposite to the predicted static (peel the noise off → become more realistic).

4.2 and Bayes' bridge

You don't need to re-derive Bayes here — just know that this bar-notation is where the whole idea "subtract unconditional from conditional" is born.


5. How the foundations feed the topic

image as vector x

noisy image x_t at step t

true noise epsilon

model noise guess epsilon_theta

prompt c

conditional guess

blank note empty

unconditional guess

difference delta epsilon

guidance scale w

scale the direction

guided noise epsilon tilde

score and Bayes bridge

DDPM sampling step

Classifier-free guidance

Read top-to-bottom: raw images become noisy inputs, the model turns them into noise guesses, running it with a prompt vs a blank note gives two guesses, their difference times is added back — and that guided guess feeds the DDPM sampling loop that produces your final image. See also Negative prompting for what happens when the "blank note" is replaced by an unwanted prompt.


Equipment checklist

Cover the right side and test yourself. If any answer is fuzzy, re-read that section before the main note.

What does bold represent?
An entire image flattened into one list (vector) of pixel numbers.
What does the subscript in mean?
The noise level / step index — small is clean, large is static.
What is versus ?
is the real added noise; is the network's guess of it (the flags "predicted").
What does stand for?
All the tunable weights inside the neural network.
What is ?
The conditioning / prompt, turned into a number vector.
What does mean?
No conditioning — a blank prompt (the null/empty token).
What is and why subtract?
Conditional guess minus unconditional guess; subtraction isolates the pure "direction the prompt adds."
What does do to that direction?
Scales its length — overshoots for stronger prompt adherence.
Why can the coefficient be negative?
For it pushes away from the generic unconditional prediction.
What does the tilde in signify?
The guided (modified) noise prediction.
What is the "score" ?
An arrow pointing toward more realistic images; it is proportional to .
What does the bar in mean?
"Probability of given the prompt ."