Interactive demo · Probabilistic Machine Learning: Advanced Topics · Chapter 25

Classifier-free guidance: quality against diversity

Classifier-free guidance replaces the conditional score by (1 + w)∇ log pt(x | c) − w∇ log pt(x), the score of p(x | c) p(c | x)w up to a constant. Three overlapping classes in the plane have exact conditional and unconditional scores at every noise level. Raise w and watch the samples move away from the other classes: they become more typical of their class (higher p(c | x)) and less diverse.

Class c

Guidance weight w

Sampler

Try these

Each class is a two-component Gaussian mixture; the classes have equal prior weight. 1000 samples from fixed seeds, VP SDE with β(t) from 0.1 to 20, either 100 ancestral steps (Algorithm 25.2 with the guided score) or 50 Heun steps of the probability-flow ODE. The gold background is the tilted target p(x | c)1+wp(x)−w, normalised on a 200 × 200 grid; w = −1 gives the unconditional model and w = 0 the conditional one. The class probability is the exact p(c | x) of the clean data; the spread is the square root of the trace of the sample covariance.

In the lecture notes