In machine learning, diffusion models, also known as diffusion-based generative models or score-based generative models, are a class of latent variable generative models. A diffusion model consists of two major components: the forward diffusion process, and the reverse sampling process. The goal of diffusion models is to learn a diffusion process for a given dataset, such that the process can generate new elements that are distributed similarly as the original dataset. A diffusion model models data as generated by a diffusion process, whereby a new datum performs a random walk with drift through the space of all possible data. A trained diffusion model can be sampled in many ways, with different efficiency and quality. There are various equivalent formalisms, including Markov chains, denoising diffusion probabilistic models, noise conditioned score networks, and stochastic differential equations. They are typically trained using variational inference. The model responsible for denoising is typically called its "backbone". The backbone may be of any kind, but they are typically U-nets or transformers. As of 2024, diffusion models are mainly used for computer vision tasks, including image denoising, inpainting, super-resolution, image generation, and video generation. These typically involve training a neural network to sequentially denoise images corrupted by Gaussian noise. The model is trained to reverse the process of adding noise to an image. After training to convergence, it can be used for image generation by starting with an image composed of random noise, and applying the network iteratively to denoise the image. Diffusion-based image generators have seen widespread commercial interest, such as Stable Diffusion and DALL-E. These models typically combine diffusion models with other models, such as text-encoders and cross-attention modules to allow text-conditioned generation. Other than computer vision, diffusion models have also found applications in natural language processing such as text generation and summarization, sound generation, and reinforcement learning.
Denoising diffusion model
Non-equilibrium thermodynamics Diffusion models were introduced in 2015 as a method to train a model that can sample from a highly complex probability distribution. They used techniques from non-equilibrium thermodynamics, especially diffusion. Consider, for example, how one might model the distribution of all naturally occurring photos. Each image is a point in the space of all images, and the distribution of naturally occurring photos is a "cloud" in space, which, by repeatedly adding noise to the images, diffuses out to the rest of the image space, until the cloud becomes all but indistinguishable from a Gaussian distribution 𝒩(0,I). A model that can approximately undo the diffusion can then be used to sample from the original distribution. This is studied in "non-equilibrium" thermodynamics, as the starting distribution is not in equilibrium, unlike the final distribution. The equilibrium distribution is the Gaussian distribution 𝒩(0,I), with pdf ρ(x)∝e−12‖x‖2. This is just the Maxwell–Boltzmann distribution of particles in a potential well V(x)=12‖x‖2 at temperature 1. The initial distribution, being very much out of equilibrium, would diffuse towards the equilibrium distribution, making biased random steps that are a sum of pure randomness (like a Brownian walker) and gradient descent down the potential well. The randomness is necessary: if the particles were to undergo only gradient descent, then they will all fall to the origin, collapsing the distribution.
Denoising Diffusion Probabilistic Model (DDPM) The 2020 paper proposed the Denoising Diffusion Probabilistic Model (DDPM), which improves upon the previous method by variational inference.
Forward diffusion To present the model, some notation is required.
β1,...,βT∈(0,1) are fixed constants. αt:=1−βt α¯t:=α1⋯αt σt:=1−α¯t σ~t:=σt−1σtβt μ~t(xt,x0):=αt(1−α¯t−1)xt+α¯t−1(1−αt)x0σt2 𝒩(μ,Σ) is the Gaussian distribution with mean μ and variance Σ, and 𝒩(x|μ,Σ) is the probability density at x. A vertical bar denotes conditioning. A forward diffusion process starts at some starting point x0∼q, where q is the probability distribution to be learned, then repeatedly adds noise to it byxt=1−βtxt−1+βtztwhere z1,...,zT are IID (Independent and identically distributed random variables) samples from 𝒩(0,I). The coefficients 1−βt and βt ensure that Var(Xt)=I assuming that Var(X0)=I. The values of βt are chosen such that for any starting distribution of x0, if it has finite second moment, then limt→∞xt|x0 converges to 𝒩(0,I). The entire diffusion process then satisfiesq(x0:T)=q(x0)q(x1|x0)⋯q(xT|xT−1)=q(x0)𝒩(x1|α1x0,β1I)⋯𝒩(xT|αTxT−1,βTI)orlnq(x0:T)=lnq(x0)−∑t=1T12βt‖xt−1−βtxt−1‖2+Cwhere C is a normalization constant and often omitted. In particular, we note that x1:T|x0 is a Gaussian process, which affords us considerable freedom in reparameterization. For example, by standard manipulation with Gaussian process, xt|x0∼N(α¯tx0,σt2I)xt−1|xt,x0∼𝒩(μ~t(xt,x0),σ~t2I)In particular, notice that for large t, the variable xt|x0∼N(α¯tx0,σt2I) converges to 𝒩(0,I). That is, after a long enough diffusion process, we end up with some xT that is very close to 𝒩(0,I), with all traces of the original x0∼q gone. For example, sincext|x0∼N(α¯tx0,σt2I)we can sample xt|x0 directly "in one step", instead of going through all the intermediate steps x1,x2,...,xt−1.
Backward diffusion The key idea of DDPM is to use a neural network parametrized by θ. The network takes in two arguments xt,t, and outputs a vector μθ(xt,t) and a matrix Σθ(xt,t), such that each step in the forward diffusion process can be approximately undone by xt−1∼𝒩(μθ(xt,t),Σθ(xt,t)). This then gives us a backward diffusion process pθ defined bypθ(xT)=𝒩(xT|0,I)pθ(xt−1|xt)=𝒩(xt−1|μθ(xt,t),Σθ(xt,t))The goal now is to learn the parameters θ such that pθ(x0) is as close to q(x0) as possible. To do that, we use maximum likelihood estimation with variational inference.
… excerpt ends here. Continue reading the full article.




![Diffusion model: Transport by rectified flow[41]](https://thumb.wikimedia.org/wikipedia/commons/thumb/7/75/Rectified_Flow.png/1280px-Rectified_Flow.png?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
![Diffusion model: The reflow process[41]](https://thumb.wikimedia.org/wikipedia/commons/thumb/2/26/Reflow_Illustration.png/1280px-Reflow_Illustration.png?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)