At every denoising step the model can be run twice: once with the prompt attached, once with it dropped. The two noise predictions disagree, and that disagreement is precisely what the prompt contributed. Classifier-free guidance takes the gap between them and scales it up:
Task: write guided_noise(eps_uncond, eps_cond, scales), returning one guided prediction per entry of scales, in the same order — a list of lists, every number rounded to 4 decimal places.
eps_uncond and eps_cond are lists of the same length; work elementwise.scales may contain any numbers at all. The familiar range of 5 to 10 is a habit of image tools, not a restriction on the arithmetic.Read the formula at and it collapses to — the plain conditioned prediction, with no guidance happening at all. Everything people mean by "turning guidance up" lives at , out beyond the conditioned prediction, at a point no single run of the model ever produced.
The difference between the two predictions points in the direction the condition is asking for. Exaggerate that direction and the condition gets obeyed harder.
Once your code passes every test, a reference solution shows up here so you can compare it with yours.