The connection between diffusion and score function is a topic that arises in the context of stochastic processes and machine learning, specifically in the area of generative modeling and variational inference. Here, I'll provide an overview of both concepts and discuss how they relate to each other.
Diffusion
Diffusion processes are a class of stochastic processes that describe the random motion of particles in a medium. The most well-known diffusion process is Brownian motion. Mathematically, diffusion is often described by the Fokker-Planck equation or the diffusion equation for the probability density function ( p(x, t) ) of finding a particle at position ( x ) at time ( t ):
[ \frac{\partial p(x, t)}{\partial t} = D \frac{\partial^2 p(x, t)}{\partial x^2} ]
where ( D ) is the diffusion coefficient. This equation is a simplified one-dimensional version and assumes a constant diffusion coefficient.
Score Function
The score function is a concept from statistics and is related to the gradient of the log-likelihood function. If you have a probability distribution ( p(x; \theta) ) parameterized by ( \theta ), the score function ( \nabla_\theta \log p(x; \theta) ) tells you how to update the parameters ( \theta ) to increase the probability of observing the data ( x ). The score function is central to many optimization and estimation techniques in statistics and machine learning, including maximum likelihood estimation.
Connection
The connection between diffusion and the score function becomes particularly interesting in the context of score-based generative models. For instance, consider a continuous-time diffusion process that gradually adds noise to data ( x ) until it becomes pure noise at time ( T ). We can define a reverse-time process that starts with the noise and aims to recover the data. This is where the score function comes in.
The reverse process can be guided by the score function of the perturbed data at each time step, which essentially tells us the direction in which the log-likelihood gradient is increasing. This is useful for generative modeling, where we want to generate samples from complex distributions by learning the score function.
In a generative setting, the score function is estimated using a neural network, which is trained to predict the gradient of the log-density with respect to the data at different noise levels (time steps). Denote the estimated score function as ( s_\theta(x(t), t) ), where ( x(t) ) is the data perturbed by noise at time ( t ). The training objective can be to minimize the following loss:
[ L(\theta) = \mathbb{E}{t \sim \mathcal{U}(0, T), x(0) \sim p{data}, \epsilon \sim \mathcal{N}(0,1)}\left[ || s_\theta(x(t), t) - \nabla_x \log p_t(x(t)) ||^2 \right] ]
where ( x(t) = x(0) + \sqrt{t} \cdot \epsilon ), ( p_t(x(t)) ) is the distribution of ( x(t) ), and ( \mathcal{U}(0, T) ) denotes a uniform distribution over the interval ( [0, T] ).
Once trained, the model can generate new samples by starting with noise and following the reverse diffusion process, using the learned score function to guide the transformation back to the data distribution.
The connection is hence manifested in the way the score function is used to reverse the diffusion process, effectively turning a generative model into an iterative refinement procedure that begins with noise and ends with coherent samples from the target distribution. This approach is encapsulated in models such as Score-Based Generative Models (SGMs) and Denoising Diffusion Probabilistic Models (DDPMs).