Diffusion models generate data by learning to reverse a gradual noising process. Conceptually, they operate in two phases: a forward process that corrupts data with noise over many steps, and a reverse process that trains a neural network to undo this corruption. During the forward phase, input data (like an image) is incrementally altered by adding small amounts of Gaussian noise at each step. This transforms the original data into random noise over hundreds or thousands of steps, simulating a diffusion-like process. The key idea is that by understanding how to reverse this noising, the model can generate new data from noise by iteratively refining it.
The training process focuses on teaching the model to predict and remove the noise added at each step. For example, given a noisy image at a specific timestep, the model is trained to estimate the noise component. This is typically done using a loss function like mean squared error (MSE) between the predicted and actual noise. The model architecture, often a U-Net, is designed to handle spatial data and is conditioned on the current timestep to adjust its behavior for different noise levels. By learning to reverse each small corruption step, the model builds the capability to reconstruct data from pure noise. This approach avoids complex probability calculations used in other generative models, relying instead on iterative refinement.
During sampling (generation), the model starts with random noise and applies the learned reverse process step by step. At each timestep, the network predicts the noise in the current “noisy” data and subtracts it to produce a slightly cleaner version. This repeats until a coherent output (e.g., an image) is formed. For instance, generating a cat image might begin as static, with edges and shapes emerging over dozens of steps. Practical implementations often optimize the number of steps—using fewer for speed (e.g., 50 steps) or more for higher quality (e.g., 1,000 steps). While computationally intensive, this iterative denoising provides fine-grained control over outputs and avoids mode collapse issues seen in GANs. Developers can adjust parameters like step count or noise schedules to balance speed and output quality.
Zilliz Cloud is a managed vector database built on Milvus perfect for building GenAI applications.
Try FreeLike the article? Spread the word