Diffusion model

On this page 7

A diffusion model is a generative model that learns to reverse a gradual noising process: during training it sees data corrupted by increasing amounts of random noise and learns to remove that noise, and during generation it starts from pure noise and denoises it step by step into a new sample. In generative AI, diffusion models are the dominant approach for text-to-image systems and a leading approach for video and audio generation.

Their appeal lies in stable training, high sample quality and broad coverage of the training distribution. The main cost is speed, because generation requires many sequential passes through a large neural network.

How a diffusion model generates data

A diffusion model has two processes. The forward process is fixed and requires no learning: it adds small amounts of Gaussian noise to a training example over hundreds or thousands of steps until the example becomes indistinguishable from random noise. A noise schedule sets how much noise is added at each step.

The reverse process is learned. A neural network, historically a U-Net and increasingly a diffusion transformer, receives a noisy input and the step number and predicts the noise that was added. The training loss is usually a simple mean squared error between predicted and actual noise, which makes training far more stable than adversarial methods.

At generation time a sampler starts from random noise and repeatedly subtracts the predicted noise, gradually forming a coherent image, sound or video. Conditioning information such as a text prompt is injected through cross-attention so that the denoising moves toward content that matches the prompt.

ParameterTypical rangeEffect
Training timestepsAbout 1,000Granularity of the noise schedule
Sampling steps1 to 4 distilled, 20 to 50 standardSpeed versus detail and fidelity
Guidance scaleAbout 3 to 12Prompt adherence versus diversity
Resolution512 to 2048 pixels per sideDetail, memory and compute cost
Random seedAny integerReproducibility of a given output
Key parameters of a diffusion pipeline

Latent diffusion and guidance

Running diffusion directly on full-resolution pixels is expensive. Latent diffusion solves this by first compressing images with an autoencoder into a much smaller latent space, often reducing each spatial side by a factor of eight, and performing all denoising there. A decoder turns the final latent back into pixels.

Classifier-free guidance is the standard technique for prompt adherence. The model predicts noise both with and without the prompt, and the sampler pushes the result further in the direction of the prompted prediction. Higher guidance gives closer prompt matching but less variety and, at extreme values, oversaturated or distorted images.

Diffusion models compared with other generative approaches

Diffusion is one of several families of generative models. Each makes a different trade-off between quality, diversity and speed.

ApproachGeneration styleStrengthWeakness
Diffusion modelIterative denoisingHigh quality, stable trainingMany steps, slower sampling
GANSingle generator passVery fast samplingUnstable training, mode collapse
Variational autoencoderDecode from latent codeFast, smooth latent spaceOften blurrier output
Autoregressive modelOne token at a timeStrong for text and sequencesSlow for large images
Flow matchingLearned continuous transportFewer steps, simple trainingNewer, still maturing tooling
Diffusion versus neighboring generative methods

Unlike a GAN, a diffusion model does not pit two networks against each other, so it rarely suffers from mode collapse, where a generator produces only a narrow range of outputs. Flow matching and rectified flow are closely related and are often grouped with diffusion in current systems.

Variants and practical applications

Diffusion models extend well beyond basic image generation. The same denoising principle supports editing, restoration and other media types.

TaskConditioning inputTypical use
Text-to-imageText prompt embeddingIllustration, design concepts
InpaintingImage plus maskRemoving or replacing objects
Image-to-imagePartially noised source imageStyle transfer, variations
Super-resolutionLow-resolution imageUpscaling and restoration
Text-to-videoPrompt plus temporal layersShort clips, motion studies
Audio generationText or spectrogramSpeech, music, sound effects
Common diffusion tasks and how they are conditioned

Control adapters add structured conditions such as edge maps, depth maps or human poses, which give designers precise compositional control. Small adapters trained with LoRA let teams teach a base model a specific style or product without full retraining.

Limitations and common pitfalls

Diffusion models produce impressive results but have well-known weaknesses that affect production use.

  • Sampling cost: dozens of network passes per output make generation slower than one-shot methods, although distillation can reduce this to a few steps with some loss of quality.
  • Fine structure errors: text rendering, hands and counting objects have historically been unreliable, though newer models improve markedly.
  • Memorization risk: models can reproduce near copies of training images that appear many times in the data.
  • Bias inheritance: outputs reflect imbalances in training data, such as default depictions of professions.
  • Overguidance: very high guidance scales cause harsh colors and artifacts.

Responsible deployment usually adds content filters, provenance metadata and dataset curation to manage legal and reputational risks.

The simple explanation

Imagine taking a clear photo and sprinkling it with static, a little at a time, until nothing but grainy noise remains. A diffusion model is trained to run that film backward: given a noisy picture, it learns to remove a bit of the static. Repeat that cleaning step many times, and a picture appears out of pure noise.

When you type a description, the description steers each cleaning step toward an image that fits your words. The result is a brand-new picture, not a copy pulled from a library, built gradually from randomness.

How it is used in practice

A furniture retailer’s creative team needs lifestyle photos of a new sofa in twelve room styles. Instead of staging twelve shoots, they photograph the sofa once in a studio and use a latent diffusion model with inpainting to generate the surrounding rooms, keeping the product pixels untouched by masking them.

They run 30 sampling steps at a guidance scale of 7, fix the random seed for each approved layout so it can be reproduced, and use a depth-map adapter to keep perspective consistent. A designer reviews every image, rejecting those with warped lamps or impossible shadows.

The team delivers the full set in two days instead of several weeks, and every image is labeled as generated in the asset system so that marketing staff know its origin.