A comprehensive statistical mechanics and stochastic calculus treatment of Brownian motion, the Fluctuation-Dissipation Theorem, Fokker-Planck evolution, DDPM, Score-SDEs, and Discrete Language Diffusion (SEDD, LLaDA).
Generative modeling in modern machine learning represents a profound computational realization of non-equilibrium statistical mechanics. At its core, the problem of generative modeling asks: How can we transform an uninformative, high-entropy prior distribution (such as isotropic Gaussian noise or a sequence of mask tokens) into a highly structured, low-entropy data distribution (such as natural images, protein conformations, or coherent text)?
In classical physics, this problem is mirrored by the study of thermal relaxation, Brownian motion, and time-reversal symmetry in stochastic systems. In this chapter, we develop the complete mathematical continuum that connects the 1905 Einstein-Langevin theory of Brownian motion to continuous-time score-based Stochastic Differential Equations (Score-SDEs), Denoising Diffusion Probabilistic Models (DDPM), and modern Discrete Diffusion Large Language Models (SEDD, LLaDA).
Before diving into formal stochastic calculus, let us construct the conceptual dictionary bridging Classical Statistical Mechanics and Modern Deep Generative Diffusion.
Statistical Mechanics Concept
Mathematical Symbol
Machine Learning / Diffusion Concept
Microstate Configuration
x∈Rd (or x∈VN)
Data sample (image pixels, latent vector, token sequence)
Energy Function
E(x)
Negative unnormalized log-likelihood −logp~(x)
Boltzmann / Gibbs Distribution
p∞(x)=Z1e−E(x)/T
Target data density pdata(x)
Thermal Heat Bath Fluctuations
η(t)∼N(0,2γkBTI)
Gaussian noise injection / Brownian motion dWt
Friction / Dissipation
γx˙
Drift coefficient / deterministic decay towards prior
Thermodynamic Force
−∇E(x)
Stein Score Function ∇xlogpt(x)
Thermalization Time
t→∞
Forward diffusion horizon T (pure isotropic noise)
Time-Reversal (Maxwell's Demon)
Time-reversed drift f−g2∇logp
Learned neural denoiser / score network sθ(x,t)
Entropy Production
ΔStot=DKL(q∥p)≥0
Variational Loss / Evidence Lower Bound (ELBO) gap
Consider a macroscopic or mesoscopic particle of mass m and position x(t)∈Rd suspended in a fluid solvent at absolute temperature T. The solvent consists of an astronomical number of fluid molecules (N∼1023) undergoing rapid, chaotic thermal motion.
The microscopic collisions exerted by the fluid on the particle can be partitioned into two distinct physical effects across timescales:
Macroscopic Systematic Friction (Dissipation): A mean drag force opposing the velocity x˙(t)=v(t), modeled via Stokes' drag law as −γv(t), where γ>0 is the friction coefficient.
Microscopic Random Kicks (Fluctuation): A rapidly fluctuating stochastic force η(t) arising from individual, instantaneous molecular collisions.
Newton's second law yields the Classical Langevin Equation (Paul Langevin, 1908):
mdt2d2x(t)=−γdtdx(t)+η(t)
Equivalently, writing in terms of velocity v(t)=x˙(t):
Because molecular collisions occur on a picosecond timescale (τc∼10−13 s), vastly faster than the relaxation timescale of the mesoscopic particle (τr=m/γ∼10−7 s), we model η(t) as a stationary, Gaussian white noise stochastic process:
Zero Mean:E[η(t)]=0
Delta-Correlated in Time (Markovian Memoryless Limit):E[η(t)η(t′)T]=2Dvδ(t−t′)Id
where Dv is the diffusion constant in velocity space, δ(⋅) is the Dirac delta distribution, and Id is the d-dimensional identity matrix.
In thermal equilibrium at temperature T, the Equipartition Theorem of classical statistical mechanics requires that each translational degree of freedom possesses an average kinetic energy of 21kBT:
Comparing this with our Langevin derivation at τ=0:
t→∞limE[v(t)2]=γmDv=mkBT⟹Dv=γkBT
This is the celebrated Einstein Fluctuation-Dissipation Theorem (FDT) (1905).
The Fluctuation-Dissipation Theorem:
The noise covariance amplitude 2Dv (fluctuation) and the drag coefficient γ (dissipation) are inextricably tied by the thermal energy scale kBT:
E[η(t)η(t′)T]=2γkBTδ(t−t′)I
You cannot have friction without thermal noise, nor thermal noise without friction; both arise from the exact same microscopic collisions with the heat bath.
In molecular dynamics, biological fluids, and machine learning optimization, the relaxation time τr=m/γ is negligibly small compared to observation timescales. Setting mdtdv→0 in the full Langevin equation with an external potential energy landscape E(x):
0=−γdtdx−∇E(x)+η(t)
Rearranging and defining mobility μ=1/γ:
dtdx=−μ∇E(x)+μη(t)
In standard stochastic calculus notation, setting units such that mobility μ=1 and thermal noise intensity 2kBT=2T, we obtain the Overdamped Langevin Stochastic Differential Equation (SDE):
dxt=−∇E(xt)dt+2TdWt
where Wt is standard d-dimensional Brownian motion (Wiener process) satisfying E[dWt]=0 and E[dWtdWtT]=Idt.
Let p(x,t) denote the probability density of finding the particle at position x at time t. To derive the deterministic PDE governing the time evolution of p(x,t), let g(x):Rd→R be an arbitrary smooth, compactly supported test function.
By Itô's Lemma, the differential of g(xt) along the trajectory of dxt=−∇E(xt)dt+2TdWt is:
In the stationary state ∂t∂p(x,t)=0, conservation requires ∇⋅J∞(x)=0. Under thermal equilibrium, a stronger condition holds: Detailed Balance, which requires the probability current to vanish identically everywhere:
J∞(x)=−p∞(x)∇E(x)−T∇p∞(x)=0
Dividing by Tp∞(x):
p∞(x)∇p∞(x)=∇logp∞(x)=−T1∇E(x)
Integrating both sides with respect to x:
logp∞(x)=−TE(x)−logZ⟹p∞(x)=Z1e−TE(x)
where Z=∫Rde−E(x)/Tdx is the canonical partition function.
In 2015, Sohl-Dickstein et al. introduced deep generative modeling via non-equilibrium thermodynamics, which was later refined and popularized by Jonathan Ho, Ajay Jain, and Pieter Abbeel (NeurIPS 2020) into Denoising Diffusion Probabilistic Models (DDPM).
Let x0∼q(x0) be a clean data sample from the target distribution. The forward process generates a sequence of latent variables x1,x2,…,xT by sequentially adding Gaussian noise according to a fixed variance schedule β1,β2,…,βT∈(0,1):
In 2021, Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole unified DDPMs and Score-Based Generative Networks under the continuous-time framework of Stochastic Differential Equations (SDEs).
In a foundational 1982 paper, Brian D. O. Anderson proved that any forward diffusion process governed by Itô SDE dx=f(x,t)dt+g(t)dWt possesses an exact reverse-time stochastic trajectory running backward from t=T to t=0.
Theorem (Anderson, 1982 - Reverse-Time SDE):
Let x(t) satisfy dx=f(x,t)dt+g(t)dWt with marginal probability density pt(x). Then the time-reversed process xˉ(t)=x(T−t) satisfies the reverse-time SDE:
dx=[f(x,t)−g(t)2∇xlogpt(x)]dt+g(t)dWˉt
where dt is an infinitesimal negative time step running backward from T to 0, and Wˉt is a standard Brownian motion running backward in time.
We now provide the rigorous derivation by proving that the forward and reverse SDEs generate identical marginal densities pt(x) at every instant t∈[0,T].
Step 1: Forward Fokker-Planck Equation.
The forward SDE dx=f(x,t)dt+g(t)dWt has probability current Jf(x,t)=pt(x)f(x,t)−21g(t)2∇xpt(x). Its Fokker-Planck equation is:
∂t∂pt(x)=−∇x⋅[pt(x)f(x,t)]+21g(t)2∇x2pt(x)
Step 2: Reverse SDE Ansatz.
Assume a general reverse-time SDE running backward with drift f~(x,t) and identical diffusion coefficient g(t):
dx=f~(x,t)dt+g(t)dWˉt
Reversing time via substitution τ=−t, the time derivative satisfies ∂τ∂=−∂t∂. The Fokker-Planck equation for this reverse process running backward must satisfy:
Step 3: Equating Forward and Reverse Fokker-Planck Equations.
For the reverse process to have the exact same marginals pt(x) as the forward process, the two time-derivative expressions must match:
Remarkably, Song et al. (2021) demonstrated that there exists a completely deterministic ordinary differential equation (ODE) whose trajectory shares the exact same marginal probability density pt(x) as the stochastic SDE for all t∈[0,T]:
For any sample x0, we can compute its exact likelihood under the model by integrating the divergence of the ODE vector field v(x,t)=f(x,t)−21g(t)2sθ(x,t) using the continuous change-of-variables formula:
To train a neural network sθ(x,t) to approximate ∇xlogpt(x) without knowing the intractable normalizing partition function of pt(x), we use Score Matching.
Song et al. introduced Predictor-Corrector (PC) Samplers, which combine numerical integration of the reverse SDE with intermediate Langevin MCMC corrections:
The Corrector uses the learned score sθ(xt,t) to actively suppress accumulated numerical drift and discretization error, guaranteeing high sampling fidelity.
While continuous diffusion operates in Euclidean spaces Rd, language models, symbolic mathematics, and biological sequences exist on discrete vocabularies V={1,2,…,V}N. On a discrete lattice, the gradient operator ∇xlogp(x) is undefined.
Aspect
Continuous Diffusion (Images, Audio, Latents)
Discrete Diffusion / Masking (LLaDA, Language)
State Space
Continuous vector space x∈RD
Discrete token vocabulary x∈VL
Corruption Mechanism
Additive Gaussian noise (xt=αˉtx0+1−αˉtϵ)
Absorbing [MASK] token substitution (q(xt∣x0))
Forward Stationary State
Standard Normal prior N(0,I)
Pure masked sequence ([MASK],…,[MASK])
Model Output
Continuous Score Vector sθ(xt,t)∈RD
Logit distribution over vocabulary pθ(x0i∣xt)∈Δ∣V∣
In Diffusion-LM (Li et al., 2022), discrete token sequences w=(w1,…,wN) are mapped into continuous embedding space x0=Embed(w)∈RN×d. Gaussian diffusion is performed in continuous space, and at step t=0, tokens are recovered via categorical rounding:
pθ(w∣x0)=i=1∏Nsoftmax(E(wi)Tx0(i))
Fundamental Bottleneck: Continuous embeddings suffer from rounding collapse and out-of-vocabulary drift during intermediate timesteps, where continuous latents wander into regions of embedding space that do not correspond to any valid grammatical token sequence.
To overcome the embedding bottleneck, Lou et al. (ICML 2024) formulated Score Entropy Discrete Diffusion (SEDD) directly on the discrete state space VN using Continuous-Time Markov Chains (CTMC).
Let xt∈VN evolve according to a transition rate matrix Qt∈RV×V, where Qt(x,y)≥0 (x=y) is the instantaneous jump rate from state x to state y, with diagonal Qt(x,x)=−∑y=xQt(x,y).
The probability distribution pt(x) obeys the continuous-time Master Equation:
By Kolmogorov's time-reversal theorem for jump processes, the reverse-time process running from t=T back to t=0 is itself a continuous-time Markov chain with reverse transition rate matrix Qˉt(x,y):
Qˉt(x,y)=Qt(y,x)pt(x)pt(y)
The Discrete Score Function:
The discrete analog of the continuous score ∇xlogpt(x) is the Concrete Probability Ratio:
st(x,y)=pt(x)pt(y)for y=x
While the continuous score measures the directional gradient of log-density, the discrete score measures the relative probability mass between adjacent discrete states x and y.
Minimizing LSEDD forces the neural network sθ(xt,y,t) to converge to the exact time-reversal transition rates Qˉt(xt,y), enabling rigorous discrete generation without continuous relaxation.
In late 2024 and 2025, Large Language Diffusion Models underwent a major breakthrough with LLaDA (Large Language Diffusion with Masking) (Nie et al., NeurIPS 2025 / 2024), scaling discrete diffusion to an 8-billion parameter foundational model competitive with LLaMA3.
At training time, given a sequence x0=(x01,…,x0N), a time t∼U(0,T) is sampled, masking a subset of tokens Mt⊆{1,…,N}. The Transformer network pθ(x0i∣xt) is trained via bidirectional cross-entropy loss only on the masked positions:
We conclude by tying all generative diffusion frameworks back to fundamental Non-Equilibrium Thermodynamics.
ΔStot=lnPrev[x(T−t)]P[x(t)]=ΔSsys+ΔSmedium≥0
Consider the path probability measure P[x(t)]t=0T of the forward diffusion process and the time-reversed path measure PR[xˉ(t)]t=0T. By the Crooks Fluctuation Theorem and the Second Law of Thermodynamics, the total entropy production along the stochastic trajectory is:
ΔStot=DKL(P[x(t)]∥PR[xˉ(t)])≥0
Expanding the path integral under the forward SDE dx=fdt+gdWt and parameterized reverse model dx=[f−g2sθ]dt+gdWˉt via Girsanov's Theorem:
[!IMPORTANT]
The Thermodynamic Nature of Diffusion Training:
Minimizing the score-matching loss JESM(θ) is mathematically identical to minimizing the total thermodynamic entropy production of the time-reversal process.
When the neural score network achieves zero loss (sθ(x,t)=∇xlogpt(x)), total entropy production vanishes (ΔStot=0), meaning the artificial generative process operates as an ideal, microscopically reversible thermodynamic engine running backwards in time.
Langevin, P. (1908). Sur la théorie du mouvement brownien. C. R. Acad. Sci. (Paris), 146, 530–533.
Einstein, A. (1905). Über die von der molekularkinetischen Theorie der Wärme geforderte Bewegung von in ruhenden Flüssigkeiten suspendierten Teilchen. Annalen der Physik, 322(8), 549–560.
Anderson, B. D. O. (1982). Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3), 313–326.
Hyvärinen, A. (2005). Estimation of non-normalized statistical models by score matching. Journal of Machine Learning Research, 6(4), 695–709.
Vincent, P. (2011). A connection between score matching and denoising autoencoders. Neural Computation, 23(7), 1661–1674.
Sohl-Dickstein, J., Weiss, E., Khanshali, N., & Sompolinsky, H. (2015). Deep unsupervised learning using nonequilibrium thermodynamics. ICML 2015.
Song, Y., & Ermon, S. (2019). Generative modeling by estimating gradients of the data distribution. NeurIPS 2019.
Ho, J., Jain, A., & Abbeel, P. (2020). Denoising diffusion probabilistic models. NeurIPS 2020.
Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., & Poole, B. (2021). Score-based generative modeling through stochastic differential equations. ICLR 2021.
Li, X. L., Thickstun, J., Gulrajani, I., Liang, P., & Hashimoto, T. B. (2022). Diffusion-LM improves controllable text generation. NeurIPS 2022.
Lou, A., Meng, C., & Ermon, S. (2024). Discrete diffusion modeling by estimating the score of the continuous-time Markov chain. ICML 2024.
Nie, S., et al. (2025). Large Language Diffusion Models (LLaDA). NeurIPS 2025 / arXiv:2410.02416.