What is classifier-free guidance and how does the scale work?
sobes.tech AI
Answer from AI
Classifier-free guidance is a method for improving the quality of generation in diffusion models without the need to train a separate classifier. Instead, the model is trained simultaneously on conditional and unconditional data, allowing it to combine predictions with and without conditions during generation.
The mechanism works as follows: during generation, two predictions are taken — a conditional one (considering the given condition, such as text) and an unconditional one (without any condition). They are then combined using a scale parameter, which adjusts the influence of the condition. The formula:
x_{guided} = x_{uncond} + scale * (x_{cond} - x_{uncond})
Where:
x_{cond}— the model's prediction with the conditionx_{uncond}— the prediction without the conditionscale— a coefficient, usually >1, that amplifies the influence of the condition
Increasing the scale results in a stronger adherence to the condition, but too large a value can degrade quality or introduce artifacts. Thus, the scale parameter allows balancing between diversity and accuracy of the generation.