Skip to content

Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN027 · Algorithm

Classifier-free guidance

Combines conditional and unconditional diffusion predictions to change conditioning strength at sampling time.

Partly runs in CodeSplash (Experimental) Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method covers part of this entry; some options or variants aren't built yet. The methods that run it are Experimental.

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Availability
Partly runs in CodeSplash (Experimental)
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through synth.diffusion. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Combines conditional and unconditional diffusion predictions to change conditioning strength at sampling time.

Question / hypotheses

Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.

Architecture / computational structure

A model trained with occasional condition dropout supplies conditional and null-condition outputs; the sampler combines them at each step.

Assumptions

Both branches must share a compatible prediction parameterization and noise schedule. Guidance is an inference modification, not a calibrated probability or a universally monotone quality improvement.

Formula / computational definition

ϵ^=ϵuncond+s(ϵcond−ϵuncond).\hat\epsilon=\epsilon_{uncond}+s(\epsilon_{cond}-\epsilon_{uncond}).

Parameters and notation

Learned: denoiser weights during training. Hyperparameters: condition-drop probability, guidance scale s, schedule, negative/null condition, solver steps. At s=1 this convention recovers the conditional prediction.

Fitting, fine-tuning, and adaptation

During adaptation, preserve null-condition capability if guidance will be used. Tune guidance on development prompts after fitting; report it separately from learning rate and other training hyperparameters.

How to use and calibrate

Plot quality, diversity, saturation, and prompt adherence across guidance scales. Example: choose an operating point for text-to-image or text-to-audio generation.

Example application

choose an operating point for text-to-image or text-to-audio generation.

Interpretation / pitfalls

Watch out

Very strong guidance can create artifacts and reduce diversity. Different libraries shift the numerical definition of guidance scale, so copy the formula as well as the number.

Python and R code examples

Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — numerical mechanism demonstration. · needs numpy

import numpy as np
u=np.array([.1,.2]); c=np.array([.4,.1]); s=3.
print(u+s*(c-u))
R

Component demo, not a trained model — numerical mechanism demonstration.

u <- c(.1,.2); conditional <- c(.4,.1); s <- 3
print(u+s*(conditional-u))

Sources

From the CodeSplash reference, entry TRN027.