@daibond_alpha: 1/5 EBMs are usually taught as one model family among many. In our new tutorial with @du_yilun, we use them as a single…

X AI KOLs Timeline Papers

Summary

A new tutorial, "An Energy-Based Perspective on Machine Learning," presents energy-based models as a single unifying lens for ML, showing that discriminative and generative models, representation learning, RL, and inference-time computation all differ only in three EBM design choices.

1/5 EBMs are usually taught as one model family among many. In our new tutorial with @du_yilun, we use them as a single lens on machine learning. "An Energy-Based Perspective on Machine Learning" https://t.co/ZpPD2qTIPi https://t.co/z9RTUsSs2n
Original Article
View Cached Full Text

Cached at: 11/22/26, 06:34 AM

1/5 EBMs are usually taught as one model family among many. In our new tutorial with @du_yilun, we use them as a single lens on machine learning. “An Energy-Based Perspective on Machine Learning” https://t.co/ZpPD2qTIPi https://t.co/z9RTUsSs2n


An Energy-Based Perspective on Machine Learning

Source: https://arxiv.org/html/2611.14383

Abstract

Energy-based models (EBMs) define a distribution through a scalar energy,pθ​(𝒙)∝exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\exp\left(-E_{\theta}({\bm{x}})\right), and are usually presented as one model family among many. This tutorial has a broader goal: beyond introducing EBMs, it uses them as a single lens that connects the different aspects of machine learning. Any EBM is specified by three choices, the energy, which determines what the model represents; the inference procedure, which samples from or optimizes the energy; and the learning method, which fits the energy to data. We first develop these components, including sampling, variational inference, and learning by maximum likelihood, noise contrastive estimation, pseudolikelihood, score matching, and adversarial training, and show that the learning methods share one contrastive structure. We then show that discriminative models, generative models such as GANs, normalizing flows, diffusion and autoregressive models, representation learning methods such as contrastive learning, word2vec, BERT, denoising auto-encoders, and diffusion representations, reinforcement learning with EBM policies and world models, inverse reinforcement learning, and planning, as well as inference-time computation with verifiers, are all EBMs that differ in these three choices, mostly in how they handle the partition function and sampling. This view explains existing methods, organizes them into a common framework, and suggests new algorithms by replacing one component while keeping the others, with composition of energies as a principled way to combine learned models at inference time.

Contents
  1. 1Introduction
  2. 2A Brief Introduction to Energy-Based Models1. 2.1Energy-Based Models 2. 2.2Beyond EBMs: Generalized Maximum Entropy 3. 2.3Adaptability and Composability of EBMs 4. 2.4Inference with EBMs 5. 2.5Learning for EBMs 6. 2.6Unified View through Contrastive Learning
  3. 3Discriminative Models1. 3.1Logistic Regression and CRFs 2. 3.2Structured Prediction Energy Networks
  4. 4Generative Models1. 4.1Generative Adversarial Nets 2. 4.2Normalizing Flows 3. 4.3Diffusion and Flow Models 4. 4.4Energy-Inspired Models 5. 4.5Deep Equilibrium Models 6. 4.6Autoregressive Models as Approximate Ancestral Samplers
  5. 5Representation Learning1. 5.1Contrastive Representation Learning 2. 5.2Word2vec 3. 5.3BERT 4. 5.4Diffusion Representations 5. 5.5Representation-Induced Decisive Models
  6. 6Reinforcement Learning and Planning through EBMs1. 6.1Naturally Induced EBM Policies 2. 6.2RL for EBM Policies 3. 6.3Inverse RL with EBMs 4. 6.4RL with EBM World Models 5. 6.5Planning with Trajectory EBMs
  7. 7Inference-Time Computation1. 7.1Verifiers Define the Target 2. 7.2Samplers for the Target 3. 7.3Compositional Reasoning 4. 7.4Amortizing Inference-Time Computation 5. 7.5Best-of-NNSampling-Aware Fine-Tuning
  8. 8Discussion
  9. References
  10. AOverview of Methods

1Introduction

Machine learning is often divided into supervised learning, generative modeling, representation learning, and decision making, each with its own models and training objectives. However, these areas share a common problem: learning relationships among variables and using those relationships to infer unknown quantities. Energy-based models (EBMs) provide a unified perspective on this problem by representing the compatibility of a configuration through a scalar energy function. Low-energy configurations correspond to plausible observations, compatible representations, or desirable outcomes. Learning shapes this energy landscape, while inference uses it to produce predictions, samples, or actions.

This perspective connects three ideas:representation,inference, andcomposition. An energy function represents knowledge through relationships and constraints among variables. Inference uses this knowledge by searching for compatible configurations, either through optimization or sampling. Composition combines energy functions to express requirements that must be considered together. Separating these roles allows learned knowledge to be reused in different computations and combined with new information at inference time. For example, a joint energy over observations and latent variables can support both generating observations from a latent description and inferring a description from an observation. An energy over trajectories can be combined with a new goal to formulate a planning problem.

In this tutorial, which grew from the courseCSE 6243taught by Bo Dai at Georgia Tech, we develop this perspective across different generative models, representation learning methods, and planning and reinforcement learning methods. We primarily consider the probabilistic formulation, in which an energy defines an unnormalized distribution throughpθ​(𝒙)∝exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\exp(-E_{\theta}({\bm{x}})). For generative modeling, this provides a common language for comparing models that parameterize densities, learn scores, or construct sampling procedures. Autoregressive models specify conditional factors whose negative logarithms sum to an energy, while invertible normalizing flows specify densities through a change of variables. Diffusion models learn gradients oflog\logdensities at different noise levels. These connections clarify both the relationships among generative models and the different assumptions they make about representation and inference. They also provide a unified way to develop new generative models.

For representation learning, energies express compatibility between observations and latent descriptions, or between different views of the same data. Contrastive methods learn features through scores for matched and mismatched observations, while reconstruction and denoising objectives train representations to support prediction of missing or corrupted information. Viewing these objectives through their associated energies connects representation learning to conditional prediction and generative modeling. It also suggests how learned generative models can provide objectives for inferring representations of new observations.

For planning and decision-making, energies score candidate actions or trajectories according to their predicted consequences. Costs and constraints contribute energy terms, while rewards enter with the opposite sign. Planning searches for configurations that satisfy these requirements, and entropy-regularized formulations connect this search to probabilistic inference. Learned dynamics, behavior models, and task objectives can therefore contribute different components of a common inference problem.

For inference-time computation, energies score different possible solutions for a question. Different methods of inference-time computation such as selecting among sampled responses, searching for partial solutions, or iteratively refining a candidate, correspond to different procedures to minimize this energy. Fine-tuning corresponds to directly fitting this combined energy, paying the cost of inference during training rather than for every input.

Composition enables us to use these connections to solve new tasks. Energy functions over compatible variables can be added to combine their requirements, corresponding to a product of their unnormalized densities when the resulting distribution is normalizable. For example, an energy describing plausible robot trajectories can be combined with energies expressing a destination and obstacle constraints. The resulting inference problem uses learned knowledge together with task-specific information, without requiring a separate predictor to be trained for each combination. This ability to represent reusable components and reason with their combinations motivates the energy-based perspective. Its practical success depends on the accuracy and relative scales of the components, as well as the ability to optimize or sample from the composed landscape.

We begin with the formulation of EBMs and methods for inference and learning (Section2). We then examine discriminative models (Section3), generative models (Section4), representation learning (Section5), reinforcement learning and planning (Section6), and inference-time compute (Section7) through this common framework, and close with a discussion (Section8). Throughout, we ask what each method represents, how inference uses that representation, and how its components can be combined or adapted to new tasks. Our aim is to explain connections among existing methods and show how those connections can guide the design of models that learn reusable knowledge and reason with it at inference time.

2A Brief Introduction to Energy-Based Models

2.1Energy-Based Models

We start with energy-based models of a single variable, which are also known as Gibbs distributions[75]. Formally, the EBM defines the density as

pθ​(𝒙)=exp⁡(−Eθ​(𝒙))Zθ,withZθ=∫exp⁡(−Eθ​(𝒙))​𝑑𝒙,p_{\theta}({\bm{x}})=\frac{\exp\left(-E_{\theta}({\bm{x}})\right)}{Z_{\theta}},\quad\text{with}\quad Z_{\theta}=\int\exp\left(-E_{\theta}({\bm{x}})\right)d{\bm{x}},(1)whereEθ​(𝒙)E_{\theta}({\bm{x}}), known as the energy function, is some function parametrized withθ\theta, andZθZ_{\theta}is known as the partition function, which is often unknown and intractable to compute. The EBM Equation1defines a valid distribution, satisfying the positivitypθ​(𝒙)⩾0p_{\theta}\left({\bm{x}}\right)\geqslant 0and normalization∫pθ​(𝒙)​𝑑𝒙=1\int p_{\theta}\left({\bm{x}}\right)d{\bm{x}}=1. The value of the densitypθ​(𝒙)p_{\theta}({\bm{x}})in Equation1up to a multiplicative constant is fully determined by the energy functionEθ​(𝒙)E_{\theta}({\bm{x}}), enabling us to sample from the density even without knowledge of the normalization constants.

EBMs can be easily generalized to joint or conditional models with multiple variables, respectively,i.e.,

pθ​(𝒙,𝒚)=exp⁡(−Eθ​(𝒙,𝒚))ZθwithZθ=∫exp⁡(−Eθ​(𝒙,𝒚))​𝑑𝒙​𝑑𝒚,\displaystyle p_{\theta}\left({\bm{x}},{\bm{y}}\right)=\frac{\exp\left(-E_{\theta}\left({\bm{x}},{\bm{y}}\right)\right)}{Z_{\theta}}\quad\text{with}\quad Z_{\theta}=\int\exp\left(-E_{\theta}({\bm{x}},{\bm{y}})\right)d{\bm{x}}d{\bm{y}},(2)pθ​(𝒚∣𝒙)=exp⁡(−Eθ​(𝒙,𝒚))Zθ​(𝒙)withZθ​(𝒙)=∫exp⁡(−Eθ​(𝒙,𝒚))​𝑑𝒚.\displaystyle p_{\theta}\left({\bm{y}}\mid{\bm{x}}\right)=\frac{\exp\left(-E_{\theta}\left({\bm{x}},{\bm{y}}\right)\right)}{Z_{\theta}({\bm{x}})}\quad\text{with}\quad Z_{\theta}({\bm{x}})=\int\exp\left(-E_{\theta}({\bm{x}},{\bm{y}})\right)d{\bm{y}}.(3)By comparing the joint and conditional EBMs in Equation2and Equation3, we emphasize the importance of partition function, leading to one key property of EBMs: with the same energy function but different partition functions, we can represent and sample from the corresponding conditional or joint distributions. Although this property seems trivial, it will play a vital role in enabling compositionality, adaptivity, and improving training data sample complexity.

In comparison to many classes of generative models, EBMs Equation1directly model the probability density, without any forms of factorization of the distribution to enable efficient sampling. As a result, for many distributions, it can be simpler to represent the distributions as EBMs than other factorized parameterizations, at the cost of much more expensive inference. Before we dive into the detailed discussion about compositional and adaptive properties of EBMs, we first provide examples of general EBMs. In fact, a variety of classic machine learning models can be represented as special forms of EBMs.

Residual EBM.

For any EBM in Equation1, it can also be equivalently written as

pθ​(𝒙)=p0​(𝒙)​exp⁡(−E~θ​(𝒙))Zθ,withE~θ​(𝒙)=Eθ​(𝒙)+log⁡p0​(𝒙),p_{\theta}({\bm{x}})=p_{0}\left({\bm{x}}\right)\frac{\exp\left(-\tilde{E}_{\theta}\left({\bm{x}}\right)\right)}{Z_{\theta}},\quad\text{with}\quad\tilde{E}_{\theta}\left({\bm{x}}\right)=E_{\theta}({\bm{x}})+\log p_{0}\left({\bm{x}}\right),(4)wherep0​(𝒙)p_{0}\left({\bm{x}}\right)is some base probability measure. The equivalent model Equation4is known as aresidual EBM[43,5]. We emphasize that although the vanilla EBM Equation1and residual EBM Equation4share the same modeling flexibility, the residual EBM is more convenient when a good base distribution is available, as in the energy-inspired models of Section4.4and the KL-regularized policies of Section6.1.

Exponential Family.

The exponential family is one of the most important classes of distributions in statistics and machine learning[185], which possesses a number of useful properties[23]and is a special form of an EBM. A probability distribution belongs to the exponential family if it can be written in the following canonical form:

pθ​(𝒙)=h⁡(𝒙)​exp⁡(θ⊤​𝐓​(𝒙)−A⁡(θ)),p_{\theta}({\bm{x}})=h({\bm{x}})\exp\left(\theta^{\top}\mathbf{T}({\bm{x}})-A(\theta)\right),whereθ\thetais the natural parameter,𝐓⁡(𝒙)\mathbf{T}\left({\bm{x}}\right)are the sufficient statistics,h⁡(𝒙)h\left({\bm{x}}\right)denotes some base measure of𝒙{\bm{x}}, andA(θ)=log∫exp(θ⊤𝐓(𝒙))h(𝒙)d𝒙A\left(\theta\right)=\log\int\exp\left(\theta^{\top}\mathbf{T}({\bm{x}})\right)h\left({\bm{x}}\right)d{\bm{x}}is thelog\log-partition function. The exponential family includes many commonly used distributions, such as the Gaussian, Poisson and multinomial distributions, to name a few.

Obviously, the exponential family is a special case of EBMs whose energy is linear inθ\theta,i.e.,Eθ​(𝒙)=−θ⊤​𝐓​(𝒙)−log⁡h⁡(𝒙)E_{\theta}\left({\bm{x}}\right)=-\theta^{\top}\mathbf{T}\left({\bm{x}}\right)-\log h\left({\bm{x}}\right).

Maximum Entropy Models.

The Maximum Entropy Model (MaxEnt)[4,60]is a statistical modeling technique that selects the probability distribution that has the highest entropy among all distributions that satisfy a set of observed constraints derived from the training data. Formally, MaxEnt is defined as

maxq∈Δ⁡(𝒳)\displaystyle\max_{q\in\Delta\left(\mathcal{X}\right)}H(q):=−∫q(𝒙)logq(𝒙)d𝒙\displaystyle\,\,H\left(q\right):=-\int q({\bm{x}})\log q({\bm{x}})d{\bm{x}}(5)s.t.\displaystyle\mathop{\mathrm{s.t.}}𝔼q⁡(𝒙)[fi(𝒙)]=ai,∀i=1,…,k,\displaystyle\,\,\mathbb{E}_{q({\bm{x}})}\left[f_{i}({\bm{x}})\right]=a_{i},\quad\forall i=1,\ldots,k,(6)which induces the Lagrangian as

L⁡(q,λ)=−H⁡(q)−∑i=1kλi​(𝔼q⁡(𝒙)​[fi​(𝒙)]−ai)−λ0​(∫q⁡(𝒙)​𝑑𝒙−1).L\left(q,\lambda\right)=-H(q)-\sum_{i=1}^{k}\lambda_{i}\left(\mathbb{E}_{q({\bm{x}})}\left[f_{i}({\bm{x}})\right]-a_{i}\right)-\lambda_{0}\left(\int q\left({\bm{x}}\right)d{\bm{x}}-1\right).(7)Taking the partial derivative ofL⁡(q,λ)L\left(q,\lambda\right)w.r.t.q⁡(𝒙)q\left({\bm{x}}\right)and setting it to zero gives

∂L⁡(q,λ)∂q⁡(𝒙)=log⁡q⁡(𝒙)+1−∑i=1kλi​fi​(𝒙)−λ0=0⇒q∗​(𝒙)=exp⁡(∑i=1kλi​fi​(𝒙))Z,\frac{\partial L\left(q,\lambda\right)}{\partial q\left({\bm{x}}\right)}=\log q({\bm{x}})+1-\sum_{i=1}^{k}\lambda_{i}f_{i}\left({\bm{x}}\right)-\lambda_{0}=0\Rightarrow q^{*}\left({\bm{x}}\right)=\frac{\exp\left(\sum_{i=1}^{k}\lambda_{i}f_{i}\left({\bm{x}}\right)\right)}{Z},(8)which obviously is an EBM with energy functionE⁡(𝒙)=−𝝀⊤​𝐟​(𝒙)E\left({\bm{x}}\right)=-\bm{\lambda}^{\top}\mathbf{f}\left({\bm{x}}\right)with parameters𝝀\bm{\lambda}and features𝐟⁡(𝒙)\mathbf{f}\left({\bm{x}}\right).

Markov Random Fields and Conditional Random Fields.

Markov random fields (MRFs) are distributions with explicit dependency among variables. Formally, an MRF defines a probability distribution on𝒙={x1,x2,…,xd}{\bm{x}}=\left\{x_{1},x_{2},\ldots,x_{d}\right\}by an undirected graphGG, in which nodes correspond to variablesxix_{i}and edges define the dependency between two variables, leading to

p⁡(𝒙)=1Z​∏c∈Cψc​(xc)=1Z​exp⁡(∑c∈Clog⁡ψc​(xc)),p({\bm{x}})=\frac{1}{Z}\prod_{c\in C}\psi_{c}\left(x_{c}\right)=\frac{1}{Z}\exp\left(\sum_{c\in C}\log\psi_{c}\left(x_{c}\right)\right),(9)withZZas partition function,CCdenoting the set of cliques ofGG, and each factorψc​(⋅)\psi_{c}\left(\cdot\right)is a non-negative function over the variables in the corresponding subgraph.

Similarly, conditional random fields (CRFs) generalize MRFs and define the conditional distribution as

p⁡(𝒚∣𝒙)=1Z⁡(𝒙)​∏c∈Cψc​(𝒙,𝒚)=1Z⁡(𝒙)​exp⁡(∑c∈Clog⁡ψc​(𝒙,𝒚))p({\bm{y}}\mid{\bm{x}})=\frac{1}{Z({\bm{x}})}\prod_{c\in C}\psi_{c}\left({\bm{x}},{\bm{y}}\right)=\frac{1}{Z({\bm{x}})}\exp\left(\sum_{c\in C}\log\psi_{c}\left({\bm{x}},{\bm{y}}\right)\right)(10)Clearly, both MRF Equation9and CRF Equation10can be reduced to corresponding EBMs equivalently with explicit dependency structure captured by the energy functionE(𝒙)=−∑c∈Clogψc(xc)E\left({\bm{x}}\right)=-\sum_{c\in C}\log\psi_{c}\left(x_{c}\right)andE(𝒙,𝒚)=−∑c∈Clogψc(𝒙,𝒚)E\left({\bm{x}},{\bm{y}}\right)=-\sum_{c\in C}\log\psi_{c}\left({\bm{x}},{\bm{y}}\right).

Hopfield Network and (Restricted) Boltzmann Machine.

Hopfield Network was proposed as binary threshold units with recurrent connections between them. It has been revealed that if the connections are symmetric, there is a corresponding global energy function for binary𝒙{\bm{x}},

E⁡(𝒙)=−12​𝒙⊤​W​𝒙−𝒙⊤​b,with𝒙∈{−1,+1}d,E\left({\bm{x}}\right)=-\frac{1}{2}{\bm{x}}^{\top}W{\bm{x}}-{\bm{x}}^{\top}b,\quad\text{with}\quad{\bm{x}}\in\left\{-1,+1\right\}^{d},which induces a distributionp⁡(𝒙)∝exp⁡(−E⁡(𝒙))p({\bm{x}})\propto\exp\left(-E\left({\bm{x}}\right)\right)that aligns with the stationary distribution of the stochastic Hopfield network updates,i.e.,p⁡(xi=1∣𝒙−i)=11+exp⁡(−2​(∑j≠iwi​j​xj+bi))p(x_{i}=1\mid{\bm{x}}_{-i})=\frac{1}{1+\exp\left(-2\left(\sum_{j\neq i}w_{ij}x_{j}+b_{i}\right)\right)}. The induced stochastic rule and stationary distribution are also known as Boltzmann machine and Boltzmann distribution, respectively.

Furthermore, if we split the variables as two disjoint groups{𝒙,𝒚}\left\{{\bm{x}},{\bm{y}}\right\}and construct bipartite connection, we obtain the energy function,

E⁡(𝒙,𝒚)=−𝒙⊤​b−𝒚⊤​a−𝒙⊤​A​𝒚,E\left({\bm{x}},{\bm{y}}\right)=-{\bm{x}}^{\top}b-{\bm{y}}^{\top}a-{\bm{x}}^{\top}A{\bm{y}},(11)where𝒙{\bm{x}}and𝒚{\bm{y}}can be binary, categorical, or Gaussian. Since the structure of the energy function is restricted such that there is no intra-layer connections in𝒙{\bm{x}}or𝒚{\bm{y}}, the model is named as restricted Boltzmann machine. Meanwhile, due to such special structure, the components of𝒚{\bm{y}}are conditionally independent given𝒙{\bm{x}}, and vice versa.

Although EBMs define flexible distributions, it is notorious that the partition function in Equation2and Equation3is intractable, therefore, both sampling from EBMs and calculating the probability are not straightforward. Consequently, learning with EBMs is complicated. We discuss sampling in Section2.4and learning in Section2.5.

2.2Beyond EBMs: Generalized Maximum Entropy

The maximum entropy model Equation5of Section2makes two choices: it maximizes the Shannon entropy, and it imposes the moment constraints exactly; its solution Equation8is then an EBM in the exponential family. EBMs extend beyond both choices. Maximizing the Shannon entropy is equivalent to minimizing the KL divergence from a uniform base measure, which can be replaced by other divergences, and the exact constraints can be relaxed to approximate ones; different choices induce different model families[79,4,60,67]. Consider the generalized problem

minq∈Δ⁡(𝒳)D(q∥p0)s.t.‖𝔼q⁡(𝒙)[𝐟(𝒙)]−𝒂‖ℬ⩽ϵ,\min_{q\in\Delta\left(\mathcal{X}\right)}\;D\left(q\,\|\,p_{0}\right)\quad\mathop{\mathrm{s.t.}}\quad\left\|\mathbb{E}_{q({\bm{x}})}\left[\mathbf{f}\left({\bm{x}}\right)\right]-{\bm{a}}\right\|_{\mathcal{B}}\leqslant\epsilon,(12)whereDDis a convex divergence from a base measurep0p_{0},‖⋅‖ℬ\left\|\cdot\right\|_{\mathcal{B}}is a norm, andϵ⩾0\epsilon\geqslant 0allows approximate moment matching. The maximum entropy model Equation5is the case of the KL divergence, a uniformp0p_{0}, andϵ=0\epsilon=0. The two choices in Equation12change the model in different ways.

  • •The divergence determines the model family.For anff-divergence with convex generatorφ\varphi, the optimum is Dφ(q∥p0)=∫p0(𝒙)φ(q⁡(𝒙)p0​(𝒙))d𝒙⟹q∗(𝒙)=p0(𝒙)(φ′)−1(𝝀⊤𝐟(𝒙)−λ0),D_{\varphi}\left(q\,\|\,p_{0}\right)=\int p_{0}({\bm{x}})\,\varphi\left(\frac{q({\bm{x}})}{p_{0}({\bm{x}})}\right)d{\bm{x}}\quad\Longrightarrow\quad q^{*}({\bm{x}})=p_{0}({\bm{x}})\,(\varphi^{\prime})^{-1}\left(\bm{\lambda}^{\top}\mathbf{f}({\bm{x}})-\lambda_{0}\right),(13)withλ0\lambda_{0}chosen for normalization, which is an exponential family only forφ⁡(u)=u​log⁡u\varphi(u)=u\log u. More generally, regular exponential families are in one-to-one correspondence with regular Bregman divergences[13], and other divergences and generalized entropies induce generalized, or deformed, exponential families[79,129,67]. For theα\alpha-divergence,φα​(u)=(uα−α​u+α−1)/(α⁡(α−1))\varphi_{\alpha}(u)=\left(u^{\alpha}-\alpha u+\alpha-1\right)/\left(\alpha(\alpha-1)\right), it is the power-law family q∗​(𝒙)=p0​(𝒙)​[1+(α−1)​(𝝀⊤​𝐟​(𝒙)−λ0)]+1/(α−1),q^{*}({\bm{x}})=p_{0}({\bm{x}})\left[1+(\alpha-1)\left(\bm{\lambda}^{\top}\mathbf{f}({\bm{x}})-\lambda_{0}\right)\right]_{+}^{1/(\alpha-1)},(14)which recovers the exponential family asα→1\alpha\to 1, and otherwise has heavier tails or bounded support. It corresponds to theqq-exponential family of Tsallis statistics[129]. Replacing the exponential family by such a heavy-tailed family changes the behavior of the learned model,e.g.,tt-logistic regression[46]replaces the softmax of logistic regression by att-exponential family, which makes the classifier robust to label noise.
  • •The norm determines the regularization and the feature space.Withϵ>0\epsilon>0, the dual of Equation12becomes maximum likelihood regularized by the dual norm[4],e.g., with anℓ1\ell_{1}penalty that yields sparse models[60]. Taking𝐟⁡(𝒙)=k⁡(𝒙,⋅)\mathbf{f}({\bm{x}})=k({\bm{x}},\cdot)as the feature map of a reproducing kernel Hilbert space (RKHS)ℋ\mathcal{H}andℬ\mathcal{B}as its norm gives the infinite-dimensional kernel exponential familyp⁡(𝒙)∝p0​(𝒙)​exp⁡(⟨λ,k⁡(𝒙,⋅)⟩ℋ)p({\bm{x}})\propto p_{0}({\bm{x}})\exp\left(\left\langle\lambda,k({\bm{x}},\cdot)\right\rangle_{\mathcal{H}}\right)with an RKHS-norm penalty[4,25,164,34], an EBM whose energy is a nonparametric function inℋ\mathcal{H}.

2.3Adaptability and Composability of EBMs

A major benefit of learning EBMs is their flexibility in representing different probability distributions using the same energy function. As noted after Equation3, a joint energy also defines the conditional distribution obtained by fixing any subset of its variables, and only the partition function changes. Energies can further be added, subtracted, and combined, which forms new distributions from learned ones without retraining[58,50]. Below, we describe these operations on sets and on distributions, discuss when a composition is correct and how it differs from a product of experts, and show how the same operations adapt a pretrained model and how composed energies are sampled.

Composing EBM Set Functions.

We first illustrate how composition over energy functions can be used to implement logical set operations[51]. Consider setsAAandBBand learned energy functionsEA​(𝒙)E_{A}({\bm{x}})andEB​(𝒙)E_{B}({\bm{x}})for these sets, for instance

EA​(𝒙)={0,for​𝒙∈AC,for​𝒙∉A,E_{A}({\bm{x}})=\begin{cases}0,&\text{for }{\bm{x}}\in A\\ C,&\text{for }{\bm{x}}\not\in A,\\ \end{cases}(15)whereCCis a large numerical value. Sampling under these learned energy functionsEA​(𝒙)E_{A}({\bm{x}})orEB​(𝒙)E_{B}({\bm{x}})would correspond to drawing samples from either setAAorBB. Logical operations on the sets then become arithmetic on the energies, as illustrated in Figure1(a).

  1. 1.LogicalAND.The intersectionA∩BA\cap Bis represented by the sum of the energies, EA∧B​(𝒙)=EA​(𝒙)+EB​(𝒙),E_{A\wedge B}({\bm{x}})=E_{A}({\bm{x}})+E_{B}({\bm{x}}),(16)which is00onA∩BA\cap Band at leastCCelsewhere, so that low-energy samples satisfy both requirements.
  2. 2.LogicalOR.The unionA∪BA\cup Bis represented by the soft minimum of the energies, EA∨B​(𝒙)=−log⁡(exp⁡(−EA​(𝒙))+exp⁡(−EB​(𝒙))),E_{A\vee B}({\bm{x}})=-\log\left(\exp\left(-E_{A}({\bm{x}})\right)+\exp\left(-E_{B}({\bm{x}})\right)\right),(17)which is at most00onA∪BA\cup Band equalsC−log⁡2C-\log 2elsewhere. It differs frommin⁡{EA​(𝒙),EB​(𝒙)}\min\left\{E_{A}({\bm{x}}),E_{B}({\bm{x}})\right\}by at mostlog⁡2\log 2, so low-energy samples satisfy either requirement.
  3. 3.LogicalNOT.Negation subtracts an energy. The complement of a bounded set is unbounded, so negation is applied relative to another set:BBwithoutAAis represented by EB∧¬A​(𝒙)=EB​(𝒙)−EA​(𝒙)+C,E_{B\wedge\neg A}({\bm{x}})=E_{B}({\bm{x}})-E_{A}({\bm{x}})+C,(18)which is00onB∖AB\setminus Aand at leastCCelsewhere. The subtracted energy acts as a negation operation: it raises the energy whereverAAholds and leaves it unchanged elsewhere.

Each operation returns an energy, so the operations can be nested, and they apply to learned energies as well as to the idealized ones of Equation15. Figure1(b) shows faces sampled from nested compositions of conditional energies that were trained independently, each on a single attribute[51].

Refer to captionFigure 1:Logical composition of energy functions.(a)AND,OR, andNOTapplied to two setsAAandBB; the composed energy is low in the shaded region.(b)Faces sampled from compositions of conditional energies, each trained independently on one attribute of CelebA. Figures fromDu et al. [51].

Composing EBM Probability Distributions.

We can likewise combine distributions rather than sets. Product, mixture, and inversion are the distributional counterparts ofAND,OR, andNOT, but the energies are nowlog\log-densities, so their values, and not only their minimizers, matter, as illustrated in Figure2. Letpi​(𝒙)=exp⁡(−Ei​(𝒙))/Zip_{i}({\bm{x}})=\exp\left(-E_{i}({\bm{x}})\right)/Z_{i}fori=1,2i=1,2.

  1. 1.Product of Distributions.The product of the two distributions can be written as pproduct​(𝒙)∝p1​(𝒙)​p2​(𝒙)∝e−(E1​(𝒙)+E2​(𝒙)).p_{\text{product}}({\bm{x}})\propto p_{1}({\bm{x}})p_{2}({\bm{x}})\propto e^{-(E_{1}({\bm{x}})+E_{2}({\bm{x}}))}.(19)Therefore, we can construct an energy functionE′​(𝒙)E^{\prime}({\bm{x}})which represents the product of the densities using the expression E′​(𝒙)=E1​(𝒙)+E2​(𝒙),E^{\prime}({\bm{x}})=E_{1}({\bm{x}})+E_{2}({\bm{x}}),(20)providing a way to compose energy functions to implement the product of densities. The product of densities allows us to construct a new density that combines the information in both distributions – sampling𝒙{\bm{x}}which is highly likely under both distributions[50,197]. The partition functionsZ1Z_{1}andZ2Z_{2}play no role, since adding a constant to either energy only changes the normalizer of the product, and the product is normalizable whenever one of the densities is bounded, since thenp1​p2⩽(sup𝒙p1​(𝒙))​p2p_{1}p_{2}\leqslant\left(\sup_{\bm{x}}p_{1}({\bm{x}})\right)\,p_{2}. Weighting the energies,w1​E1+w2​E2w_{1}E_{1}+w_{2}E_{2}withw1,w2>0w_{1},w_{2}>0, givesp1w1​p2w2p_{1}^{w_{1}}p_{2}^{w_{2}}, in which each weight acts as an inverse temperature that sharpens or flattens its component.
  2. 2.Mixture of Distributions.We can represent the mixturepmix​(𝒙)=w1​p1​(𝒙)+w2​p2​(𝒙)p_{\text{mix}}({\bm{x}})=w_{1}p_{1}({\bm{x}})+w_{2}p_{2}({\bm{x}}), withw1+w2=1w_{1}+w_{2}=1, by the energy Emix​(𝒙)=−log⁡(w1​exp⁡(−E1​(𝒙))Z1+w2​exp⁡(−E2​(𝒙))Z2),E_{\text{mix}}({\bm{x}})=-\log\left(w_{1}\frac{\exp\left(-E_{1}({\bm{x}})\right)}{Z_{1}}+w_{2}\frac{\exp\left(-E_{2}({\bm{x}})\right)}{Z_{2}}\right),(21)which is the soft minimum Equation17with each energyEiE_{i}shifted bylog⁡Zi−log⁡wi\log Z_{i}-\log w_{i}. Unlike the product, the mixture depends on the partition functions. An energy is determined only up to an additive constant, which does not change its own distribution but shifts the weight of its component. For instance, in the energy composition operator in Equation17. the soft minimum ofE1E_{1}andE2E_{2}alone is the mixture with weights proportional toZ1Z_{1}andZ2Z_{2}. For general distributions, a mixture with given weights requireslog⁡Z1−log⁡Z2\log Z_{1}-\log Z_{2}, which can be learned together with the energy, as the constantccof binary NCE Equation42, or estimated with the variational bound Equation30. If the mixture is only sampled, the partition functions can be avoided by ancestral sampling: drawiiwith probabilitywiw_{i}, then draw𝒙∼pi{\bm{x}}\sim p_{i}. They are needed once the mixture is composed further,e.g., multiplied by a third distribution, since MCMC on the composed energy evaluatesEmixE_{\text{mix}}itself.
  3. 3.Inversion of Distributions.We can represent a distribution that favors points that are likely underp1p_{1}but unlikely underp2p_{2}by raisingp2p_{2}to a negative power, pinv​(𝒙)∝p1​(𝒙)p2​(𝒙)α,Einv​(𝒙)=E1​(𝒙)−α​E2​(𝒙),p_{\text{inv}}({\bm{x}})\propto\frac{p_{1}({\bm{x}})}{p_{2}({\bm{x}})^{\alpha}},\qquad E_{\text{inv}}({\bm{x}})=E_{1}({\bm{x}})-\alpha E_{2}({\bm{x}}),(22)withα>0\alpha>0, which is the distributional counterpart of Equation18. Like the product, the inversion does not depend on the partition functions, but may not be normalizable. For Gaussianspi=𝒩⁡(0,σi2​I)p_{i}=\mathcal{N}\left(0,\sigma_{i}^{2}I\right),pinvp_{\text{inv}}is normalizable only ifα​σ12<σ22\alpha\sigma_{1}^{2}<\sigma_{2}^{2},i.e., the negated expert must be broad relative to the positive one. Classifier-free guidance Equation88is an inversion of this kind raised to the power1+w1+w, sincept​(𝒙∣y)1+w/pt​(𝒙)w=(pt​(𝒙∣y)/pt​(𝒙)α)1+wp_{t}({\bm{x}}\mid y)^{1+w}/p_{t}({\bm{x}})^{w}=\left(p_{t}({\bm{x}}\mid y)/p_{t}({\bm{x}})^{\alpha}\right)^{1+w}withα=w/(1+w)<1\alpha=w/(1+w)<1, and its negated distribution is the unconditional model.

Figure 2:Composing two one-dimensional densities.Left:p1p_{1}(dotted) andp2p_{2}(dashed), repeated in gray in the other panels, where each composition (blue) is scaled to its own maximum. The product keeps the mass on which both agree, and the mixture keeps the mass of both. Adding the unnormalized densities,e−E1+e−E2e^{-E_{1}}+e^{-E_{2}}, instead weights each component by its partition function Equation21, so the broadp2p_{2}gets weightw2≈0.72w_{2}\approx 0.72rather than12\tfrac{1}{2}(here eachEiE_{i}has minimum zero). The inversionp1/p20.7p_{1}/p_{2}^{0.7}keeps the mass ofp1p_{1}wherep2p_{2}is low.

When Is a Composition Correct?

We can understand what a product does through Bayes’ rule. Letc1,…,cnc_{1},\ldots,c_{n}be conditions on𝒙{\bm{x}}, such as attributes of an image or requirements on a trajectory, and suppose we have an unconditional EBMp⁡(𝒙)∝exp⁡(−E⁡(𝒙))p({\bm{x}})\propto\exp\left(-E({\bm{x}})\right)and a conditional EBMp⁡(𝒙∣ci)∝exp⁡(−E⁡(𝒙∣ci))p({\bm{x}}\mid c_{i})\propto\exp\left(-E({\bm{x}}\mid c_{i})\right)for each condition alone. If the conditions are conditionally independent given𝒙{\bm{x}}, then

p⁡(𝒙∣c1,…,cn)\displaystyle p({\bm{x}}\mid c_{1},\ldots,c_{n})∝p⁡(𝒙)​∏i=1np⁡(ci∣𝒙)∝p⁡(𝒙)​∏i=1np⁡(𝒙∣ci)p⁡(𝒙),\displaystyle\propto p({\bm{x}})\prod_{i=1}^{n}p(c_{i}\mid{\bm{x}})\propto p({\bm{x}})\prod_{i=1}^{n}\frac{p({\bm{x}}\mid c_{i})}{p({\bm{x}})},(23)E⁡(𝒙∣c1,…,cn)\displaystyle E({\bm{x}}\mid c_{1},\ldots,c_{n})=E⁡(𝒙)+∑i=1n(E⁡(𝒙∣ci)−E⁡(𝒙)),\displaystyle=E({\bm{x}})+\sum_{i=1}^{n}\left(E({\bm{x}}\mid c_{i})-E({\bm{x}})\right),up to constants that do not depend on𝒙{\bm{x}}[117]. Each differenceE⁡(𝒙∣ci)−E⁡(𝒙)E({\bm{x}}\mid c_{i})-E({\bm{x}})equals−log⁡p⁡(ci∣𝒙)-\log p(c_{i}\mid{\bm{x}})up to a constant,i.e., it is the energy of an implicit classifier, so the conjunction adds one classifier energy per condition to a single prior, which is counted once rather thannntimes. Weighting the differences gives the guided distributions of Section4.3, withn=1n=1for classifier-free guidance, and adding the difference forc1c_{1}while subtracting the one forc2c_{2}gives the negationp⁡(𝒙)​p​(c1∣𝒙)/p⁡(c2∣𝒙)p({\bm{x}})\,p(c_{1}\mid{\bm{x}})/p(c_{2}\mid{\bm{x}}), an inversion Equation22whose negated expert is the implicit classifier ofc2c_{2}. The derivation makes two requirements explicit. First, the conditions must be conditionally independent given𝒙{\bm{x}}, which holds, for example, when each condition is a function of𝒙{\bm{x}}. Second, eachp⁡(𝒙∣ci)p({\bm{x}}\mid c_{i})must be accurate where the composition places its mass, a region that may contain few training examples for any single condition. The first is a modeling assumption, and the second determines how far a composition generalizes beyond its training data.

What Does Composition Do?

Composition reuses learned components in new combinations. Each component describes one aspect of the data or the task, such as a concept, a constraint, a dynamics model, or a goal, and may be a separately trained model or a conditional model evaluated under one condition. Components may also be defined over different subsets of the variables, in which case the composed energy is an MRF Equation9whose factors are learned separately and whose graph is chosen for each task, as when the constraints among objects in a scene are composed into a factor graph over their poses[197]. Since the components are learned separately, training needs to cover each component but not each combination. Suppose𝒙{\bm{x}}is described byKKconditions, each taking one ofMMvalues. A single model ofp⁡(𝒙∣c1,…,cK)p({\bm{x}}\mid c_{1},\ldots,c_{K})must be trained on enough of theMKM^{K}combinations, whereas the composition Equation23only requires theK​MKMconditionalsp⁡(𝒙∣ck)p({\bm{x}}\mid c_{k}), and it generates combinations that never appear together in the training data[51,117]. The same operations recur throughout this tutorial: guided sampling multiplies a diffusion model by a classifier (Section4.3), planners compose dynamics, goals, and obstacles (Section6.5), and reasoning composes the energies of individual constraints into larger problems (Section7.3). The product Equation20has the form of a product of experts[87], which uses it to model a single distribution with jointly trained experts; composition uses it to combine models trained separately. SeeDu and Kaelbling [50]for a broader discussion.

Adaptation.

The same operations adapt a pretrained model to new data or requirements without retraining it. Conditioning is the simplest case: by Equation2and Equation3, clamping any subset of the variables of a joint energy, such as the visible pixels of an image or the start and goal of a trajectory, turns the same energy into a conditional model, and MCMC never needs the new partition function. A residual energy adapts a model to new data: by Equation4,p⁡(𝒙)∝p0​(𝒙)​exp⁡(−E~θ​(𝒙))p({\bm{x}})\propto p_{0}({\bm{x}})\exp\left(-\tilde{E}_{\theta}({\bm{x}})\right)keeps a pretrainedp0p_{0}fixed and learns onlyE~θ\tilde{E}_{\theta}, which can be small when the new distribution is close to the old one. This is the structure of the KL-regularized fine-tuning of language models in Section6.1, whereE~=−r/λ\tilde{E}=-r/\lambda, and of the probabilistic adaptation of video models, in which a large pretrained text-to-video model, used only through its score and without fine-tuning, is composed as a product with a small model trained on domain-specific videos[194]. Finally, a new requirement is a new energy term: the planning problems of Section6.5adapt a model of trajectories to a goal and constraints by adding their energies.

Sampling from Compositions.

A composed energy is sampled or minimized with the methods of Section2.4, which need the composed energy or its gradient but not the partition function. Three practical issues remain. First, reading a sum of energies as a product of distributions requires each energy to be alog\log-density up to a constant. Energies trained by regression (Section2.5) or with a margin (Section3) are not maximum likelihood fits, and for them the sum is better read as an objective, as in the set operations above: its minimizers satisfy all requirements when the requirements are compatible, and prediction by energy minimization Equation35applies directly. Second, separately trained energies have no common scale, so the weights in∑iwi​Ei\sum_{i}w_{i}E_{i}act as inverse temperatures that must be chosen at inference time. Third, the modes of a product lie where all components agree, which can be a small region far from the modes of each component, so the composed landscape is harder to sample than its parts. Annealing through smoothed energies helps, and diffusion models provide such a sequence for each component; however, adding their scores at a noise level does not give the score of the smoothed product, so Langevin or MCMC corrections on the summed energies are needed to sample the composition correctly (Section4.3)[49].

2.4Inference with EBMs

In this section, we first introduce the approximate algorithms for calculating the corresponding probability distributions induced by EBMs, which can be largely categorized in two classes:Metropolis–Hastings algorithmvia generating samples andvariational inferencevia distribution approximation. Then, we introduce prediction by optimization, which returns a single output rather than samples. We mainly discuss the inference methods for unconditional EBMs Equation2, however, the algorithms can be easily generalized for conditional EBMs Equation3.

Metropolis-Hastings Sampling.

SinceZθZ_{\theta}is intractable, we cannot sample from or calculate the probability ofpθ​(𝒙)∝exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\exp\left(-E_{\theta}({\bm{x}})\right)directly. Markov chain Monte Carlo (MCMC) instead constructs a Markov chain whose stationary distribution ispθp_{\theta}, and treats the states of the chain after a burn-in period as approximate samples. The Metropolis-Hastings (MH) algorithm[125,85]is the general recipe: given the current state𝒙{\bm{x}}, it draws a candidate𝒙′∼q⁡(𝒙′∣𝒙){\bm{x}}^{\prime}\sim q({\bm{x}}^{\prime}\mid{\bm{x}})from a proposal distribution and accepts it with probability

α⁡(𝒙,𝒙′)=min⁡{1,exp⁡(−Eθ​(𝒙′))​q​(𝒙∣𝒙′)exp⁡(−Eθ​(𝒙))​q​(𝒙′∣𝒙)},\alpha\left({\bm{x}},{\bm{x}}^{\prime}\right)=\min\left\{1,\frac{\exp\left(-E_{\theta}({\bm{x}}^{\prime})\right)\,q({\bm{x}}\mid{\bm{x}}^{\prime})}{\exp\left(-E_{\theta}({\bm{x}})\right)\,q({\bm{x}}^{\prime}\mid{\bm{x}})}\right\},(24)otherwise staying at𝒙{\bm{x}}. The partition function cancels in the ratio, so only energy differencesEθ​(𝒙′)−Eθ​(𝒙)E_{\theta}({\bm{x}}^{\prime})-E_{\theta}({\bm{x}})are required, and the acceptance step guarantees detailed balance with respect topθp_{\theta}for any valid proposal. Different MH samplers differ only inthe choice ofqq, which determines how the energy function is used.

The Gibbs sampler[72]updates one variable (or block of variables) at a time, using the full conditionalpθ​(xi∣𝒙−i)p_{\theta}(x_{i}\mid{\bm{x}}_{-i})as the proposal. With this choice ofqq, the acceptance probability in Equation24is always one, which means the candidate is always accepted. The conditionals only involve the energy terms that containxix_{i}, which makes Gibbs sampling natural for MRFs and Boltzmann machines. Particularly, in RBMs, the conditional independence of𝒚{\bm{y}}given𝒙{\bm{x}}and vice versa allows each layer to be sampled in one block.

For continuous𝒙{\bm{x}}and differentiable energies, the gradient∇𝒙Eθ​(𝒙)\nabla_{\bm{x}}E_{\theta}({\bm{x}})provides a much better proposal than random perturbations. Langevin dynamics follows the gradient with injected noise,

𝒙(t+1)=𝒙(t)−η​∇𝒙Eθ​(𝒙(t))+2​η​𝝃(t),𝝃(t)∼𝒩⁡(0,I),{\bm{x}}^{(t+1)}={\bm{x}}^{(t)}-\eta\nabla_{\bm{x}}E_{\theta}\left({\bm{x}}^{(t)}\right)+\sqrt{2\eta}\,\bm{\xi}^{(t)},\quad\bm{\xi}^{(t)}\sim\mathcal{N}\left(0,I\right),(25)which converges topθp_{\theta}asη→0\eta\to 0. With a finite step size, the update is biased; using Equation25as the proposal of an MH step removes the bias, yielding the Metropolis-adjusted Langevin algorithm (MALA)[147]. In practice, many EBM learning methods run the unadjusted version for a fixed number of steps.

Langevin dynamics moves by a small random step at each iteration, so it explores the space slowly, like a random walk. Hamiltonian Monte Carlo (HMC)[59,130]avoids this by borrowing the dynamics of a physical particle. It introduces an auxiliary momentum𝒗∈ℝd{\bm{v}}\in\mathbb{R}^{d}and defines the Hamiltonian

H⁡(𝒙,𝒗)=Eθ​(𝒙)+12​‖𝒗‖22,H({\bm{x}},{\bm{v}})=E_{\theta}({\bm{x}})+\frac{1}{2}\|{\bm{v}}\|_{2}^{2},(26)i.e., a potential energyEθ​(𝒙)E_{\theta}({\bm{x}})plus a kinetic energy. The joint distributionp⁡(𝒙,𝒗)∝exp⁡(−H⁡(𝒙,𝒗))=pθ​(𝒙)​𝒩​(𝒗,0,I)p({\bm{x}},{\bm{v}})\propto\exp\left(-H({\bm{x}},{\bm{v}})\right)=p_{\theta}({\bm{x}})\,\mathcal{N}\left({\bm{v}};0,I\right)haspθp_{\theta}as its marginal on𝒙{\bm{x}}, so it suffices to sample from the joint and discard𝒗{\bm{v}}. Each HMC iteration first resamples the momentum𝒗∼𝒩⁡(0,I){\bm{v}}\sim\mathcal{N}\left(0,I\right), and then moves(𝒙,𝒗)({\bm{x}},{\bm{v}})along Hamilton’s equations,

d​𝒙d​t=𝒗,d​𝒗d​t=−∇𝒙Eθ​(𝒙).\frac{d{\bm{x}}}{dt}={\bm{v}},\qquad\frac{d{\bm{v}}}{dt}=-\nabla_{\bm{x}}E_{\theta}({\bm{x}}).(27)The particle speeds up when rolling down the energy landscape and slows down when climbing, while the total energyHHstays constant. Hence it can travel far from its starting point to a state of similar probability. Since Equation27cannot be solved exactly, it is simulated forLLsteps of the leapfrog integrator with step sizeϵ\epsilon,

𝒗←𝒗−ϵ2​∇𝒙Eθ​(𝒙),𝒙←𝒙+ϵ​𝒗,𝒗←𝒗−ϵ2​∇𝒙Eθ​(𝒙).{\bm{v}}\leftarrow{\bm{v}}-\frac{\epsilon}{2}\nabla_{\bm{x}}E_{\theta}({\bm{x}}),\qquad{\bm{x}}\leftarrow{\bm{x}}+\epsilon{\bm{v}},\qquad{\bm{v}}\leftarrow{\bm{v}}-\frac{\epsilon}{2}\nabla_{\bm{x}}E_{\theta}({\bm{x}}).(28)The leapfrog integrator is reversible and preserves volume, so the end point(𝒙′,𝒗′)({\bm{x}}^{\prime},{\bm{v}}^{\prime})can be used as an MH proposal with a simple acceptance probabilitymin⁡{1,exp⁡(H⁡(𝒙,𝒗)−H⁡(𝒙′,𝒗′))}\min\left\{1,\exp\left(H({\bm{x}},{\bm{v}})-H({\bm{x}}^{\prime},{\bm{v}}^{\prime})\right)\right\}, which corrects the discretization error. Because the leapfrog integrator nearly conservesHH, this probability stays close to one even for distant proposals. HMC thus trades more gradient evaluations per sample (LLper iteration) for much less correlated samples. Its performance depends onϵ\epsilonandLL: a largeϵ\epsilonlowers the acceptance rate, while a poorly chosenLLwastes computation or makes the trajectory turn back on itself. The No-U-Turn sampler[91]balances this trade-off by settingLLadaptively. With a single leapfrog step (L=1L=1), HMC reduces to MALA with step sizeη=ϵ2/2\eta=\epsilon^{2}/2.

The exact samplers above, general MH, Gibbs sampling, MALA, and HMC, are all special cases of the MH algorithm; unadjusted Langevin dynamics is not, and does not sample exactly frompθp_{\theta}at a finite step size. These samplers place different requirements on the energy function: general MH and Gibbs sampling only need to evaluate energies (or conditionals), and therefore apply to discrete and structured spaces, whereas Langevin dynamics and HMC need the gradient∇𝒙Eθ\nabla_{\bm{x}}E_{\theta}, and therefore require continuous inputs and differentiable energies.

Amortized Sampling via Variational Inference.

MCMC samplers pay their cost for every sample: each new sample requires running a chain for many steps, and consecutive samples are correlated. Variational inference takes a different route: it fits a tractable distributionqϕ​(𝒙)q_{\phi}({\bm{x}})to approximate EBMpθp_{\theta}, so that afterwards drawing a sample costs only one pass throughqϕq_{\phi}; the cost of inference is thusamortizedover all samples. The standard objective is minimizing the reverse Kullback-Leibler divergence,

minqϕKL(qϕ∥pθ)=𝔼𝒙∼qϕ[Eθ(𝒙)]−H(qϕ)+logZθ,\min_{q_{\phi}}\,\,\mathrm{KL}\left(q_{\phi}\|p_{\theta}\right)=\mathbb{E}_{{\bm{x}}\sim q_{\phi}}\left[E_{\theta}({\bm{x}})\right]-H\left(q_{\phi}\right)+\log Z_{\theta},(29)whereH⁡(qϕ)=−𝔼qϕ​[log⁡qϕ​(𝒙)]H\left(q_{\phi}\right)=-\mathbb{E}_{q_{\phi}}\left[\log q_{\phi}({\bm{x}})\right]is the entropy ofqϕq_{\phi}. Sincelog⁡Zθ\log Z_{\theta}does not depend onϕ\phi, we can fitqϕq_{\phi}by minimizing𝔼qϕ​[Eθ​(𝒙)]−H⁡(qϕ)\mathbb{E}_{q_{\phi}}\left[E_{\theta}({\bm{x}})\right]-H\left(q_{\phi}\right), which never evaluates the intractable partition function. The first term pulls the samples toward low-energy regions, and the entropy term keeps them spread out instead of collapsing onto a single minimum. Because the KL divergence is non-negative, Equation29also yields the variational lower bound

log⁡Zθ⩾𝔼𝒙∼qϕ​[−Eθ​(𝒙)]+H⁡(qϕ),\log Z_{\theta}\geqslant\mathbb{E}_{{\bm{x}}\sim q_{\phi}}\left[-E_{\theta}({\bm{x}})\right]+H\left(q_{\phi}\right),(30)which is tight if and only ifqϕ=pθq_{\phi}=p_{\theta}. Therefore, the same optimization provides both a sampler and an estimate of thelog\log-partition function, which can also be used for learning EBMs.

The only remaining part is that the parametrization choice ofqϕq_{\phi}needs to make both sampling and the entropy tractable. The classical choice for MRFs is the mean-field approximationqϕ​(𝒙)=∏iqϕi​(xi)q_{\phi}({\bm{x}})=\prod_{i}q_{\phi_{i}}(x_{i}), which ignores the dependencies among variables[185]. Modern choices are neural samplers: normalizing flows[146]and autoregressive models give exactlog\logdensities, and hence exact entropies, variational auto-encoders[104]give a lower bound on thelog\logdensity, and implicit generators𝒙=gϕ​(𝒛){\bm{x}}=g_{\phi}({\bm{z}})with𝒛∼𝒩⁡(0,I){\bm{z}}\sim\mathcal{N}\left(0,I\right)are more flexible but require estimating the entropy[101,34,36].

To optimize the variational objective Equation29, we can exploit the stochastic gradient descent method, which requires estimating the gradient w.r.t.ϕ\phi. The difficulty is thatϕ\phiappears in the distribution the expectation is taken over. There are two standard estimators. For continuous𝒙{\bm{x}}and an implicit or reparameterizableqϕq_{\phi},i.e.,𝒙=gϕ​(𝒛){\bm{x}}=g_{\phi}({\bm{z}})with𝒛∼𝒩⁡(0,I){\bm{z}}\sim\mathcal{N}\left(0,I\right), the reparameterization trick[104]movesϕ\phiinside the expectation,

∇ϕ𝔼𝒛​[Eθ​(gϕ​(𝒛))]=𝔼𝒛​[(∂gϕ​(𝒛)∂ϕ)⊤​∇𝒙Eθ​(gϕ​(𝒛))],\nabla_{\phi}\mathbb{E}_{{\bm{z}}}\left[E_{\theta}\left(g_{\phi}({\bm{z}})\right)\right]=\mathbb{E}_{{\bm{z}}}\left[\left(\frac{\partial g_{\phi}({\bm{z}})}{\partial\phi}\right)^{\top}\nabla_{\bm{x}}E_{\theta}\left(g_{\phi}({\bm{z}})\right)\right],(31)which again uses∇𝒙Eθ\nabla_{\bm{x}}E_{\theta}. For discrete𝒙{\bm{x}}, or whenever∇𝒙Eθ\nabla_{\bm{x}}E_{\theta}is unavailable, we use the REINFORCE, or score-function, estimator[190]. It relies on the identity∇ϕqϕ​(𝒙)=qϕ​(𝒙)​∇ϕ​log⁡qϕ​(𝒙)\nabla_{\phi}q_{\phi}({\bm{x}})=q_{\phi}({\bm{x}})\nabla_{\phi}\log q_{\phi}({\bm{x}}), which gives

∇ϕ𝔼𝒙∼qϕ​[Eθ​(𝒙)+log⁡qϕ​(𝒙)]=𝔼𝒙∼qϕ​[(Eθ​(𝒙)+log⁡qϕ​(𝒙)−b)​∇ϕ​log​qϕ​(𝒙)],\nabla_{\phi}\mathbb{E}_{{\bm{x}}\sim q_{\phi}}\left[E_{\theta}({\bm{x}})+\log q_{\phi}({\bm{x}})\right]=\mathbb{E}_{{\bm{x}}\sim q_{\phi}}\left[\left(E_{\theta}({\bm{x}})+\log q_{\phi}({\bm{x}})-b\right)\nabla_{\phi}\log q_{\phi}({\bm{x}})\right],(32)where the left-hand side is exactly the variational objective,i.e.,𝔼qϕ​[Eθ​(𝒙)]−H⁡(qϕ)\mathbb{E}_{q_{\phi}}\left[E_{\theta}({\bm{x}})\right]-H\left(q_{\phi}\right). The derivative oflog⁡qϕ\log q_{\phi}inside the expectation drops out because𝔼qϕ​[∇ϕ​log​qϕ​(𝒙)]=0\mathbb{E}_{q_{\phi}}\left[\nabla_{\phi}\log q_{\phi}({\bm{x}})\right]=0; for the same reason, any constant baselinebbcan be subtracted without introducing bias. REINFORCE only needs to evaluate the energy and thelog\log-density ofqϕq_{\phi}at the samples, so it applies to any𝒙{\bm{x}}, including discrete and structured outputs. Its price is high variance, as it only uses the value of the energy rather than its gradient. Therefore, in practice, a baselinebb,e.g., the average ofEθ​(𝒙)+log⁡qϕ​(𝒙)E_{\theta}({\bm{x}})+\log q_{\phi}({\bm{x}})over the other samples in a batch, or other control variates are necessary to make it work. In short, the two estimators trade generality for variance: the reparameterization estimator Equation31uses the gradient of the energy and usually has much lower variance, but requires continuous𝒙{\bm{x}}, a differentiableEθE_{\theta}, and a reparameterizableqϕq_{\phi}; REINFORCE Equation32only needs energy values andlog⁡qϕ\log q_{\phi}, and so applies to discrete or non-differentiable settings, at the cost of higher variance. When both are applicable, the reparameterization estimator is generally preferred.

Compared with MCMC, variational inference is fast at sampling time but biased: the error is limited by the family ofqϕq_{\phi}, and the reverse KL Equation29is mode-seeking, soqϕq_{\phi}tends to miss some modes ofpθp_{\theta}. The two can be combined[36]: a learnedqϕq_{\phi}can provide initializations for short MCMC chains, or serve as the proposal in an MH step, whose acceptance probability Equation24then corrects the bias ofqϕq_{\phi}.

Prediction.

In addition to drawing samples, we can use an EBM to make a prediction given an input𝒙{\bm{x}}. For a conditional model

pθ​(𝒚∣𝒙)=exp⁡(−Eθ​(𝒙,𝒚))Zθ​(𝒙),p_{\theta}({\bm{y}}\mid{\bm{x}})=\frac{\exp(-E_{\theta}({\bm{x}},{\bm{y}}))}{Z_{\theta}({\bm{x}})},(33)a maximum a posteriori (MAP) prediction is

𝒚^MAP∈arg​max𝒚⁡pθ​(𝒚∣𝒙)=arg​min𝒚⁡Eθ​(𝒙,𝒚).\hat{{\bm{y}}}_{\mathrm{MAP}}\in\operatorname*{arg\,max}_{{\bm{y}}}p_{\theta}({\bm{y}}\mid{\bm{x}})=\operatorname*{arg\,min}_{{\bm{y}}}E_{\theta}({\bm{x}},{\bm{y}}).(34)The partition function depends on𝒙{\bm{x}}but not on the candidate output𝒚{\bm{y}}, so it is not needed to compare predictions. More generally, energy minimization defines a prediction rule even when the energy does not induce a normalizable probability distribution, provided a minimum exists. The probabilistic interpretation additionally requires0<Zθ​(𝒙)<∞0<Z_{\theta}({\bm{x}})<\infty.

The computation required to find a prediction depends on the energy and the output space. For a small set of discrete labels, we can evaluate every candidate and select the one with the lowest energy. For continuous outputs and differentiable energies, we can iteratively update a candidate through gradient descent,

𝒚(t+1)=𝒚(t)−ηt​∇𝒚Eθ​(𝒙,𝒚(t)),{\bm{y}}^{(t+1)}={\bm{y}}^{(t)}-\eta_{t}\nabla_{{\bm{y}}}E_{\theta}({\bm{x}},{\bm{y}}^{(t)}),(35)whereηt\eta_{t}is a step size. For structured discrete outputs, we instead need to use combinatorial search or another approximate minimization method. Overall, for general nonconvex energies, these minimization procedures may not find a global minimum, making initialization significantly affect the final prediction.

Standard feedforward prediction is a special case in which the minimum is available directly. Consider the quadratic energy

Eθ​(𝒙,𝒚)=12​σ2​‖𝒚−fθ​(𝒙)‖22,σ>0.E_{\theta}({\bm{x}},{\bm{y}})=\frac{1}{2\sigma^{2}}\|{\bm{y}}-f_{\theta}({\bm{x}})\|_{2}^{2},\qquad\sigma>0.(36)Its unique minimizer is𝒚^=fθ​(𝒙)\hat{{\bm{y}}}=f_{\theta}({\bm{x}}), which can be computed with one network evaluation. In contrast, a general energyEθ​(𝒙,𝒚)E_{\theta}({\bm{x}},{\bm{y}})does not need to have this quadratic form and can express multiple complex dependencies among output variables.

2.5Learning for EBMs

Learning an EBM means fitting the energyEθE_{\theta}so thatpθ​(𝒙)∝exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\exp\left(-E_{\theta}({\bm{x}})\right)matches the data distribution. The obstacle is again the partition function:ZθZ_{\theta}depends onθ\theta, so the likelihood and its gradient cannot be computed directly. Learning methods for EBMs differ mainly in how they avoid or approximateZθZ_{\theta}, as we will discuss in the following.

Maximum Likelihood Estimation.

Given a dataset𝒟={X}\mathcal{D}=\{X\}, the most direct approach to learning an energy functionEθ​(𝒙)E_{\theta}({\bm{x}})is through maximum likelihood estimation (MLE). We can directly fit a probability densitypθ​(𝒙)∝exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\exp(-E_{\theta}({\bm{x}}))to maximize thelog\log-likelihood of samples drawn from a dataset𝒟\mathcal{D},i.e., minimizing the negativelog\log-likelihood.

The full form of the likelihood ofEθ​(𝒙)E_{\theta}({\bm{x}})as defined in Equation1isexp⁡(−Eθ​(𝒙))/Z\exp(-E_{\theta}({\bm{x}}))/Z, whereZZis the partition function. The negativelog\log-likelihood loss objective is given by

ℒN​L​L​(𝒟)=𝔼𝒙∼𝒟​[−log⁡(pθ​(𝒙))],\mathcal{L}_{NLL}(\mathcal{D})=\mathbb{E}_{{\bm{x}}\sim\mathcal{D}}[-\log(p_{\theta}({\bm{x}}))],(37)which can be equivalently written as

ℒN​L​L​(𝒟)=𝔼𝒙∼𝒟​[Eθ​(𝒙)]+log⁡(∫exp⁡(−Eθ​(𝒙))​𝑑𝒙).\mathcal{L}_{NLL}(\mathcal{D})=\mathbb{E}_{{\bm{x}}\sim\mathcal{D}}[E_{\theta}({\bm{x}})]+\log\left(\int\exp(-E_{\theta}({\bm{x}}))d{\bm{x}}\right).(38)Taking the gradient of the above objective, we obtain the expression

∇θℒN​L​L​(𝒟)=𝔼𝒙∼𝒟​[∇θEθ​(𝒙)]−∫exp⁡(−Eθ​(𝒙))​∇θEθ​(𝒙)​𝑑𝒙∫exp⁡(−Eθ​(𝒙))​𝑑𝒙,\nabla_{\theta}\mathcal{L}_{NLL}(\mathcal{D})=\mathbb{E}_{{\bm{x}}\sim\mathcal{D}}[\nabla_{\theta}E_{\theta}({\bm{x}})]-\frac{\int\exp(-E_{\theta}({\bm{x}}))\nabla_{\theta}E_{\theta}({\bm{x}})d{\bm{x}}}{\int\exp(-E_{\theta}({\bm{x}}))d{\bm{x}}},(39)where we can reduce the right-hand side to the expectation

∇θℒN​L​L​(𝒟)=𝔼𝒙∼𝒟​[∇θEθ​(𝒙)]−𝔼𝒙∼pθ​(𝒙)​[∇θEθ​(𝒙)].\nabla_{\theta}\mathcal{L}_{NLL}(\mathcal{D})=\mathbb{E}_{{\bm{x}}\sim\mathcal{D}}[\nabla_{\theta}E_{\theta}({\bm{x}})]-\mathbb{E}_{{\bm{x}}\sim p_{\theta}({\bm{x}})}[\nabla_{\theta}E_{\theta}({\bm{x}})].(40)Using the above expression, the gradient ofℒN​L​L\mathcal{L}_{NLL}can be computed equivalently from the surrogate loss

ℒ~N​L​L​(𝒟)=𝔼𝒙∼𝒟​[Eθ​(𝒙)]−𝔼𝒙∼stopgrad​(pθ​(𝒙))​[Eθ​(𝒙)],\widetilde{\mathcal{L}}_{NLL}(\mathcal{D})=\mathbb{E}_{{\bm{x}}\sim\mathcal{D}}[E_{\theta}({\bm{x}})]-\mathbb{E}_{{\bm{x}}\sim\texttt{stopgrad}\left(p_{\theta}({\bm{x}})\right)}[E_{\theta}({\bm{x}})],(41)which gives us a simple objective for trainingEθ​(𝒙)E_{\theta}({\bm{x}})through maximum likelihood estimation, where we contrastively decrease the energy of ground truth data samples while increasing the energy of samples drawn from the model distribution𝒙∼pθ​(𝒙){\bm{x}}\sim p_{\theta}({\bm{x}}). However, in practice, drawing samples from the distributionpθ​(𝒙)p_{\theta}({\bm{x}})can be challenging – several approaches to drawing these samples were discussed in Section2.4.

Particularly, in the original contrastive divergence, these negative samples are initialized from ground truth data[87], while one can also initialize samples from random noise or an approximate distribution and use Langevin dynamics to draw negative samples to train the EBM[55,36].

Noise Contrastive Estimation.

Maximum likelihood needs samples from the modelpθp_{\theta}in every gradient step, which is what makes it expensive. Noise contrastive estimation (NCE)[81]avoids this by recasting the learning problem as classification between data and noise, from which the energy function can be recovered. Concretely, by formulating binary classification and multi-class classification problems, we obtain two variants of NCE.

Binary NCE.The original formulation[81]poses a binary classification between data and noise. It treats thelog\log-partition function as an extra scalar parametercc, so that the model’s normalizedlog\log-density is

log⁡pθ,c​(𝒙)=−Eθ​(𝒙)−c.\log p_{\theta,c}({\bm{x}})=-E_{\theta}({\bm{x}})-c.(42)Suppose each data point comes withν\nunoise samples, so that a sample is a prioriν\nutimes more likely to be noise. By Bayes’ rule, the probability that a sample𝒙{\bm{x}}is data rather than noise is

P⁡(y=1∣𝒙)=pθ,c​(𝒙)pθ,c​(𝒙)+ν​pn​(𝒙)=sigm⁡(hθ,c​(𝒙)),hθ,c​(𝒙)=−Eθ​(𝒙)−log⁡pn​(𝒙)⏟unnormalizedlog-ratio to noise+(−c−log⁡ν)⏟bias​b,P(y=1\mid{\bm{x}})=\frac{p_{\theta,c}({\bm{x}})}{p_{\theta,c}({\bm{x}})+\nu\,p_{n}({\bm{x}})}=\mathrm{sigm}\left(h_{\theta,c}({\bm{x}})\right),\qquad h_{\theta,c}({\bm{x}})=\underbrace{-E_{\theta}({\bm{x}})-\log p_{n}({\bm{x}})}_{\text{unnormalized \\log-ratio to noise}}+\underbrace{\left(-c-\log\nu\right)}_{\text{bias }b},(43)wheresigm\mathrm{sigm}is the logistic function. The posterior is thus a sigmoid of the model’slog\log-density ratio to the noise, plus a bias termb=−c−log⁡νb=-c-\log\nu, which implies we can recover the EBM parameters from the classifierP⁡(y=1∣𝒙)P(y=1\mid{\bm{x}}). We obtain the Binary NCE, which fits(θ,c)(\theta,c)by logistic regression,i.e., minimizing the cross-entropy,

ℒNCEbin​(θ,c)=−𝔼𝒙∼pd​[log⁡sigm⁡(hθ,c​(𝒙))]−ν​𝔼𝒙∼pn​[log⁡(1−sigm⁡(hθ,c​(𝒙)))],\mathcal{L}_{\text{NCE}}^{\text{bin}}(\theta,c)=-\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\log\mathrm{sigm}\left(h_{\theta,c}({\bm{x}})\right)\right]-\nu\,\mathbb{E}_{{\bm{x}}\sim p_{n}}\left[\log\left(1-\mathrm{sigm}\left(h_{\theta,c}({\bm{x}})\right)\right)\right],(44)with the gradient with respect toθ\thetaas

∇θℒNCEbin=𝔼𝒙∼pd​[(1−sigm⁡(hθ,c​(𝒙)))​∇θEθ​(𝒙)]−ν​𝔼𝒙∼pn​[sigm⁡(hθ,c​(𝒙))​∇θEθ​(𝒙)].\nabla_{\theta}\mathcal{L}_{\text{NCE}}^{\text{bin}}=\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\left(1-\mathrm{sigm}\left(h_{\theta,c}({\bm{x}})\right)\right)\nabla_{\theta}E_{\theta}({\bm{x}})\right]-\nu\,\mathbb{E}_{{\bm{x}}\sim p_{n}}\left[\mathrm{sigm}\left(h_{\theta,c}({\bm{x}})\right)\nabla_{\theta}E_{\theta}({\bm{x}})\right].(45)We emphasize that the negative samples in Equation45now come frompnp_{n}instead ofpθp_{\theta}, so no MCMC is needed. If the model family containspdp_{d}, the minimizer satisfiespθ,c=pdp_{\theta,c}=p_{d}, so the estimator is consistent[81], and the learned constant recovers thelog\log-partition function,c⋆=logZθ=log∫exp(−Eθ(𝒙))d𝒙c^{\star}=\log Z_{\theta}=\log\int\exp\left(-E_{\theta}({\bm{x}})\right)d{\bm{x}}. Binary NCE therefore learns both the energy and its normalizer, which allows the likelihood of new samples to be evaluated afterwards.

Ranking NCE.The second form poses a multi-class problem instead[124]: given one data point𝒙0∼pd{\bm{x}}_{0}\sim p_{d}hidden amongKKnoise samples𝒙1,…,𝒙K∼pn{\bm{x}}_{1},\ldots,{\bm{x}}_{K}\sim p_{n}, the model must identify which of theK+1K+1samples is the real one. To see what this probability is, leti∈{0,…,K}i\in\{0,\ldots,K\}be the unknown position of the data point, with a uniform prior. If the data were drawn from the modelpθp_{\theta}, theK+1K+1samples would have joint densitypθ​(𝒙i)​∏j≠ipn​(𝒙j)p_{\theta}({\bm{x}}_{i})\prod_{j\neq i}p_{n}({\bm{x}}_{j})givenii. By Bayes’ rule, the posterior over the position is

P(i∣𝒙0:K)=pθ​(𝒙i)​∏j≠ipn​(𝒙j)∑l=0Kpθ​(𝒙l)​∏j≠lpn​(𝒙j)=pθ​(𝒙i)/pn​(𝒙i)∑l=0Kpθ​(𝒙l)/pn​(𝒙l)=exp⁡(−Eθ​(𝒙i))/pn​(𝒙i)∑l=0Kexp⁡(−Eθ​(𝒙l))/pn​(𝒙l),P\left(i\mid{\bm{x}}_{0:K}\right)=\frac{p_{\theta}({\bm{x}}_{i})\prod_{j\neq i}p_{n}({\bm{x}}_{j})}{\sum_{l=0}^{K}p_{\theta}({\bm{x}}_{l})\prod_{j\neq l}p_{n}({\bm{x}}_{j})}=\frac{p_{\theta}({\bm{x}}_{i})/p_{n}({\bm{x}}_{i})}{\sum_{l=0}^{K}p_{\theta}({\bm{x}}_{l})/p_{n}({\bm{x}}_{l})}=\frac{\exp\left(-E_{\theta}({\bm{x}}_{i})\right)/p_{n}({\bm{x}}_{i})}{\sum_{l=0}^{K}\exp\left(-E_{\theta}({\bm{x}}_{l})\right)/p_{n}({\bm{x}}_{l})},(46)where the second equality divides the numerator and the denominator by∏j=0Kpn​(𝒙j)\prod_{j=0}^{K}p_{n}({\bm{x}}_{j}), and the third substitutespθ=exp⁡(−Eθ)/Zθp_{\theta}=\exp\left(-E_{\theta}\right)/Z_{\theta}, so thatZθZ_{\theta}cancels. This is a softmax over the samples with logits−Eθ​(𝒙k)−log⁡pn​(𝒙k)-E_{\theta}({\bm{x}}_{k})-\log p_{n}({\bm{x}}_{k}). Ranking NCE maximizes the probability of identifying the data point,i=0i=0,i.e., it minimizes the negativelog\log-probability,

ℒNCErank​(θ)=−𝔼⁡[log⁡exp⁡(−Eθ​(𝒙0))/pn​(𝒙0)∑k=0Kexp⁡(−Eθ​(𝒙k))/pn​(𝒙k)].\mathcal{L}_{\text{NCE}}^{\text{rank}}(\theta)=-\mathbb{E}\left[\log\frac{\exp\left(-E_{\theta}({\bm{x}}_{0})\right)/p_{n}({\bm{x}}_{0})}{\sum_{k=0}^{K}\exp\left(-E_{\theta}({\bm{x}}_{k})\right)/p_{n}({\bm{x}}_{k})}\right].(47)Since any constant in the energy appears in both the numerator and the denominator, the partition function cancels: ranking NCE learnsEθE_{\theta}alone, with no parametercc. Its gradient,

∇θℒNCErank=𝔼⁡[∇θEθ​(𝒙0)−∑k=0Kwk​∇θEθ​(𝒙k)],wk=exp⁡(−Eθ​(𝒙k))/pn​(𝒙k)∑j=0Kexp⁡(−Eθ​(𝒙j))/pn​(𝒙j),\nabla_{\theta}\mathcal{L}_{\text{NCE}}^{\text{rank}}=\mathbb{E}\left[\nabla_{\theta}E_{\theta}({\bm{x}}_{0})-\sum_{k=0}^{K}w_{k}\,\nabla_{\theta}E_{\theta}({\bm{x}}_{k})\right],\qquad w_{k}=\frac{\exp\left(-E_{\theta}({\bm{x}}_{k})\right)/p_{n}({\bm{x}}_{k})}{\sum_{j=0}^{K}\exp\left(-E_{\theta}({\bm{x}}_{j})\right)/p_{n}({\bm{x}}_{j})},(48)is again the maximum likelihood gradient, with the expectation underpθp_{\theta}replaced by a self-normalized importance sampling estimate that usespnp_{n}as the proposal. Ranking NCE is consistent as well, and it is especially convenient for conditional modelspθ​(𝒚∣𝒙)p_{\theta}({\bm{y}}\mid{\bm{x}}), where the partition functionZθ​(𝒙)Z_{\theta}({\bm{x}})differs for every input and binary NCE would need a separate constant for each𝒙{\bm{x}}[124]. The price is that it does not recoverZθZ_{\theta}, which has to be estimated separately,e.g., by importance sampling, if normalized likelihoods are needed.

Choosing the noise.Both forms depend heavily on the noise distribution.pnp_{n}must be positive whereverpdp_{d}is, and it should be close topdp_{d}: if the noise is easy to tell apart from the data, the classifier succeeds without learning much about the data, and the gradients carry little information. Largerν\nuorKKmakes both estimators closer to maximum likelihood, at the cost of more noise samples per data point.

Pseudolikelihood Estimation.

Given an unnormalized EBMEθ​(𝒙)E_{\theta}({\bm{x}})over variables𝒙={x1,x2,…,xd}{\bm{x}}=\left\{x_{1},x_{2},\ldots,x_{d}\right\}, in pseudolikelihood estimation[21], we define the pseudolikelihood as

P​L​(θ,𝐱)=∏j=1dpθ​(xj∣𝐱−j).PL(\theta;\mathbf{x})=\prod_{j=1}^{d}p_{\theta}(x_{j}\mid\mathbf{x}_{-j}).(49)The objective we train our estimator with is then the negativelog\log-pseudolikelihood

ℒP​L(θ)=−∑i=1N∑j=1dlogpθ(xj(i)∣𝐱−j(i)).\mathcal{L}_{PL}(\theta)=-\sum_{i=1}^{N}\sum_{j=1}^{d}\log p_{\theta}(x_{j}^{(i)}\mid\mathbf{x}_{-j}^{(i)}).(50)The objective in Equation50is substantially easier to optimize than Equation37since we can computepθ​(xj(i)∣𝐱−j(i))p_{\theta}(x_{j}^{(i)}\mid\mathbf{x}_{-j}^{(i)})in closed form as

p⁡(xj=k∣𝐱−j)=p⁡(xj=k,𝐱−j)∑v∈𝒱p⁡(xj=v,𝐱−j)=exp⁡(−E⁡(xj=k,𝐱−j))∑v∈𝒱exp⁡(−E⁡(xj=v,𝐱−j)),p(x_{j}=k\mid\mathbf{x}_{-j})=\frac{p(x_{j}=k,\mathbf{x}_{-j})}{\sum_{v\in\mathcal{V}}p(x_{j}=v,\mathbf{x}_{-j})}=\frac{\exp(-E(x_{j}=k,\mathbf{x}_{-j}))}{\sum_{v\in\mathcal{V}}\exp(-E(x_{j}=v,\mathbf{x}_{-j}))},which can be computed by enumerating through the vocabulary size𝒱\mathcal{V}ofxjx_{j}.

In general, pseudolikelihood is a consistent estimator of the overall distributionp⁡(𝒙)p({\bm{x}}), as long as the distribution is positive at every data point𝒙{\bm{x}}[21,95]. However, in comparison to other approaches for training EBMs, pseudolikelihood focuses on local interactions between variables. This can make the method data inefficient when fitting distributions where there are global interactions between multiple variables.

Connection to masked discrete diffusion.Pseudolikelihood is closely related to masked, or absorbing-state, discrete diffusion models[9,150,157]. Both are trained to predict hidden variables from visible ones. Pseudolikelihood hides exactly one variablexjx_{j}and fitspθ​(xj∣𝒙−j)p_{\theta}(x_{j}\mid{\bm{x}}_{-j}). Masked diffusion hides a random subsetMMof the variables, whose size ranges from one variable to all of them, and fitspθ​(xj∣𝒙−M)p_{\theta}(x_{j}\mid{\bm{x}}_{-M})for everyj∈Mj\in M. With the linear noise schedule, its training objective is a weighted average of such masked-prediction losses over masking ratios,

ℒMD(θ)=𝔼t∼𝒰⁡[0,1][1t𝔼M∼qt[−∑j∈Mlogpθ(xj∣𝒙−M)]],\mathcal{L}_{\text{MD}}(\theta)=\mathbb{E}_{t\sim\mathcal{U}[0,1]}\left[\frac{1}{t}\,\mathbb{E}_{M\sim q_{t}}\left[-\sum_{j\in M}\log p_{\theta}\left(x_{j}\mid{\bm{x}}_{-M}\right)\right]\right],(51)whereqtq_{t}hides each variable independently with probabilitytt. Pseudolikelihood Equation50is the special case in which exactly one variable is hidden at a time. The link is even closer in continuous time: the score of a discrete diffusion model can be written through the single-variable conditionalspt​(xj∣𝒙−j)p_{t}(x_{j}\mid{\bm{x}}_{-j}), exactly the quantities pseudolikelihood fits, and it can be learned by a categorical ratio matching objective built on them[165].

The difference matters for what each objective learns. By the chain rule, for any orderingπ\piof the variables,log⁡p⁡(𝒙)=∑k=1dlog⁡p⁡(xπ⁡(k)∣𝒙π(<k))\log p({\bm{x}})=\sum_{k=1}^{d}\log p\left(x_{\pi(k)}\mid{\bm{x}}_{\pi(<k)}\right). The masked diffusion objective Equation51is equivalent to averaging this decomposition over random orderings[178,92,136], so it is an upper bound on the negativelog\log-likelihood. Pseudolikelihood keeps only the last term of each ordering,k=dk=d, where every other variable is visible. It is therefore not a bound on the likelihood, and it never trains the model to predict a variable whose neighbors are also unknown, which is why it struggles with the global interactions mentioned above. In this sense, masked diffusion extends pseudolikelihood from one masking level to all of them.

The two also differ in another respect. In an EBM, every conditional is derived from a single energy function, so the conditionals are always consistent with one joint distribution. Masked diffusion models usually parameterize the conditionals directly with a neural network, and the learned conditionals need not agree with any joint distribution. The two also sample differently: Gibbs sampling resamples one variable at a time from the pseudolikelihood conditionals and keeps cycling, whereas masked diffusion starts with every variable hidden and reveals them progressively until none are left.

Score Matching.

Score matching[94]avoids the partition function by fitting the gradient of thelog\log-density instead of the density itself. For continuous𝒙{\bm{x}}, this gradient is thescore,

∇𝒙​log​pθ​(𝒙)=−∇𝒙Eθ​(𝒙)−∇𝒙​log​Zθ=−∇𝒙Eθ​(𝒙),\nabla_{\bm{x}}\log p_{\theta}({\bm{x}})=-\nabla_{\bm{x}}E_{\theta}({\bm{x}})-\nabla_{\bm{x}}\log Z_{\theta}=-\nabla_{\bm{x}}E_{\theta}({\bm{x}}),(52)andZθZ_{\theta}drops out because it does not depend on𝒙{\bm{x}}. Score matching fits the model score to the data score by minimizing their expected squared distance, the Fisher divergence,

ℒESM​(θ)=12​𝔼𝒙∼pd​[‖∇𝒙​log​pθ​(𝒙)−∇𝒙​log​pd​(𝒙)‖22].\mathcal{L}_{\text{ESM}}(\theta)=\frac{1}{2}\,\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\big\|\nabla_{\bm{x}}\log p_{\theta}({\bm{x}})-\nabla_{\bm{x}}\log p_{d}({\bm{x}})\big\|_{2}^{2}\right].(53)The data score∇𝒙​log​pd\nabla_{\bm{x}}\log p_{d}is unknown, butHyvärinen [94]showed by integration by parts that, under mild smoothness and boundary conditions, Equation53equals, up to a constant that does not depend onθ\theta,

ℒSM​(θ)=𝔼𝒙∼pd​[12​‖∇𝒙Eθ​(𝒙)‖22−tr(∇𝒙2Eθ​(𝒙))],\mathcal{L}_{\text{SM}}(\theta)=\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\frac{1}{2}\big\|\nabla_{\bm{x}}E_{\theta}({\bm{x}})\big\|_{2}^{2}-\mathop{\mathrm{tr}}\left(\nabla_{\bm{x}}^{2}E_{\theta}({\bm{x}})\right)\right],(54)which only involves the energy and the data. Like NCE, score matching needs no samples from the model; unlike NCE, it needs no noise distribution either. It is consistent when the model family containspdp_{d}[94].

Scalable variants.The trace of the Hessian in Equation54needsddbackward passes, which is expensive in high dimensions. Sliced score matching[162]projects the scores onto random directions𝒗{\bm{v}}and replaces the trace with𝒗⊤​∇𝒙2Eθ​(𝒙)​𝒗{\bm{v}}^{\top}\nabla_{\bm{x}}^{2}E_{\theta}({\bm{x}})\,{\bm{v}}, which needs a single Hessian-vector product. Denoising score matching[183]removes the second derivative altogether. It adds Gaussian noise to the data,𝒙~=𝒙+σ​ϵ\tilde{\bm{x}}={\bm{x}}+\sigma\bm{\epsilon}withϵ∼𝒩⁡(0,I)\bm{\epsilon}\sim\mathcal{N}\left(0,I\right), and matches the model score at𝒙~\tilde{\bm{x}}to the score of the noising kernel, which is known in closed form,

ℒDSM​(θ)=12​𝔼𝒙∼pd,ϵ​[‖−∇𝒙~Eθ​(𝒙~)+𝒙~−𝒙σ2‖22].\mathcal{L}_{\text{DSM}}(\theta)=\frac{1}{2}\,\mathbb{E}_{{\bm{x}}\sim p_{d},\,\bm{\epsilon}}\left[\Big\|-\nabla_{\tilde{\bm{x}}}E_{\theta}(\tilde{\bm{x}})+\frac{\tilde{\bm{x}}-{\bm{x}}}{\sigma^{2}}\Big\|_{2}^{2}\right].(55)Its minimizer is the score of the noisy data distribution rather than ofpdp_{d}itself, which approaches the data score asσ→0\sigma\to 0. Training on a range of noise levels, from large to small, gives the noise-conditional score models behind score-based diffusion models[161,163], which can be read as EBMs whose energy is learned at every noise level and sampled with annealed Langevin dynamics Equation25.

Limitations.Because the score is a local quantity, score matching sees each region of the space only through how the density changes there. Where the data are scarce, as in the low-density regions between separated modes, the learned score is inaccurate, and Langevin sampling from it mixes poorly between modes[161]; the noise in denoising score matching helps by filling in these regions. Score matching also requires continuous𝒙{\bm{x}}and a differentiable energy. For discrete data, ratio matching[96]plays the same role by matching ratiospθ​(𝒙′)/pθ​(𝒙)p_{\theta}({\bm{x}}^{\prime})/p_{\theta}({\bm{x}})between states that differ in a single variable, in whichZθZ_{\theta}again cancels. These ratios are determined by the single-variable conditionalspθ​(xj∣𝒙−j)p_{\theta}(x_{j}\mid{\bm{x}}_{-j}), which ties score matching for discrete data back to pseudolikelihood and to the categorical ratio matching used in discrete diffusion[165].

Adversarial Training.

Adversarial training starts from maximum likelihood and removes the partition function with the variational bound from Section2.4. The negativelog\log-likelihood Equation38containslog⁡Zθ\log Z_{\theta}, and by Equation30,log⁡Zθ\log Z_{\theta}is itself the solution of an optimization problem over distributions,

log⁡Zθ=maxq⁡𝔼𝒙∼q​[−Eθ​(𝒙)]+H⁡(q),\log Z_{\theta}=\max_{q}\;\mathbb{E}_{{\bm{x}}\sim q}\left[-E_{\theta}({\bm{x}})\right]+H\left(q\right),(56)where the maximum is attained atq=pθq=p_{\theta}. Substituting Equation56into Equation38turns maximum likelihood into a min-max problem,

minθ⁡ℒN​L​L​(θ)=minθ⁡maxq​𝔼𝒙∼pd​[Eθ​(𝒙)]−𝔼𝒙∼q​[Eθ​(𝒙)]+H⁡(q).\min_{\theta}\;\mathcal{L}_{NLL}(\theta)=\min_{\theta}\,\max_{q}\;\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[E_{\theta}({\bm{x}})\right]-\mathbb{E}_{{\bm{x}}\sim q}\left[E_{\theta}({\bm{x}})\right]+H\left(q\right).(57)The two players have clear roles. For a fixed energy, the inner maximization overqqis exactly the variational inference problem Equation29: it fitsqqtopθp_{\theta}by minimizingKL(q∥pθ)\mathrm{KL}\left(q\|p_{\theta}\right), soqqbecomes an amortized sampler for the current EBM. For a fixedqq, the gradient of the outer objective with respect toθ\thetais

𝔼𝒙∼pd​[∇θEθ​(𝒙)]−𝔼𝒙∼q​[∇θEθ​(𝒙)],\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right]-\mathbb{E}_{{\bm{x}}\sim q}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right],(58)which is the maximum likelihood gradient Equation40with the samples frompθp_{\theta}replaced by samples fromqq. The energy thus lowers itself on data and raises itself on the sampler’s outputs, while the sampler moves its samples toward low energy and keeps them spread out through the entropy term. No MCMC is run during training; the sampler is learned instead.

This is the structure of a generative adversarial network[77]: the energy plays the discriminator andqqplays the generator. The difference is the entropy termH⁡(q)H\left(q\right). Without it, the inner maximization would put all ofqq’s mass at the minimum of the energy, which is the mode collapse familiar from GANs, and the game would no longer correspond to maximum likelihood. With it, the solution of Equation57is the maximum likelihood estimate, and the learned generator is a sampler for the learned EBM[101,39].

The entropy is also what makes the method hard in practice. It is easy to compute only for restricted families ofqq, such as normalizing flows[146]. For flexible implicit generators𝒙=gϕ​(𝒛){\bm{x}}=g_{\phi}({\bm{z}}), it has to be estimated or bounded, and different estimates lead to different algorithms[101,39]. One alternative definesqqby a few steps of learnable sampling dynamics, such as Langevin or Hamiltonian updates started from a simple distribution, whose entropy can be tracked through the dynamics[36]; the dual view of Equation57also extends to kernel exponential families[34]. A second difficulty is that for a fixedqqthe objective in Equation57is only a lower bound on the negativelog\log-likelihood, sinceqqonly lower-boundslog⁡Zθ\log Z_{\theta}. Ifqqfalls behind the current energy, minimizing overθ\thetalowers the bound rather than the likelihood. In practice,θ\thetaandqqare updated in alternation, and the quality of the learned EBM depends on how closelyqqtrackspθp_{\theta}.

Regression Training.

Energy functions can also be learned through regression objectives that supervise the outputs or updates of energy minimization. The supervision need not specify scalar energy values: it can instead describe where optimization should arrive or how a candidate should move[38]. IREM and Equilibrium Matching illustrate these two approaches.

*Regressing optimized predictions.*Iterative Reasoning through Energy Minimization (IREM)[52]learns a conditional energyEθ​(𝒙,𝒚)E_{\theta}({\bm{x}},{\bm{y}})by supervising the prediction obtained after minimizing it. Given a paired input and solution(𝒙,𝒚)({\bm{x}},{\bm{y}}), initialize𝒚^(0)\hat{{\bm{y}}}^{(0)}and performKKupdates,

𝒚^(k+1)=𝒚^(k)−η​∇𝒚Eθ​(𝒙,𝒚^(k)).\hat{{\bm{y}}}^{(k+1)}=\hat{{\bm{y}}}^{(k)}-\eta\nabla_{{\bm{y}}}E_{\theta}({\bm{x}},\hat{{\bm{y}}}^{(k)}).(59)The regression objective is

ℒIREM​(θ)=𝔼(𝒙,𝒚)∼𝒟,𝒚^(0)​[‖𝒚^(K)−𝒚‖22].\mathcal{L}_{\mathrm{IREM}}(\theta)=\mathbb{E}_{({\bm{x}},{\bm{y}})\sim\mathcal{D},\,\hat{{\bm{y}}}^{(0)}}\left[\|\hat{{\bm{y}}}^{(K)}-{\bm{y}}\|_{2}^{2}\right].(60)Training differentiates through optimization to shape the energy landscape. In practice, IREM truncates backpropagation to the final update and uses a replay buffer of optimized candidates alongside random initializations. The regression target is the solution reached by optimization, rather than the energy assigned to that solution. At inference time, the learned energy can be optimized for a different number of steps, although finite-step training alone does not guarantee that longer optimization improves predictions.

*Regressing an update field.*Equilibrium Matching (EqM)[186]instead supervises a time-independent field at corrupted data points. Given data𝒙{\bm{x}}, Gaussian noiseϵ\bm{\epsilon}, andγ∼𝒰⁡[0,1]\gamma\sim\mathcal{U}[0,1], let

𝒙γ=(1−γ)​𝒙+γ​ϵ.{\bm{x}}_{\gamma}=(1-\gamma){\bm{x}}+\gamma\bm{\epsilon}.(61)EqM regressesfθf_{\theta}toward(ϵ−𝒙)​c​(γ)(\bm{\epsilon}-{\bm{x}})c(\gamma), withc⁡(0)=0c(0)=0. Its explicit-energy variant, EqM-E, setsfθ=∇Eθf_{\theta}=\nabla E_{\theta}and minimizes

ℒEqM​-​E​(θ)=𝔼𝒙,ϵ,γ​[‖∇𝒙γEθ​(𝒙γ)−(ϵ−𝒙)​c​(γ)‖22].\mathcal{L}_{\mathrm{EqM\text{-}E}}(\theta)=\mathbb{E}_{{\bm{x}},\bm{\epsilon},\gamma}\left[\left\|\nabla_{{\bm{x}}_{\gamma}}E_{\theta}({\bm{x}}_{\gamma})-(\bm{\epsilon}-{\bm{x}})c(\gamma)\right\|_{2}^{2}\right].(62)The model does not receiveγ\gamma. The target magnitude vanishes at the data endpoint, encouraging equilibrium behavior. Generation starts from noise and follows the learned descent field. Training requires no unrolled generation trajectory. EqM-E enforces a scalar potential by construction; an unconstrained vector predictor need not be exactly conservative.

Thus, IREM supervises theresultof energy minimization, whereas EqM supervises itslocal update field. Both avoid partition-function estimation, but neither objective is itself maximum likelihood forexp⁡(−Eθ)/Zθ\exp(-E_{\theta})/Z_{\theta}. In particular, optimization from random initializations in these models is not the same as equilibrium sampling from that Boltzmann density of the learned energy function.

2.6Unified View through Contrastive Learning

The learning methods above look different, but their gradients share one structure[36]. The regression methods at the end of Section2.5are the exception: they fit the update of a sampler rather than the likelihood of the energy, and fall outside this view. Each lowers the energy of the data and raises the energy of a set ofnegative samples,

∇θℒ​(θ)=𝔼𝒙∼pd​[∇θEθ​(𝒙)]−𝔼𝒙∼q​[∇θEθ​(𝒙)],\nabla_{\theta}\mathcal{L}(\theta)=\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right]-\mathbb{E}_{{\bm{x}}\sim q}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right],(63)or, in the form of Equation41,ℒ⁡(θ)=𝔼pd​[Eθ]−𝔼stopgrad​(q)​[Eθ]\mathcal{L}(\theta)=\mathbb{E}_{p_{d}}\left[E_{\theta}\right]-\mathbb{E}_{\texttt{stopgrad}\left(q\right)}\left[E_{\theta}\right]. Maximum likelihood is the caseq=pθq=p_{\theta}Equation40. The other methods replacepθp_{\theta}with anegative samplerqqthat is cheaper to draw from, and they differ mainly in this choice. Table1lists the samplers, which we explain below, and Figure3shows them on a two-dimensional example. The view also tells where each method loses accuracy: whereverqqdiffers frompθp_{\theta}, the gradient differs from the maximum likelihood gradient.

Refer to captionFigure 3:Illustration of Negative Samples.The negative samples of the learning methods in Table1, for the same data and current model. Maximum likelihood draws from the model itself, including a spurious low-energy region far from the data. Contrastive divergence and score matching start at the data and move a short distance (lines connect each data point to its negative sample), so they never visit that region, and pseudolikelihood resamples one coordinate at a time, so it moves only along the axes. Noise-contrastive estimation weights noise samples by the classifier (marker size), and adversarial training draws from a learned sampler, which can lag behind the model.Table 1:Learning methods for EBMs as choices of the negative samplerqqin Equation63, followingDai et al. [36].pdp_{d}is the data distribution,TθkT_{\theta}^{k}denoteskksteps of an MCMC kernel that leavespθp_{\theta}invariant,𝒙−j{\bm{x}}_{-j}is𝒙{\bm{x}}without itsjj-th variable, andsigm⁡(hθ,c)\mathrm{sigm}(h_{\theta,c})is the NCE classifier in Equation43.#### Short MCMC Chains.

Contrastive divergence (CD)[87]starts the chains at the data and runs onlykksteps, often a single one, soq=Tθk​pdq=T_{\theta}^{k}p_{d}. Persistent CD[170]continues the chains from the previous iteration instead of restarting them, and short-run Langevin from noise or from a replay buffer[55]is a further variant. These samplers are cheap because they never run to convergence. The price is thatqqstays near where the chains started, so energy minima far from the data are rarely visited and rarely corrected. When short chains are restarted from noise, the learned energy need not be an accurate density, but the energy together with its short-run sampler is still a valid generator[133].

Pseudolikelihood as One Gibbs Step.

The gradient of one term of Equation50is

−∇θlogpθ(xj∣𝒙−j)=∇θEθ(𝒙)−𝔼xj′∼pθ(⋅∣𝒙−j)[∇θEθ(xj′,𝒙−j)].-\nabla_{\theta}\log p_{\theta}\left(x_{j}\mid{\bm{x}}_{-j}\right)=\nabla_{\theta}E_{\theta}({\bm{x}})-\mathbb{E}_{x_{j}^{\prime}\sim p_{\theta}(\cdot\mid{\bm{x}}_{-j})}\left[\nabla_{\theta}E_{\theta}\left(x_{j}^{\prime},{\bm{x}}_{-j}\right)\right].(64)Averaging overjjgives Equation63with the following sampler: take a data point, pick a variablejjuniformly at random, and resample it from its conditional. This is a single step of random-scan Gibbs sampling started at the data[96]. Composite likelihood[114]resamples a block of variables instead of one, and non-local contrastive objectives[181]resample within a region chosen around the data point. Each enlarges the neighborhood the sampler can reach, which is why they capture more global structure than pseudolikelihood.

Score Matching as One Langevin Step.

Letqqtake one Langevin step Equation25with step sizeη/2\eta/2from each data point,𝒙′=𝒙−η2​∇𝒙Eθ​(𝒙)+η​𝝃{\bm{x}}^{\prime}={\bm{x}}-\frac{\eta}{2}\nabla_{\bm{x}}E_{\theta}({\bm{x}})+\sqrt{\eta}\,\bm{\xi}with𝝃∼𝒩⁡(0,I)\bm{\xi}\sim\mathcal{N}\left(0,I\right), and treat𝒙′{\bm{x}}^{\prime}as fixed, as in Equation41. A second-order Taylor expansion of∇θEθ​(𝒙′)\nabla_{\theta}E_{\theta}({\bm{x}}^{\prime})around𝒙{\bm{x}}gives[96,36]

𝔼𝒙∼pd​[∇θEθ​(𝒙)]−𝔼𝒙′​[∇θEθ​(𝒙′)]=η2​∇θℒSM​(θ)+o⁡(η),\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right]-\mathbb{E}_{{\bm{x}}^{\prime}}\left[\nabla_{\theta}E_{\theta}({\bm{x}}^{\prime})\right]=\frac{\eta}{2}\,\nabla_{\theta}\mathcal{L}_{\text{SM}}(\theta)+o(\eta),(65)so score matching Equation54is the small-step limit of one-step Langevin CD. Its locality, noted in its limitations above, is the locality of this sampler. Minimum probability flow[159]and minimum Stein discrepancy estimators[14]also correspond to fixed one-step samplers from the data, a symmetric transition kernel and one step of Stein variational gradient descent, respectively[36].

NCE as Importance Sampling.

Splitting the data weight1−sigm1-\mathrm{sigm}in Equation45into11and−sigm-\mathrm{sigm}and collecting thesigm\mathrm{sigm}terms gives

∇θℒNCEbin=𝔼𝒙∼pd​[∇θEθ​(𝒙)]−∫(pd​(𝒙)+ν​pn​(𝒙))​sigm​(hθ,c​(𝒙))​∇θEθ​(𝒙)​𝑑𝒙.\nabla_{\theta}\mathcal{L}_{\text{NCE}}^{\text{bin}}=\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right]-\int\left(p_{d}({\bm{x}})+\nu\,p_{n}({\bm{x}})\right)\,\mathrm{sigm}\left(h_{\theta,c}({\bm{x}})\right)\,\nabla_{\theta}E_{\theta}({\bm{x}})\,d{\bm{x}}.(66)The negatives are thus data and noise samples weighted by the classifier. Sincesigm⁡(hθ,c)=pθ,c/(pθ,c+ν​pn)\mathrm{sigm}(h_{\theta,c})=p_{\theta,c}/(p_{\theta,c}+\nu p_{n}), the weighted measure(pd+ν​pn)​sigm​(hθ,c)\left(p_{d}+\nu p_{n}\right)\mathrm{sigm}(h_{\theta,c})equalspθ,cp_{\theta,c}exactly whenpθ,c=pdp_{\theta,c}=p_{d}, so the negatives become model samples as the model approaches the data. Ranking NCE Equation48is explicitly self-normalized importance sampling with proposalpnp_{n}. In both cases, the quality of the sampler depends on how wellpnp_{n}coverspθp_{\theta}, which is the noise-choice problem discussed above.

Learned Samplers.

Adversarial training Equation58is the only case whereqqis trained to approachpθp_{\theta}, by the inner maximization of Equation57. From this view, the methods above fixqqby hand, which makes them cheap but leaves a gap that does not shrink with more training, while a learned sampler can close the gap at the cost of a min-max problem[36].

The same template also explains contrastive representation learning. InfoNCE[179]is ranking NCE Equation47for a conditional energyEθ​(𝒙,𝒚)E_{\theta}({\bm{x}},{\bm{y}}), where the negatives for𝒙{\bm{x}}are the𝒚{\bm{y}}’s of other samples in the batch,i.e.,pnp_{n}is the marginal of the data. We return to this in Section5.

3Discriminative Models

We first instantiate the EBM framework for discriminative tasks, where the goal is to predict an output𝒚{\bm{y}}from an input𝒙{\bm{x}}. The energy is now defined over input–output pairs,Eθ​(𝒙,𝒚)E_{\theta}({\bm{x}},{\bm{y}}), and it induces a conditional distribution

pθ​(𝒚∣𝒙)=exp⁡(−Eθ​(𝒙,𝒚))Zθ​(𝒙),Zθ​(𝒙)=∑𝒚exp⁡(−Eθ​(𝒙,𝒚)).p_{\theta}({\bm{y}}\mid{\bm{x}})=\frac{\exp\left(-E_{\theta}({\bm{x}},{\bm{y}})\right)}{Z_{\theta}({\bm{x}})},\qquad Z_{\theta}({\bm{x}})=\sum_{{\bm{y}}}\exp\left(-E_{\theta}({\bm{x}},{\bm{y}})\right).(67)which is the conditional EBM Equation3with the integral replaced by a sum over outputs. Different choices of the output space and of the energy recover familiar models, including logistic regression, conditional random fields (CRFs), and structured prediction energy networks.

3.1Logistic Regression and CRFs

When𝒚{\bm{y}}is one of a few classes, Equation67is logistic regression; when𝒚{\bm{y}}is a structured output, such as a label sequence, and the energy decomposes over neighboring labels, it is a CRF[106]. The two differ in how the partition functionZθ​(𝒙)Z_{\theta}({\bm{x}})is computed. For logistic regression, it is a sum overKKclasses and is obtained by direct enumeration. For a linear-chain CRF, it hasKTK^{T}terms and cannot be enumerated, but the chain structure lets dynamic programming compute it exactly. In both cases, maximum likelihood can be carried out exactly, without the sampling-based approximations of Section2.5.

Logistic Regression.

Lety∈{1,…,K}y\in\left\{1,\ldots,K\right\}and let the energy be linear in a feature map𝐟⁡(𝒙)\mathbf{f}({\bm{x}}),

Eθ​(𝒙,y)=−𝒘y⊤​𝐟​(𝒙)−by,pθ​(y∣𝒙)=exp⁡(𝒘y⊤​𝐟​(𝒙)+by)∑k=1Kexp⁡(𝒘k⊤​𝐟​(𝒙)+bk),E_{\theta}({\bm{x}},y)=-{\bm{w}}_{y}^{\top}\mathbf{f}({\bm{x}})-b_{y},\qquad p_{\theta}(y\mid{\bm{x}})=\frac{\exp\left({\bm{w}}_{y}^{\top}\mathbf{f}({\bm{x}})+b_{y}\right)}{\sum_{k=1}^{K}\exp\left({\bm{w}}_{k}^{\top}\mathbf{f}({\bm{x}})+b_{k}\right)},(68)withθ={𝒘k,bk}k=1K\theta=\left\{{\bm{w}}_{k},b_{k}\right\}_{k=1}^{K}. The conditional distribution is the softmax of the negative energies, andK=2K=2gives the sigmoid. The partition function is a sum ofKKterms, so the negativelog\log-likelihood can be computed exactly,

ℒ(θ)=𝔼(𝒙,y)∼𝒟[Eθ(𝒙,y)+log∑k=1Kexp(−Eθ(𝒙,k))].\mathcal{L}(\theta)=\mathbb{E}_{({\bm{x}},y)\sim\mathcal{D}}\left[E_{\theta}({\bm{x}},y)+\log\sum_{k=1}^{K}\exp\left(-E_{\theta}({\bm{x}},k)\right)\right].(69)Its gradient has the form of Equation40, with the expectation under the model computed exactly by summing over theKKclasses,

∇θℒ\displaystyle\nabla_{\theta}\mathcal{L}=𝔼(𝒙,y)∼𝒟​[∇θEθ​(𝒙,y)−∑k=1Kpθ​(k∣𝒙)​∇θEθ​(𝒙,k)],\displaystyle=\mathbb{E}_{({\bm{x}},y)\sim\mathcal{D}}\left[\nabla_{\theta}E_{\theta}({\bm{x}},y)-\sum_{k=1}^{K}p_{\theta}(k\mid{\bm{x}})\,\nabla_{\theta}E_{\theta}({\bm{x}},k)\right],(70)∇𝒘kℒ\displaystyle\nabla_{{\bm{w}}_{k}}\mathcal{L}=𝔼(𝒙,y)∼𝒟[(pθ(k∣𝒙)−𝟏[y=k])𝐟(𝒙)].\displaystyle=\mathbb{E}_{({\bm{x}},y)\sim\mathcal{D}}\left[\left(p_{\theta}(k\mid{\bm{x}})-\bm{1}[y=k]\right)\mathbf{f}({\bm{x}})\right].The gradient for classkkis the gap between the predicted probability and the label, times the features. For fixed features,ℒ\mathcal{L}is convex, and Algorithm1gives the stochastic gradient version of MLE; for small problems, Newton’s method, known as iteratively reweighted least squares, converges faster. When𝐟\mathbf{f}is a neural network trained jointly, the same algorithm is the standard softmax cross-entropy training of classifiers.

Algorithm 1Maximum likelihood for logistic regression by stochastic gradient descent1:data

𝒟\mathcal{D}, features

𝐟\mathbf{f}, step size

η\eta, batch size

BB 2:Initialize

𝒘k←𝟎{\bm{w}}_{k}\leftarrow\mathbf{0},

bk←0b_{k}\leftarrow 0for

k=1,…,Kk=1,\ldots,K 3:repeat

4:Sample a minibatch

{(𝒙i,yi)}i=1B\left\{({\bm{x}}_{i},y_{i})\right\}_{i=1}^{B}from

𝒟\mathcal{D} 5:Compute

pi​k←pθ​(k∣𝒙i)p_{ik}\leftarrow p_{\theta}(k\mid{\bm{x}}_{i})by Equation68for all

i,ki,k⊳\trianglerightexact negative phase

6:

𝒘k←𝒘k−ηB∑i=1B(pi​k−𝟏[yi=k])𝐟(𝒙i){\bm{w}}_{k}\leftarrow{\bm{w}}_{k}-\frac{\eta}{B}\sum_{i=1}^{B}\left(p_{ik}-\bm{1}[y_{i}=k]\right)\mathbf{f}({\bm{x}}_{i})for all

kk 7:

bk←bk−ηB∑i=1B(pi​k−𝟏[yi=k])b_{k}\leftarrow b_{k}-\frac{\eta}{B}\sum_{i=1}^{B}\left(p_{ik}-\bm{1}[y_{i}=k]\right)for all

kk 8:untilconverged

Linear-Chain CRF.

For a label sequence𝒚=(y1,…,yT){\bm{y}}=(y_{1},\ldots,y_{T})withyt∈{1,…,K}y_{t}\in\left\{1,\ldots,K\right\}, a linear-chain CRF[106],i.e., the CRF Equation10with cliques over neighboring labels, lets the energy decompose into a unary term for each position and a pairwise term for each pair of neighboring labels,

Eθ(𝒙,𝒚)=−∑t=1Tsθ(𝒙,t,yt)−∑t=2TAyt−1,yt,E_{\theta}({\bm{x}},{\bm{y}})=-\sum_{t=1}^{T}s_{\theta}({\bm{x}},t,y_{t})-\sum_{t=2}^{T}A_{y_{t-1},y_{t}},(71)wheresθ​(𝒙,t,k)s_{\theta}({\bm{x}},t,k)scores labelkkat positiontt, through a linear model or a neural network, andA∈ℝK×KA\in\mathbb{R}^{K\times K}scores label transitions. The sum inZθ​(𝒙)Z_{\theta}({\bm{x}})now hasKTK^{T}terms, but the chain structure lets the forward algorithm compute it by dynamic programming inO⁡(T​K2)O(TK^{2})time,

α1​(k)=esθ​(𝒙,1,k),αt​(k)=esθ​(𝒙,t,k)​∑j=1Kαt−1​(j)​eAj​k,Zθ​(𝒙)=∑k=1KαT​(k),\alpha_{1}(k)=e^{s_{\theta}({\bm{x}},1,k)},\qquad\alpha_{t}(k)=e^{s_{\theta}({\bm{x}},t,k)}\sum_{j=1}^{K}\alpha_{t-1}(j)\,e^{A_{jk}},\qquad Z_{\theta}({\bm{x}})=\sum_{k=1}^{K}\alpha_{T}(k),(72)carried out inlog\logspace for numerical stability. MLE then applies directly. The gradient again has the form of Equation40, and because the energy is a sum of local terms, the expectation under the model only needs the marginalspθ​(yt∣𝒙)p_{\theta}(y_{t}\mid{\bm{x}})andpθ​(yt−1,yt∣𝒙)p_{\theta}(y_{t-1},y_{t}\mid{\bm{x}}), which the forward-backward algorithm computes exactly inO⁡(T​K2)O(TK^{2}). In practice, one computeslog⁡Zθ​(𝒙)\log Z_{\theta}({\bm{x}})with Equation72and lets automatic differentiation produce this gradient, then optimizes with L-BFGS or stochastic gradient descent. Prediction is energy minimization,𝒚⋆=argmin𝒚Eθ​(𝒙,𝒚){\bm{y}}^{\star}=\mathop{\mathrm{argmin}}_{\bm{y}}E_{\theta}({\bm{x}},{\bm{y}}), solved exactly by the Viterbi algorithm, which replaces the sum in Equation72with a max.

General CRFs.

Exact MLE relies on the chain structure, and it extends to trees and graphs of low treewidth through the junction tree algorithm. For CRFs on loopy graphs, such as grid CRFs for image segmentation,Zθ​(𝒙)Z_{\theta}({\bm{x}})and the marginals are intractable, and the learning methods of Section2.5apply with the label𝒚{\bm{y}}in place of𝒙{\bm{x}}: approximate marginals from loopy belief propagation or mean-field[185], pseudolikelihood over each label given its neighbors[21], or contrastive divergence with Gibbs sampling.

Max-Margin Training.

Alternatively, one can drop the probabilistic model and train with only the minimum-energy output. The structured perceptron[33], max-margin Markov networks[168], and structured support vector machines (structured SVMs)[174]replace the expectation under the model in Equation40with the energy minimizer, or its loss-augmented version for the margin-based methods, which only requires MAP inference. These methods are still EBMs: they learn an energy over input–output pairs and predict by minimizing it, but they shape the energy with a margin loss instead of the likelihood, so the energy never needs to be normalized[108]. This makes them applicable whenever the energy can be minimized, even whenZθ​(𝒙)Z_{\theta}({\bm{x}})cannot be computed. The same idea underlies the SPENs of Section3.2, which keep the structured SVM loss and replace its linear energy with a deep network.

3.2Structured Prediction Energy Networks

A CRF fixes the interactions among labels in advance through a graph over the labels. In a linear-chain CRF Equation71, only neighboring labels interact, which is what makesZθ​(𝒙)Z_{\theta}({\bm{x}})tractable; richer graphs capture more interactions but need the approximations discussed above. Structured prediction energy networks (SPENs)[18]drop this restriction. The energy is a deep network over the whole output, so it can capture interactions among all labels, and inference becomes optimization over𝒚{\bm{y}}instead of dynamic programming.

Energy.

For multi-label classification withLLlabels, SPENs relax the binary output to𝒚∈[0,1]L{\bm{y}}\in[0,1]^{L}and use an energy with two terms,

Eθ(𝒙,𝒚)=−∑i=1Lyi𝒃i⊤F(𝒙)−𝒄2⊤g(C1𝒚),E_{\theta}({\bm{x}},{\bm{y}})=-\sum_{i=1}^{L}y_{i}\,{\bm{b}}_{i}^{\top}F({\bm{x}})-{\bm{c}}_{2}^{\top}g\left(C_{1}{\bm{y}}\right),(73)whereF⁡(𝒙)F({\bm{x}})is a feature network,𝒃i{\bm{b}}_{i},𝒄2{\bm{c}}_{2}, andC1C_{1}are learned parameters, andggis an elementwise nonlinearity. The first term is local: it scores each label from the input, as in logistic regression. The second term is global:𝒄2⊤​g​(C1​𝒚){\bm{c}}_{2}^{\top}g\left(C_{1}{\bm{y}}\right)is a one-hidden-layer network over the whole label vector, which can learn which labels tend to appear together, without specifying a graph.

Inference.

Prediction is energy minimization, as in Section2.4,

𝒚^=argmin𝒚∈[0,1]LEθ​(𝒙,𝒚),\hat{{\bm{y}}}=\mathop{\mathrm{argmin}}_{{\bm{y}}\in[0,1]^{L}}\;E_{\theta}({\bm{x}},{\bm{y}}),(74)solved by projected gradient descent on𝒚{\bm{y}}, with𝒚{\bm{y}}rounded to binary labels at the end. SinceEθE_{\theta}is not convex in𝒚{\bm{y}}, this finds a local minimum, and the result depends on the initialization and the number of steps.

Learning.

Zθ​(𝒙)Z_{\theta}({\bm{x}})is an integral over𝒚{\bm{y}}with a non-decomposable energy, so maximum likelihood is out of reach, and SPENs are trained without a probabilistic model. The original SPEN is trained as a structured SVM[174], one of the max-margin methods mentioned at the end of the previous subsection, with the structured hinge loss

ℒ⁡(θ)=∑(𝒙,𝒚)∈𝒟max𝒚′⁡[Δ⁡(𝒚,𝒚′)+Eθ​(𝒙,𝒚)−Eθ​(𝒙,𝒚′)]+,\mathcal{L}(\theta)=\sum_{({\bm{x}},{\bm{y}})\in\mathcal{D}}\max_{{\bm{y}}^{\prime}}\left[\Delta({\bm{y}},{\bm{y}}^{\prime})+E_{\theta}({\bm{x}},{\bm{y}})-E_{\theta}({\bm{x}},{\bm{y}}^{\prime})\right]_{+},(75)whereΔ⁡(𝒚,𝒚′)\Delta({\bm{y}},{\bm{y}}^{\prime})is a task loss, such as the Hamming distance. Its gradient is∇θEθ​(𝒙,𝒚)−∇θEθ​(𝒙,𝒚^′)\nabla_{\theta}E_{\theta}({\bm{x}},{\bm{y}})-\nabla_{\theta}E_{\theta}({\bm{x}},\hat{\bm{y}}^{\prime}), where𝒚^′\hat{\bm{y}}^{\prime}is the maximizer, found by gradient descent on𝒚′{\bm{y}}^{\prime}. This is the contrastive form Equation63with a single negative sample: the output with low energy but high task loss.

A SPEN is thus a structured SVM with a deep energy. A structured SVM uses an energy that is linear in the parameters,E𝒘​(𝒙,𝒚)=−𝒘⊤​Ψ​(𝒙,𝒚)E_{\bm{w}}({\bm{x}},{\bm{y}})=-{\bm{w}}^{\top}\Psi({\bm{x}},{\bm{y}}), with a joint feature mapΨ\Psidesigned so that the maximization over𝒚′{\bm{y}}^{\prime}in Equation75, known as loss-augmented inference, can be solved exactly,e.g., by dynamic programming or graph cuts. The training problem is then convex. SPENs keep the same loss and replace the linear energy with the deep energy Equation73. This removes the need to designΨ\Psiand lets the energy learn interactions among all labels, but loss-augmented inference becomes gradient descent over a relaxed𝒚′{\bm{y}}^{\prime}, which is only approximate, and the training problem is no longer convex.

End-to-end SPENs[19]replace the hinge loss altogether: they unroll a fixed number of gradient steps of Equation74and backpropagate a task loss on the final prediction through them, which is the regression training of Section2.5applied to a discriminative energy.

Two later lines of work change how the energy is trained or used. Deep value networks[82]train the energy to regress the task score of an output directly. Inference networks[175]train a separate networkAω​(𝒙)A_{\omega}({\bm{x}})to approximate the minimizer in Equation74, so prediction is a single forward pass. The latter mirrors adversarial training in Section2.5: the energy is trained against a learned network that searches for its low-energy outputs, except that here the network finds a minimizer rather than a sampler.

4Generative Models

Many existing generative models can be viewed as special cases of EBMs. Each defines, explicitly or implicitly, a distributionpθ​(𝒙)∝exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\exp\left(-E_{\theta}({\bm{x}})\right), and they differ mainly in how they handle two parts that Section2treated separately: the potential functionEθE_{\theta}and the sampler that draws from it. A general EBM parameterizes the potential freely, so it can express any shape, but it must pay at sampling time, with MCMC or a learned sampler, and at training time, with the methods of Section2.5. Other generative models restrict or learn one of the two parts so that the other becomes easy.

The following subsections take the main families in turn. In GANs, the generator plays the role of the learned sampler in adversarial training and the discriminator plays the role of the potential; adding an entropy term on the generator turns the pair into an EBM trained by maximum likelihood. Normalizing flows build the sampler as an invertible map, which makes the potential, including its normalization, exact by change of variables. Diffusion and flow-matching models learn the gradient of the potential at many noise levels and sample by following it, as in annealed Langevin dynamics. Energy-inspired models take a sampler that uses a learned potential as the model itself, so that sampling is exact and the likelihood has a tractable bound; modern Hopfield networks, discussed alongside them, retrieve stored patterns by energy minimization; and deep equilibrium models define a layer by the fixed point of an iterative update, such as energy minimization. Finally, autoregressive models write the potential as a sum of normalized conditionals, which makes sampling one variable at a time exact.

4.1Generative Adversarial Nets

The adversarial training of Section2.5already has the structure of a GAN. We make the correspondence explicit, and then use it to read the original GAN and its variants from the EBM view.

Entropy-Regularized GAN.

Take the samplerqqin Equation57to be an implicit generator,𝒙=gϕ​(𝒛){\bm{x}}=g_{\phi}({\bm{z}})with𝒛∼𝒩⁡(0,I){\bm{z}}\sim\mathcal{N}\left(0,I\right), and writeqϕq_{\phi}for its distribution. Maximum likelihood for the EBM becomes

minθ⁡maxϕ​𝔼𝒙∼pd​[Eθ​(𝒙)]−𝔼𝒛​[Eθ​(gϕ​(𝒛))]+H⁡(qϕ).\min_{\theta}\,\max_{\phi}\;\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[E_{\theta}({\bm{x}})\right]-\mathbb{E}_{{\bm{z}}}\left[E_{\theta}\left(g_{\phi}({\bm{z}})\right)\right]+H\left(q_{\phi}\right).(76)The energy acts as the discriminator: it is lowered on data and raised on generated samples. The generator moves its samples toward low energy, while the entropy term keeps them spread out. The two players have the same roles as in Section2.5, and so does the result. If both families are rich enough, the solution satisfiesqϕ=pθ=pdq_{\phi}=p_{\theta}=p_{d}: the energy recovers−log⁡pd-\log p_{d}up to a constant, and the generator is a sampler for it. Training yields both parts of the EBM, the potential and the sampler[101,39,36]. The practical difficulty is the one noted in Section2.5: the entropy of an implicit generator has no closed form and must be estimated or bounded.

The Original GAN.

The original GAN[77]trains a discriminatorD⁡(𝒙)=sigm⁡(ℓ⁡(𝒙))D({\bm{x}})=\mathrm{sigm}\left(\ell({\bm{x}})\right)to tell data from generated samples,

minϕ⁡maxℓ​𝔼𝒙∼pd​[log⁡sigm⁡(ℓ⁡(𝒙))]+𝔼𝒛​[log⁡(1−sigm⁡(ℓ⁡(gϕ​(𝒛))))].\min_{\phi}\,\max_{\ell}\;\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\log\mathrm{sigm}\left(\ell({\bm{x}})\right)\right]+\mathbb{E}_{{\bm{z}}}\left[\log\left(1-\mathrm{sigm}\left(\ell(g_{\phi}({\bm{z}}))\right)\right)\right].(77)For a fixed generator, the optimal discriminator isD⋆=pd/(pd+qϕ)D^{\star}=p_{d}/(p_{d}+q_{\phi}), so its logit is thelog\log-density ratio,ℓ⋆=log⁡pd−log⁡qϕ\ell^{\star}=\log p_{d}-\log q_{\phi}, and the generator then minimizes the Jensen–Shannon divergence betweenpdp_{d}andqϕq_{\phi}[77].

The discriminator objective in Equation77is binary NCE Equation44withν=1\nu=1and the generator as the noise distribution. Comparingℓ\ellwith the NCE logit Equation43shows what is missing: NCE parameterizesℓ⁡(𝒙)=−Eθ​(𝒙)−log⁡pn​(𝒙)−c\ell({\bm{x}})=-E_{\theta}({\bm{x}})-\log p_{n}({\bm{x}})-c, which requires the noise density, whereas an implicit generator has no tractableqϕ​(𝒙)q_{\phi}({\bm{x}}). The GAN therefore learns the ratioℓ\elldirectly instead of an energy. This has two consequences. First, asqϕq_{\phi}approachespdp_{d}, thelog\log-ratio goes to zero and the discriminator becomes constant,D⋆=1/2D^{\star}=1/2, so at the solution the potential is discarded and only the sampler remains. The energy could in principle be read off as−Eθ=ℓ+log⁡qϕ-E_{\theta}=\ell+\log q_{\phi}up to a constant, but this requireslog⁡qϕ\log q_{\phi}. Without the generator’s density, the EBM cannot be obtained from a trained GAN. Second, the generator update has no entropy term, so the generator’s best response is not tied to an EBM. For a fixed energy, the entropy-regularized generator maximizes−𝔼q[Eθ]+H(q)=−KL(q∥pθ)+logZθ-\mathbb{E}_{q}\left[E_{\theta}\right]+H\left(q\right)=-\mathrm{KL}\left(q\|p_{\theta}\right)+\log Z_{\theta}, whose unique maximizer is the EBM itself,q=pθ∝exp⁡(−Eθ)q=p_{\theta}\propto\exp\left(-E_{\theta}\right). Without the entropy, the generator only maximizes−𝔼q​[Eθ]-\mathbb{E}_{q}\left[E_{\theta}\right], or, in Equation77, minimizes𝔼q​[log⁡(1−sigm⁡(ℓ))]\mathbb{E}_{q}\left[\log\left(1-\mathrm{sigm}(\ell)\right)\right]; in both cases, the best response is a point mass at the minimum of the energy, or at the maximum ofℓ\ell. The EBM is then just one of the distributions the generator may settle on, with no force pulling it there, and the game can reach solutions outside the space of EBMs, such as a generator that covers only some modes of the data; this is one source of mode collapse.

The entropy term in Equation76addresses both points: it makes the generator’s objectiveKL(qϕ∥pθ)\mathrm{KL}\left(q_{\phi}\|p_{\theta}\right), so every solution of the game is an EBM, and it keeps the discriminator a valid energy at the solution. Both require the generator’s density: the entropyH⁡(qϕ)=−𝔼qϕ​[log⁡qϕ]H\left(q_{\phi}\right)=-\mathbb{E}_{q_{\phi}}\left[\log q_{\phi}\right]requireslog⁡qϕ\log q_{\phi}, which is exactly what an implicit generator lacks. This is why entropy-regularized GANs either use generators with tractable densities or estimate the entropy, as discussed in Section2.5.

Other GAN Variants.

Several GAN variants change the discriminator loss, and the EBM view classifies them by how the loss shapes the potential. Each loss relaxes the constraints that an EBM places on the model: the potential need not be normalized, and the generator need not sample from it. Theff-GAN[134]replaces the Jensen–Shannon divergence with anyff-divergence through its variational representation. Its optimal discriminator is again a function of the density ratiopd/qϕp_{d}/q_{\phi}, and its generator again has no entropy term, so both points above apply unchanged: the energy cannot be recovered withoutlog⁡qϕ\log q_{\phi}, and the solutions of the game need not be EBMs. The Wasserstein GAN[6]uses a criticffand the objective𝔼pd​[f]−𝔼qϕ​[f]\mathbb{E}_{p_{d}}\left[f\right]-\mathbb{E}_{q_{\phi}}\left[f\right]over11-Lipschitzff. Withf=−Eθf=-E_{\theta}, the critic objective looks like the contrastive maximum likelihood loss Equation41, but the resemblance is only in form. Maximum likelihood requires the negative samples to come from the EBM itself,pθ∝exp⁡(−Eθ)p_{\theta}\propto\exp\left(-E_{\theta}\right). In the Wasserstein GAN, the generator is trained to reduce the Wasserstein distance topdp_{d}, and like the original GAN it has no entropy term, so its best response to a fixed critic is again a point mass rather thanpθp_{\theta}. The generator is therefore not a sampler for the EBM defined by the critic, and the critic’s gradient is not the maximum likelihood gradient. The Lipschitz constraint, rather than normalization, keeps the critic bounded, and at the solution the critic is the potential that defines the Wasserstein distance, not alog\log-density.

Table 2:GANs from the EBM view: the discriminator loss, whether the generator has an entropy term (Entropy), and what the discriminator represents at the solution.Table2summarizes the comparison. In every case the generator is a learned sampler. What separates the entropy-regularized GAN is that the discriminator is trained by maximum likelihood and the generator byKL(qϕ∥pθ)\mathrm{KL}\left(q_{\phi}\|p_{\theta}\right), so both parts of the EBM survive training. The learned energy can then be used beyond sampling, for example to evaluate unnormalized likelihoods, to refine generated samples with a few MCMC steps, or to be composed with other energies as in Section2.3.

4.2Normalizing Flows

For a general EBM, the partition functionZθZ_{\theta}is intractable, and this is the source of the difficulties in sampling and learning discussed in Section2. Normalizing flows avoid it with a special parametrization: the model is an invertible transformation of a simple distribution, so the change-of-variables formula gives its density, normalization included.

Change of Variables.

Let𝒛∼p0{\bm{z}}\sim p_{0}be a simple base distribution, such as𝒩⁡(0,I)\mathcal{N}\left(0,I\right), and let𝒙=gθ​(𝒛){\bm{x}}=g_{\theta}({\bm{z}}), wheregθ:ℝd→ℝdg_{\theta}:\mathbb{R}^{d}\to\mathbb{R}^{d}is invertible and differentiable. Sincegθg_{\theta}only moves probability mass around without creating or removing any, the density of𝒙{\bm{x}}is

pθ​(𝒙)=p0​(gθ−1​(𝒙))​|det∂gθ−1​(𝒙)∂𝒙|.p_{\theta}({\bm{x}})=p_{0}\left(g_{\theta}^{-1}({\bm{x}})\right)\,\left|\det\frac{\partial g_{\theta}^{-1}({\bm{x}})}{\partial{\bm{x}}}\right|.(78)This density is tractable whengθ−1g_{\theta}^{-1}and the determinant of its Jacobian are cheap to compute, and normalizing flows are built from layers that meet both requirements. Coupling layers[47,48]transform half of the variables with a function of the other half, so the Jacobian is triangular and its determinant is the product of the diagonal. Autoregressive flows[138,103]transform each variable conditioned on the previous ones, which also gives a triangular Jacobian. Glow[102]adds invertible1×11\times 1convolutions. Continuous normalizing flows[29,78]definegθg_{\theta}by an ordinary differential equation, in which case thelog\log-determinant becomes the integral of a trace along the trajectory. A deep flow composes many such layers, and thelog\log-determinants add up.

Normalizing Flows as EBMs.

Taking the negativelog\logof Equation78writes the flow in the form of Equation1,

pθ​(𝒙)=exp⁡(−Eθ​(𝒙))Zθ,Eθ​(𝒙)=−log⁡p0​(gθ−1​(𝒙))−log⁡|det∂gθ−1​(𝒙)∂𝒙|,Zθ=1.p_{\theta}({\bm{x}})=\frac{\exp\left(-E_{\theta}({\bm{x}})\right)}{Z_{\theta}},\qquad E_{\theta}({\bm{x}})=-\log p_{0}\left(g_{\theta}^{-1}({\bm{x}})\right)-\log\left|\det\frac{\partial g_{\theta}^{-1}({\bm{x}})}{\partial{\bm{x}}}\right|,\qquad Z_{\theta}=1.(79)The energy has two terms: how unlikely the corresponding latent point is under the base distribution, and how much the flow compresses or expands volume at𝒙{\bm{x}}. This special parametrization makes the partition function of the EBM tractable: it equals one for everyθ\theta, because the change of variables preserves total mass. More generally, if the base distribution is itself an EBM,p0∝exp⁡(−E0)p_{0}\propto\exp\left(-E_{0}\right)with partition functionZ0Z_{0}, then the same argument shows that the flow has partition functionZ0Z_{0}as well. A flow never changes the partition function; it moves the normalization into the base distribution, where it is known.

Learning and Sampling.

BecauseZθZ_{\theta}does not depend onθ\theta, maximum likelihood is exact. In the gradient Equation40, the expectation under the model equals−∇θ​log​Zθ=0-\nabla_{\theta}\log Z_{\theta}=0, so the negative phase vanishes and the gradient reduces to𝔼𝒙∼pd​[∇θEθ​(𝒙)]\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\nabla_{\theta}E_{\theta}({\bm{x}})\right], with no samples from the model needed during training. Sampling is also exact and takes one pass: draw𝒛∼p0{\bm{z}}\sim p_{0}and returngθ​(𝒛)g_{\theta}({\bm{z}}). A flow therefore makes both parts of the EBM easy at once, the potential with its normalization and the sampler.

Normalizing Flows and General EBMs.

Since a flow has an exact density, and hence an exact entropy, it is a natural choice for the learned sampler in adversarial training Equation57and in variational inference[146], which is the first difficulty noted for implicit generators in Section4.1. A flow can also serve as the noise distribution of NCE Equation44, where its exact density is what NCE needs; flow contrastive estimation trains the flow and the EBM jointly, so that the noise stays close to the data[70].

Limitations.

The tractability comes from architectural constraints. The map must be invertible, so𝒙{\bm{x}}and𝒛{\bm{z}}have the same dimension and there is no bottleneck, and each layer must have a cheap Jacobian determinant, which limits how much each layer can do. Invertibility also preserves topology: mapping a unimodal Gaussian onto data with separated modes requires very steep transformations between the modes. A general EBM has none of these constraints, but pays with an intractable partition function. This is the trade-off described at the start of this section: flows restrict the potential so that its normalization and its sampler come for free.

4.3Diffusion and Flow Models

Diffusion and flow models generate data by gradually transforming noise into samples. We first introduce both families in their usual form, and then use Tweedie’s formula to show that they learn a sequence of EBMs, one for each noise level, and differ from EBMs mainly in how they parameterize it.

Diffusion Models.

A diffusion model[160,89,163]fixes a forward process that corrupts a data point𝒙0∼pd{\bm{x}}_{0}\sim p_{d}with Gaussian noise of increasing scale. All we need is its marginal at each time,

𝒙t=αt​𝒙0+σt​ϵ,ϵ∼𝒩⁡(0,I),t∈[0,1],{\bm{x}}_{t}=\alpha_{t}{\bm{x}}_{0}+\sigma_{t}\bm{\epsilon},\qquad\bm{\epsilon}\sim\mathcal{N}\left(0,I\right),\qquad t\in[0,1],(80)that is,𝒙t|𝒙0∼𝒩⁡(αt​𝒙0,σt2​I){\bm{x}}_{t}\mid{\bm{x}}_{0}\sim\mathcal{N}\left(\alpha_{t}{\bm{x}}_{0},\sigma_{t}^{2}I\right). The schedule satisfiesα0=1\alpha_{0}=1andσ0=0\sigma_{0}=0, and the signal-to-noise ratioαt2/σt2\alpha_{t}^{2}/\sigma_{t}^{2}decreases to nearly zero att=1t=1. Variance-preserving diffusion takesαt2+σt2=1\alpha_{t}^{2}+\sigma_{t}^{2}=1, variance-exploding diffusion takesαt=1\alpha_{t}=1withσt\sigma_{t}growing large, and the linear interpolationαt=1−t\alpha_{t}=1-t,σt=t\sigma_{t}=tis used by rectified flow. Letptp_{t}denote the distribution of𝒙t{\bm{x}}_{t}. To generate data, the process is run backward in time, from noise att=1t=1to data att=0t=0, by the reverse-time stochastic differential equation or the deterministic probability-flow ordinary differential equation[163]. Both only require the score∇𝒙​log​pt​(𝒙)\nabla_{\bm{x}}\log p_{t}({\bm{x}})at everytt. Diffusion models learn it with a networkϵθ​(𝒙t,t)\bm{\epsilon}_{\theta}({\bm{x}}_{t},t)trained to predict the noise that was added,

ℒ⁡(θ)=𝔼t,𝒙0∼pd,ϵ​[w⁡(t)​‖ϵθ​(αt​𝒙0+σt​ϵ,t)−ϵ‖22],\mathcal{L}(\theta)=\mathbb{E}_{t,\,{\bm{x}}_{0}\sim p_{d},\,\bm{\epsilon}}\left[w(t)\,\big\|\bm{\epsilon}_{\theta}\left(\alpha_{t}{\bm{x}}_{0}+\sigma_{t}\bm{\epsilon},t\right)-\bm{\epsilon}\big\|_{2}^{2}\right],(81)with a weightingw⁡(t)w(t)over noise levels. At eachtt, this is denoising score matching Equation55[183], which corresponds toαt=1\alpha_{t}=1, generalized toαt≠1\alpha_{t}\neq 1, as made precise below.

Flow Models.

Flow matching and rectified flow[115,119,3]use the same interpolation Equation80between data and noise, but learn the velocity of the path instead of the noise. The network𝒗θ​(𝒙t,t){\bm{v}}_{\theta}({\bm{x}}_{t},t)is regressed onto the time derivative of the interpolation,

ℒ⁡(θ)=𝔼t,𝒙0∼pd,ϵ​[‖𝒗θ​(𝒙t,t)−(α˙t​𝒙0+σ˙t​ϵ)‖22],\mathcal{L}(\theta)=\mathbb{E}_{t,\,{\bm{x}}_{0}\sim p_{d},\,\bm{\epsilon}}\left[\big\|{\bm{v}}_{\theta}\left({\bm{x}}_{t},t\right)-\left(\dot{\alpha}_{t}{\bm{x}}_{0}+\dot{\sigma}_{t}\bm{\epsilon}\right)\big\|_{2}^{2}\right],(82)and samples are generated by integrating the ordinary differential equationd​𝒙t/d​t=𝒗θ​(𝒙t,t)d{\bm{x}}_{t}/dt={\bm{v}}_{\theta}({\bm{x}}_{t},t)from noise to data. Some works use the reverse time convention, with noise att=0t=0; we follow the diffusion convention throughout. The minimizer of Equation82is the conditional expectation𝒗⋆​(𝒙,t)=α˙t​𝔼​[𝒙0∣𝒙t=𝒙]+σ˙t​𝔼​[ϵ∣𝒙t=𝒙]{\bm{v}}^{\star}({\bm{x}},t)=\dot{\alpha}_{t}\mathbb{E}\left[{\bm{x}}_{0}\mid{\bm{x}}_{t}={\bm{x}}\right]+\dot{\sigma}_{t}\mathbb{E}\left[\bm{\epsilon}\mid{\bm{x}}_{t}={\bm{x}}\right].

Tweedie’s Formula.

The two families, and their different targets, are connected by Tweedie’s formula[61]. Sincept​(𝒙)=∫pd​(𝒙0)​𝒩​(𝒙,αt​𝒙0,σt2​I)​d​𝒙0p_{t}({\bm{x}})=\int p_{d}({\bm{x}}_{0})\,\mathcal{N}\left({\bm{x}};\alpha_{t}{\bm{x}}_{0},\sigma_{t}^{2}I\right)\,d{\bm{x}}_{0}, differentiating under the integral gives∇𝒙pt​(𝒙)=∫pd​(𝒙0)​𝒩​(𝒙,αt​𝒙0,σt2​I)​αt​𝒙0−𝒙σt2​d​𝒙0\nabla_{\bm{x}}p_{t}({\bm{x}})=\int p_{d}({\bm{x}}_{0})\,\mathcal{N}\left({\bm{x}};\alpha_{t}{\bm{x}}_{0},\sigma_{t}^{2}I\right)\,\frac{\alpha_{t}{\bm{x}}_{0}-{\bm{x}}}{\sigma_{t}^{2}}\,d{\bm{x}}_{0}, and dividing bypt​(𝒙)p_{t}({\bm{x}})yields

∇𝒙​log​pt​(𝒙)=αt​𝔼​[𝒙0∣𝒙t=𝒙]−𝒙σt2,equivalently𝔼⁡[𝒙0∣𝒙t=𝒙]=𝒙+σt2​∇𝒙​log⁡pt​(𝒙)αt.\nabla_{\bm{x}}\log p_{t}({\bm{x}})=\frac{\alpha_{t}\,\mathbb{E}\left[{\bm{x}}_{0}\mid{\bm{x}}_{t}={\bm{x}}\right]-{\bm{x}}}{\sigma_{t}^{2}},\qquad\text{equivalently}\qquad\mathbb{E}\left[{\bm{x}}_{0}\mid{\bm{x}}_{t}={\bm{x}}\right]=\frac{{\bm{x}}+\sigma_{t}^{2}\nabla_{\bm{x}}\log p_{t}({\bm{x}})}{\alpha_{t}}.(83)The score of the noisy distribution is the direction from𝒙{\bm{x}}toward its denoised estimate. Taking the conditional expectation of𝒙t=αt​𝒙0+σt​ϵ{\bm{x}}_{t}=\alpha_{t}{\bm{x}}_{0}+\sigma_{t}\bm{\epsilon}given𝒙t=𝒙{\bm{x}}_{t}={\bm{x}}gives𝒙=αt​𝔼​[𝒙0∣𝒙]+σt​𝔼​[ϵ∣𝒙]{\bm{x}}=\alpha_{t}\mathbb{E}\left[{\bm{x}}_{0}\mid{\bm{x}}\right]+\sigma_{t}\mathbb{E}\left[\bm{\epsilon}\mid{\bm{x}}\right], so the expected noise is𝔼⁡[ϵ∣𝒙]=(𝒙−αt​𝔼​[𝒙0∣𝒙])/σt=−σt​∇𝒙​log⁡pt​(𝒙)\mathbb{E}\left[\bm{\epsilon}\mid{\bm{x}}\right]=\left({\bm{x}}-\alpha_{t}\mathbb{E}\left[{\bm{x}}_{0}\mid{\bm{x}}\right]\right)/\sigma_{t}=-\sigma_{t}\nabla_{\bm{x}}\log p_{t}({\bm{x}})by Equation83. Since this conditional expectation is the minimizer of Equation81, the optimal noise predictor is the score scaled by−σt-\sigma_{t}. The noise prediction, the data prediction, and the velocity are therefore all affine functions of the score, with coefficients that depend only ontt.

Diffusion Models as EBMs.

Now write each noisy distribution as an EBM with a time-dependent energy,

pt​(𝒙)=exp⁡(−Eθ​(𝒙,t))Zθ​(t),∇𝒙​log​pt​(𝒙)=−∇𝒙Eθ​(𝒙,t),p_{t}({\bm{x}})=\frac{\exp\left(-E_{\theta}({\bm{x}},t)\right)}{Z_{\theta}(t)},\qquad\nabla_{\bm{x}}\log p_{t}({\bm{x}})=-\nabla_{\bm{x}}E_{\theta}({\bm{x}},t),(84)where, as in score matching,Zθ​(t)Z_{\theta}(t)drops out of the score. We emphasize that this connection, like score matching itself, relies on the gradient∇𝒙\nabla_{\bm{x}}and the Gaussian corruption Equation80, so it holds only for continuous𝒙{\bm{x}}. For discrete data, there is no gradient; the score is replaced by ratios of probabilities between neighboring states, as in the ratio matching discussed with score matching in Section2.5, and discrete diffusion models learn such ratios or the corresponding conditionals instead[9,165,120]. By Tweedie’s formula, every target used by diffusion and flow models is determined by the gradient of this energy,

ϵ⋆​(𝒙,t)\displaystyle\bm{\epsilon}^{\star}({\bm{x}},t)=σt∇𝒙Eθ(𝒙,t),𝒙0⋆(𝒙,t)=𝒙−σt2​∇𝒙Eθ​(𝒙,t)αt,\displaystyle=\sigma_{t}\nabla_{\bm{x}}E_{\theta}({\bm{x}},t),\qquad{\bm{x}}_{0}^{\star}({\bm{x}},t)=\frac{{\bm{x}}-\sigma_{t}^{2}\nabla_{\bm{x}}E_{\theta}({\bm{x}},t)}{\alpha_{t}},(85)𝒗⋆​(𝒙,t)\displaystyle{\bm{v}}^{\star}({\bm{x}},t)=α˙tαt​𝒙−σt​(α˙t​σtαt−σ˙t)​∇𝒙Eθ​(𝒙,t).\displaystyle=\frac{\dot{\alpha}_{t}}{\alpha_{t}}{\bm{x}}-\sigma_{t}\left(\frac{\dot{\alpha}_{t}\sigma_{t}}{\alpha_{t}}-\dot{\sigma}_{t}\right)\nabla_{\bm{x}}E_{\theta}({\bm{x}},t).Substituting the first expression into Equation81recovers denoising score matching[183],i.e., Equation55, for the energyEθ​(⋅,t)E_{\theta}(\cdot,t), weighted over noise levels. A diffusion model is therefore a family of EBMs,{pt}t∈[0,1]\left\{p_{t}\right\}_{t\in[0,1]}, learned by denoising score matching[183,161]. The energy att=0t=0describes the data, and the energies at largerttare smoothed versions of it whose landscapes are easier to traverse. Sampling moves through this family from smooth to sharp, which is the annealed Langevin dynamics ofSong and Ermon [161]in its original form, and the reverse-time dynamics[163]in general.

The Difference Is the Parameterization.

In terms of the two parts of Section4, diffusion and flow models keep the EBM’s potential but parameterize it through its gradient: the network outputs the vectorϵθ\bm{\epsilon}_{\theta},𝒙0,θ{\bm{x}}_{0,\theta}, or𝒗θ{\bm{v}}_{\theta}directly, and Equation85is read in reverse to define an implied score. An EBM instead parameterizes the scalarEθ​(𝒙,t)E_{\theta}({\bm{x}},t)and obtains the score by differentiation. The two are trained with the same loss, and differ in three ways.

  • •Conservativeness.A score obtained as−∇𝒙Eθ-\nabla_{\bm{x}}E_{\theta}is a gradient field. A vector-valued network is not constrained to be one, so the implied score need not be the gradient of any energy, for the same reason as for the deep equilibrium layers of Section4.5.
  • •Access to the energy.With a scalar energy,log⁡pt\log p_{t}can be evaluated up to a constant. This enables Metropolis–Hastings corrections Equation24and Hamiltonian Monte Carlo during sampling, and comparisons between samples, none of which is possible with the vector parameterization.
  • •Cost.The scalar parameterization needs an extra backward pass to obtain the score, and in practice it has reached comparable but not better sample quality[151,49].

The difference matters most for composition (Section2.3). The product of two EBMs has energyE1+E2E_{1}+E_{2}, but adding the scores of two diffusion models at timettdoes not give the score of the noised product, because adding noise does not commute with taking products. Sampling from the composition by following the summed scores is therefore biased. With an energy parameterization, the summed energies define a valid unnormalized density at eachtt, and MCMC corrections can sample from it correctly[49]as Figure4shows.

Refer to captionFigure 4:Sampling compositions of two diffusion models.Left to right: the two component distributions, samples from the true composition, and samples from reverse diffusion and from annealed MCMC (HMC) on the composed models. Top: product; bottom: mixture. Reverse diffusion fails to sample either composition, whereas MCMC on the composed energies recovers both. For the product, summing the scores of the two models at each noise level does not give the score of the noised product, since adding noise does not commute with taking products. Reproduced fromDu et al. [49].

Guided Sampling as a Product of Distributions.

The EBM view also explains why guided sampling works. Classifier guidance[45]draws class-conditional samples from an unconditional diffusion model by adding the gradient of a classifierpt​(y∣𝒙)p_{t}(y\mid{\bm{x}})trained on noisy inputs, scaled by a guidance weightww,

∇𝒙​log​pt​(𝒙)+w​∇𝒙​log​pt​(y∣𝒙)=−∇𝒙[Eθ​(𝒙,t)+w​Eω​(𝒙,y,t)],Eω​(𝒙,y,t)=−log⁡pt​(y∣𝒙).\nabla_{\bm{x}}\log p_{t}({\bm{x}})+w\,\nabla_{\bm{x}}\log p_{t}(y\mid{\bm{x}})=-\nabla_{\bm{x}}\left[E_{\theta}({\bm{x}},t)+w\,E_{\omega}({\bm{x}},y,t)\right],\qquad E_{\omega}({\bm{x}},y,t)=-\log p_{t}(y\mid{\bm{x}}).(86)The classifier is the conditional EBM of Section3, and the right-hand side is the gradient of a sum of two energies. By Section2.3, a sum of energies is a product of distributions, so Equation86is

p~t​(𝒙∣y)∝pt​(𝒙)​pt​(y∣𝒙)w.\tilde{p}_{t}({\bm{x}}\mid y)\propto p_{t}({\bm{x}})\,p_{t}(y\mid{\bm{x}})^{w}.(87)Forw=1w=1, this is the posteriorpt​(𝒙∣y)p_{t}({\bm{x}}\mid y)by Bayes’ rule; forw>1w>1, the classifier expert is sharpened, which trades diversity for fidelity. Classifier-free guidance[90]trains a conditional and an unconditional model together and combines their outputs as(1+w)​ϵθ​(𝒙,y,t)−w​ϵθ​(𝒙,t)(1+w)\,\bm{\epsilon}_{\theta}({\bm{x}},y,t)-w\,\bm{\epsilon}_{\theta}({\bm{x}},t). By Equation85, this corresponds to the energy(1+w)​Eθ​(𝒙∣y,t)−w​Eθ​(𝒙,t)(1+w)\,E_{\theta}({\bm{x}}\mid y,t)-w\,E_{\theta}({\bm{x}},t), that is, to the distribution

p~t​(𝒙∣y)∝pt​(𝒙∣y)1+wpt​(𝒙)w∝pt​(𝒙)​pt​(y∣𝒙)1+w,\tilde{p}_{t}({\bm{x}}\mid y)\propto\frac{p_{t}({\bm{x}}\mid y)^{1+w}}{p_{t}({\bm{x}})^{w}}\propto p_{t}({\bm{x}})\,p_{t}(y\mid{\bm{x}})^{1+w},(88)where the second step uses Bayes’ rule. Classifier-free guidance is therefore classifier guidance with an implicit classifier, defined by the ratio of the two models, and the negative weight on the unconditional model is a negated expert, as in the logicalNOTof Section2.3.

In both cases, the EBM view gives guidance a precise meaning: at each noise leveltt, the guided score is the score of a product of distributions, and Langevin dynamics Equation25on the summed energy samples, asymptotically or with an MH correction, from Equation87or Equation88. The same product combines a large pretrained diffusion model with a small domain-specific one through their scores alone, which adapts black-box text-to-video models without fine-tuning[194]. It also shows the limit of the usual implementation. Guided diffusion samplers plug the summed score into the reverse process, which assumes that the guided distributions at differentttare noised versions of one another. They are not, for the same reason as for composition above: adding noise does not commute with taking products. Guided reverse diffusion therefore only approximately samples the product distribution, and running Langevin or MCMC steps on the summed energy at eachtt, corrected by Metropolis–Hastings when the energy is available, removes this bias[49].

4.4Energy-Inspired Models

Diffusion models in Section4.3can be read as EBMs with a sampler-friendly parameterization: the potential is learned through its gradients at every noise level, which is exactly what the reverse-time sampler uses. Energy-inspired models (EIMs)[107], proposed before this view of diffusion models became common, share the same spirit from a different direction: they focus on the sampling procedure of the EBM during learning. A general EBM is sampled with an approximate procedure, such as MCMC or importance sampling, so the samples we actually use come from the sampler, not from the modelpθp_{\theta}, and training the energy as if the samples were exact creates a mismatch between the model and the inference procedure. EIMs remove the mismatch by taking the distribution induced by the sampler, which uses a learned energy, as the model itself, and maximizing its likelihood directly. In terms of the two parts of Section4, an EIM keeps the energy but defines the distribution through the sampler, so that sampling is exact by construction.

Self-Normalized Importance Sampling.

Letπ⁡(𝒙)\pi({\bm{x}})be a tractable proposal, for example a Gaussian or a VAE, so that the target EBM ispθ​(𝒙)∝π⁡(𝒙)​exp⁡(−Eθ​(𝒙))p_{\theta}({\bm{x}})\propto\pi({\bm{x}})\exp\left(-E_{\theta}({\bm{x}})\right). The simplest EIM drawsKKcandidates𝒙1,…,𝒙K∼π{\bm{x}}_{1},\ldots,{\bm{x}}_{K}\sim\piand returns𝒙i{\bm{x}}_{i}with probability proportional toexp⁡(−Eθ​(𝒙i))\exp\left(-E_{\theta}({\bm{x}}_{i})\right). The likelihood of this sampler is intractable, because it marginalizes over the candidates, but treating the candidates as latent variables gives the evidence lower bound

logqθSNIS(𝒙)⩾𝔼𝒙2:K∼π[logπ⁡(𝒙)​exp⁡(−Eθ​(𝒙))1K​(exp⁡(−Eθ​(𝒙))+∑j=2Kexp⁡(−Eθ​(𝒙j)))].\log q_{\theta}^{\text{SNIS}}({\bm{x}})\geqslant\mathbb{E}_{{\bm{x}}_{2:K}\sim\pi}\left[\log\frac{\pi({\bm{x}})\exp\left(-E_{\theta}({\bm{x}})\right)}{\frac{1}{K}\left(\exp\left(-E_{\theta}({\bm{x}})\right)+\sum_{j=2}^{K}\exp\left(-E_{\theta}({\bm{x}}_{j})\right)\right)}\right].(89)AsK→∞K\to\infty, the denominator converges toZθZ_{\theta}andqθSNISq_{\theta}^{\text{SNIS}}to the EBMpθp_{\theta}; for finiteKK, the model interpolates between the proposalπ\piand the EBM. Up to terms that do not depend on the energy, Equation89is the ranking NCE objective Equation47with the proposal as the noise distribution,pn=πp_{n}=\pi. The EIM view therefore gives ranking NCE a new reading: it is a lower bound on the likelihood of a well-defined model, the SNIS sampler, whether or not the data distribution lies in the model family, and it provides a principled objective for learning the noise distribution together with the energy, which NCE alone does not. A truncated rejection sampler, which accepts proposals one at a time with probabilitysigm​(−Eθ​(𝒙))\mathrm{sigm}\left(-E_{\theta}({\bm{x}})\right), gives another EIM and recovers the generative process of learned accept/reject sampling[16].

Hamiltonian Importance Sampling.

Importance sampling scales poorly with dimension, because all candidates come from the proposal. Hamiltonian importance sampling[131]instead moves a single sample: it draws𝒙(0)∼π{\bm{x}}^{(0)}\sim\piand a momentum𝒗(0)∼𝒩⁡(0,I){\bm{v}}^{(0)}\sim\mathcal{N}\left(0,I\right), and runs leapfrog steps Equation28on the energyEθE_{\theta}with a learned schedule that rescales the momentum at each step. When the rescaling factors multiply to one, the map from(𝒙(0),𝒗(0))({\bm{x}}^{(0)},{\bm{v}}^{(0)})to(𝒙(T),𝒗(T))({\bm{x}}^{(T)},{\bm{v}}^{(T)})preserves volume, so the joint density of the endpoint equals that of the starting point. WritingΦθ\Phi_{\theta}for this map, which depends on the energy through its gradient, the likelihood of a data point𝒙=𝒙(T){\bm{x}}={\bm{x}}^{(T)}is bounded by treating the final momentum as a latent variable,

logqθHIS(𝒙)⩾𝔼𝒗(T)∼r(⋅∣𝒙)[logπ(𝒙(0))+log𝒩(𝒗(0);0,I)−logr(𝒗(T)∣𝒙)],(𝒙(0),𝒗(0))=Φθ−1(𝒙,𝒗(T)),\log q_{\theta}^{\text{HIS}}({\bm{x}})\geqslant\mathbb{E}_{{\bm{v}}^{(T)}\sim r(\cdot\mid{\bm{x}})}\left[\log\pi({\bm{x}}^{(0)})+\log\mathcal{N}\left({\bm{v}}^{(0)};0,I\right)-\log r({\bm{v}}^{(T)}\mid{\bm{x}})\right],\qquad({\bm{x}}^{(0)},{\bm{v}}^{(0)})=\Phi_{\theta}^{-1}({\bm{x}},{\bm{v}}^{(T)}),(90)wherer⁡(𝒗(T)∣𝒙)r({\bm{v}}^{(T)}\mid{\bm{x}})is a variational distribution over the final momentum and(𝒙(0),𝒗(0))({\bm{x}}^{(0)},{\bm{v}}^{(0)})is obtained by running the dynamics backward from(𝒙,𝒗(T))({\bm{x}},{\bm{v}}^{(T)}). The bound is maximized jointly over the energy, the proposal, the step size and schedule, andrr, by backpropagating through the trajectory. The proposal provides a coarse sample, and the gradient of the energy refines it, which helps when the proposal is poorly matched to the data. This construction is closely related to normalizing flows (Section4.2), as a volume-preserving flow driven by the energy, and to the dynamics-based samplers of adversarial training[36].

Hamiltonian importance sampling also resembles a diffusion model (Section4.3): both start from a simple distribution and move the sample over several steps guided by the gradient of an energy. The difference is in learning. Hamiltonian importance sampling is trained by maximizing the variational lower bound Equation90on the likelihood of the sampler’s output, which requires simulating the whole trajectory and backpropagating through it. A diffusion model never simulates its sampler during training: it fixes a forward noising process and fits the reverse process to it one noise level at a time, by the denoising regression Equation81.

Modern Hopfield Networks.

A related line of work uses an energy to design the update of a network rather than its distribution. The modern Hopfield network[142], which builds on classical Hopfield networks[93]and dense associative memories[105,42], stores patterns𝒙1,…,𝒙N{\bm{x}}_{1},\ldots,{\bm{x}}_{N}as the columns ofXXand assigns a state𝝃\bm{\xi}the energy

E(𝝃)=−1βlog∑i=1Nexp(β𝒙i⊤𝝃)+12𝝃⊤𝝃+const.E(\bm{\xi})=-\frac{1}{\beta}\log\sum_{i=1}^{N}\exp\left(\beta\,{\bm{x}}_{i}^{\top}\bm{\xi}\right)+\frac{1}{2}\bm{\xi}^{\top}\bm{\xi}+\text{const}.(91)The concave-convex procedure minimizes this energy with the update𝝃new=X​softmax​(β​X⊤​𝝃)\bm{\xi}^{\text{new}}=X\mathrm{softmax}\left(\beta X^{\top}\bm{\xi}\right), which converges, stores exponentially many patterns, and typically retrieves a well-separated pattern in one step. The softmax is a Gibbs distribution over the stored patterns, and the update replaces the state by the expected pattern under it. With queriesQQ, keysKK, valuesVVandβ=1/dk\beta=1/\sqrt{d_{k}}, one update is exactly the attentionsoftmax⁡(Q​K⊤/dk)​V\mathrm{softmax}\left(QK^{\top}/\sqrt{d_{k}}\right)Vof transformers[142], so an attention layer performs one step of energy minimization. Iterating such an update to its fixed point leads to the deep equilibrium models of Section4.5.

4.5Deep Equilibrium Models

Inference in an EBM is often energy minimization, carried out by iterating a fixed update until it stops changing. Deep equilibrium models (DEQs)[10]take this iteration as the definition of a network layer: the output is the point where the update no longer changes it. Used as a generator, a DEQ can be viewed as an energy-inspired model (Section4.4) whose sampler is a deterministic fixed-point solver: draw noise𝒛∼p0{\bm{z}}\sim p_{0}, iterate the update to its fixed point, and return it. When the update is a gradient step on an energy, this sampler is energy minimization started from the noise.

Fixed-Point Layers.

Given an input𝒙{\bm{x}}and a layerfθf_{\theta}, a DEQ defines its output as the fixed point

𝒛⋆=fθ​(𝒛⋆,𝒙).{\bm{z}}^{\star}=f_{\theta}\left({\bm{z}}^{\star},{\bm{x}}\right).(92)This corresponds to applying the same layer infinitely many times, a weight-tied network of infinite depth, but the fixed point is found directly by a root-finding method, such as Broyden’s method or Anderson acceleration, applied togθ​(𝒛)=fθ​(𝒛,𝒙)−𝒛g_{\theta}({\bm{z}})=f_{\theta}({\bm{z}},{\bm{x}})-{\bm{z}}. Training does not backpropagate through the solver’s iterations. By the implicit function theorem, the gradient of a lossℓ⁡(𝒛⋆)\ell({\bm{z}}^{\star})is

∂ℓ∂θ=∂ℓ∂𝒛⋆​(I−∂fθ​(𝒛⋆,𝒙)∂𝒛⋆)−1​∂fθ​(𝒛⋆,𝒙)∂θ,\frac{\partial\ell}{\partial\theta}=\frac{\partial\ell}{\partial{\bm{z}}^{\star}}\left(I-\frac{\partial f_{\theta}({\bm{z}}^{\star},{\bm{x}})}{\partial{\bm{z}}^{\star}}\right)^{-1}\frac{\partial f_{\theta}({\bm{z}}^{\star},{\bm{x}})}{\partial\theta},(93)which depends only on the fixed point, so memory does not grow with the number of solver steps. The vector–inverse-Jacobian product is itself computed by solving a linear fixed-point equation.

Learning DEQs.

How a DEQ is trained depends on whether a target is available for its fixed point. In the conditional setting, each input𝒙{\bm{x}}comes with a target output𝒚{\bm{y}}, and learning is easy: a task loss is placed on the fixed point and differentiated through it,

ℒ⁡(θ)=𝔼(𝒙,𝒚)∼𝒟​[ℓ⁡(hθ​(𝒛θ⋆​(𝒙)),𝒚)],𝒛θ⋆​(𝒙)=fθ​(𝒛θ⋆​(𝒙),𝒙),\mathcal{L}(\theta)=\mathbb{E}_{({\bm{x}},{\bm{y}})\sim\mathcal{D}}\left[\ell\left(h_{\theta}\left({\bm{z}}^{\star}_{\theta}({\bm{x}})\right),{\bm{y}}\right)\right],\qquad{\bm{z}}^{\star}_{\theta}({\bm{x}})=f_{\theta}\left({\bm{z}}^{\star}_{\theta}({\bm{x}}),{\bm{x}}\right),(94)wherehθh_{\theta}is an output head andℓ\ellis, for example, the cross-entropy for classification or the squared error for regression. The exact gradient is the implicit gradient Equation93[10]; cheaper approximations drop or truncate the inverse-Jacobian term, such as Jacobian-free backpropagation[192]and phantom gradients[74], and penalizing the Jacobian of the update keeps the fixed point stable during training[11]. Energy minimization trained by regression onto the solution, as in IREM[52], falls in this setting as well.

The unconditional setting, where the goal is to learn a distribution and no output is paired with the noise, is harder, and existing methods first turn it into a problem that has a target or a likelihood: distillation from a pretrained diffusion model, which supplies noise–sample pairs and reduces generation to regression[73]; an invertible fixed-point map, which gives an exact likelihood as in normalizing flows[121]; a fixed-point layer inside the denoiser of a diffusion model, trained from scratch with the denoising loss of Section4.3[12]; and Equilibrium Matching, which learns a time-independent gradient field whose descent from noise reaches the data[186].

Equilibrium Matching is the closest to a DEQ trained without a teacher, since its sampler is exactly the fixed-point iteration of Equation92with the energy-descent layerfθ​(𝒛)=𝒛−η​∇𝒛Eθ​(𝒛)f_{\theta}({\bm{z}})={\bm{z}}-\eta\nabla_{\bm{z}}E_{\theta}({\bm{z}}). As introduced in Section2.5, it corrupts data as𝒙γ=(1−γ)​𝒙+γ​ϵ{\bm{x}}_{\gamma}=(1-\gamma){\bm{x}}+\gamma\bm{\epsilon}withγ∼𝒰⁡[0,1]\gamma\sim\mathcal{U}[0,1]andϵ∼𝒩⁡(0,I)\bm{\epsilon}\sim\mathcal{N}\left(0,I\right), and regresses the gradient of the energy at𝒙γ{\bm{x}}_{\gamma}onto(ϵ−𝒙)​c​(γ)(\bm{\epsilon}-{\bm{x}})\,c(\gamma), Equation62. Two choices turn this regression into a fixed-point model. First, the network does not receiveγ\gamma, so the minimizer is the single field∇E⋆​(𝒛)=𝔼⁡[(ϵ−𝒙)​c​(γ)∣𝒙γ=𝒛]\nabla E^{\star}({\bm{z}})=\mathbb{E}\left[(\bm{\epsilon}-{\bm{x}})\,c(\gamma)\mid{\bm{x}}_{\gamma}={\bm{z}}\right], averaged over all noise levels that could have produced𝒛{\bm{z}}, rather than a family indexed by time as in diffusion. Second, the magnitude satisfiesc⁡(0)=0c(0)=0, for examplec⁡(γ)=γc(\gamma)=\gamma, so the target vanishes at the data, and data points are equilibria of the field. This holds only approximately: since the field averages over noise levels, a data point is an exact equilibrium only if the corrupted samples that land on it come almost entirely fromγ≈0\gamma\approx 0. In high dimension, the noise level can be inferred from𝒙γ{\bm{x}}_{\gamma}itself, because the norm of the added noise concentrates, so the approximation is accurate, but it can be loose in low dimension. Samples are generated by iterating

𝒛k+1=𝒛k−η​∇𝒛Eθ​(𝒛k),𝒛0∼𝒩⁡(0,I),{\bm{z}}_{k+1}={\bm{z}}_{k}-\eta\,\nabla_{\bm{z}}E_{\theta}({\bm{z}}_{k}),\qquad{\bm{z}}_{0}\sim\mathcal{N}\left(0,I\right),(95)until the gradient is small, that is, until a fixed point is reached; the step size and the number of steps can be adapted at sampling time, and accelerated methods such as Nesterov’s can be used. Training needs only data and noise, with no pretrained model and no unrolled trajectory.

Connection to EBMs.

Choose the layer to be one step of gradient descent on an energy,fθ​(𝒛,𝒙)=𝒛−η​∇𝒛Eθ​(𝒙,𝒛)f_{\theta}({\bm{z}},{\bm{x}})={\bm{z}}-\eta\nabla_{\bm{z}}E_{\theta}({\bm{x}},{\bm{z}}). Its fixed points are exactly the stationary points of the energy,∇𝒛Eθ​(𝒙,𝒛⋆)=0\nabla_{\bm{z}}E_{\theta}({\bm{x}},{\bm{z}}^{\star})=0, so the forward pass of the DEQ is energy minimization, as in Section2.4, and Equation93differentiates through the minimizer without unrolling it. This is the exact counterpart of the unrolled training of end-to-end SPENs in Section3.2and of IREM in Section2.5, which backpropagate through a fixed number of minimization steps. The converse does not hold: a general layerfθf_{\theta}is not the gradient of any scalar function, because the Jacobian of a gradient field is symmetric while that of a general layer is not. A general DEQ therefore computes an equilibrium that is not the minimum of any energy, and its fixed point may not exist or be unique. Monotone operator equilibrium networks[191]restrict the layer so that a unique fixed point is guaranteed, and the modern Hopfield networks of Section4.4are an instance in which the update does descend an explicit energy.

4.6Autoregressive Models as Approximate Ancestral Samplers

Autoregressive models can be viewed as another reparameterization of an EBM from the sampler’s point of view, in the spirit of the energy-inspired models of Section4.4. Instead of parameterizing a global energy and then designing a sampler for it, the parameterization follows ancestral sampling: each step models the conditional distribution of one variable given the ones already generated, and the joint distribution is the one induced by a single sweep in a fixed order.

Fixed-Order Factorization of an EBM.

For𝒙=(x1,…,xd){\bm{x}}=(x_{1},\ldots,x_{d})with eachxix_{i}in a finite vocabulary𝒱\mathcal{V}, any EBM Equation1factorizes exactly in a fixed order by the chain rule,

pθ​(𝒙)=∏i=1dpθ​(xi∣𝒙<i),pθ​(xi∣𝒙<i)=∑𝒙>iexp⁡(−Eθ​(𝒙))∑xi,𝒙>iexp⁡(−Eθ​(𝒙)).p_{\theta}({\bm{x}})=\prod_{i=1}^{d}p_{\theta}(x_{i}\mid{\bm{x}}_{<i}),\qquad p_{\theta}(x_{i}\mid{\bm{x}}_{<i})=\frac{\sum_{{\bm{x}}_{>i}}\exp\left(-E_{\theta}({\bm{x}})\right)}{\sum_{x_{i},\,{\bm{x}}_{>i}}\exp\left(-E_{\theta}({\bm{x}})\right)}.(96)Drawingx1x_{1}, thenx2x_{2}givenx1x_{1}, and so on, is ancestral sampling: each variable is drawn given the ones already visited, with the unvisited ones marginalized out, and this single pass returns an exact sample. Unlike a Gibbs sweep (Section2.4), which conditions on the current values of all other variables and revisits them, it draws each variable once. For a general EBM, however, the sum over𝒙>i{\bm{x}}_{>i}is as intractable asZθZ_{\theta}itself. Autoregressive models reparameterize exactly this sum: they model it directly with a networkeθe_{\theta},

∑𝒙>iexp⁡(−Eθ​(𝒙))≈exp⁡(−eθ​(xi,𝒙<i)),\sum_{{\bm{x}}_{>i}}\exp\left(-E_{\theta}({\bm{x}})\right)\;\approx\;\exp\left(-e_{\theta}(x_{i};{\bm{x}}_{<i})\right),(97)which turns the exact conditional in Equation96into

pθ​(xi=v∣𝒙<i)=exp⁡(−eθ​(v,𝒙<i))∑v′∈𝒱exp⁡(−eθ​(v′,𝒙<i)).p_{\theta}(x_{i}=v\mid{\bm{x}}_{<i})=\frac{\exp\left(-e_{\theta}(v;{\bm{x}}_{<i})\right)}{\sum_{v^{\prime}\in\mathcal{V}}\exp\left(-e_{\theta}(v^{\prime};{\bm{x}}_{<i})\right)}.(98)The marginalization over the unvisited variables is never computed; it is absorbed intoeθe_{\theta}, which plays the role of the free energy of𝒙⩽i{\bm{x}}_{\leqslant i}after𝒙>i{\bm{x}}_{>i}is summed out. What remains is a normalization over the|𝒱|\left|\mathcal{V}\right|values of a single variable, with−eθ​(⋅,𝒙<i)-e_{\theta}(\cdot;{\bm{x}}_{<i})as the logits,i.e., the multi-class logistic regression of Section3. An autoregressive model is therefore ancestral sampling of Equation96with its intractable conditionals replaced by learned ones. NADE[177]gives a concrete instance: its forward pass is a single pass of mean-field inference that approximates the conditionalsp⁡(xi∣𝒙<i)p(x_{i}\mid{\bm{x}}_{<i})of an RBM, with the unvisited variables initialized to zero rather than summed out, and its weight sharing is inherited from the RBM.

Exact Learning.

The same factorization makes learning exact: maximum likelihood decomposes into a sum of per-step cross-entropies,

ℒ⁡(θ)=−𝔼𝒙∼pd​[∑i=1dlog⁡pθ​(xi∣𝒙<i)],\mathcal{L}(\theta)=-\mathbb{E}_{{\bm{x}}\sim p_{d}}\left[\sum_{i=1}^{d}\log p_{\theta}(x_{i}\mid{\bm{x}}_{<i})\right],(99)each of which is the exact maximum likelihood of a conditional EBM Equation98, and all of which can be computed in parallel from a data sequence.

Relation to Pseudolikelihood.

Pseudolikelihood Equation50is the closest learning method for EBMs, and comparing the two shows what the reparameterization changes. Both fit single-variable conditionals that are softmaxes over𝒱\mathcal{V}, and both are tractable for the same reason: only the normalization of one variable over|𝒱|\left|\mathcal{V}\right|values is needed. They differ in the conditioning set (Figure5). Pseudolikelihood fits the full conditionalspθ​(xj∣𝒙−j)p_{\theta}(x_{j}\mid{\bm{x}}_{-j}), the steps of the Gibbs sampler of Section2.4, which can be computed fromEθE_{\theta}in closed form because nothing is summed out. An autoregressive model fits the chain-rule conditionalspθ​(xi∣𝒙<i)p_{\theta}(x_{i}\mid{\bm{x}}_{<i}), the steps of ancestral sampling in Equation96, which require summing out𝒙>i{\bm{x}}_{>i}and are therefore reparameterized byeθe_{\theta}. This single difference leads to opposite trade-offs:

Figure 5:Illustration of different conditioning sets.Pseudolikelihood predicts one token from all the others; an autoregressive model predicts the next token from the prefix, and the remaining tokens are not yet generated; BERT predicts a fixed fraction of masked tokens; masked diffusion predicts the masked tokens at every masking leveltt, and averaging overttgives a bound on the likelihood.- •Objective.By the chain rule, Equation99is exactly the negativelog\log-likelihood, so autoregressive training is exact MLE. The sum of full conditionals in Equation50is not a likelihood. In the ordering view of Section2.5, pseudolikelihood keeps only the last term of every ordering, whereas an autoregressive model keeps all the terms of one fixed ordering.

  • •Energy.Pseudolikelihood keeps the global energy: all its conditionals are derived from a singleEθE_{\theta}, which it estimates consistently[21]. An autoregressive model gives the global energy up, as discussed below.
  • •Sampling.The full conditionals learned by pseudolikelihood do not produce a sample in one pass, and still require many Gibbs sweeps. The chain-rule conditionals do: one ordered pass from the empty state returns an exact sample.

In the language of Section2.6, pseudolikelihood corresponds to a single Gibbs step started at the data, while an autoregressive model corresponds to ancestral sampling from the empty state. Masked discrete diffusion, discussed next, lies between the two: it hides a random subset of the variables, ranging from a single one, as in pseudolikelihood, to all of them, as in the first step of an autoregressive pass.

Connection to Discrete Diffusion.

The order of the sweep is a choice. Averaging Equation99over random orders gives an any-order autoregressive model[178,92], and, as discussed with pseudolikelihood in Section2.5, the masked discrete diffusion objective Equation51is equivalent to it[136]. Masked diffusion models are therefore autoregressive samplers whose order is random and which may reveal several variables per step. Revealing several variables at once, from conditionals predicted independently given the same context, trades the exactness of a sequential sweep for parallel generation, and, as noted there, learned conditionals that are parameterized directly need not be consistent with a single joint distribution, which the autoregressive factorization Equation96guarantees.

The Price of the Reparameterization.

The reparameterization Equation97trades the energy for the sampler. On the gain side, sampling takes a single exact pass of Equation98with no burn-in or mixing, and learning is exact maximum likelihood Equation99, since each step only requires a normalization over|𝒱|\left|\mathcal{V}\right|values. On the cost side,eθe_{\theta}is no longer tied to a global energy. In Equation96, all conditionals are derived from a singleEθE_{\theta}, whereas an autoregressive model approximates each marginalized sum separately, so in general the parameters of an underlying EBM cannot be recovered from it. Moreover, summing out𝒙>i{\bm{x}}_{>i}couples variables thatEθE_{\theta}does not couple directly: even whenEθE_{\theta}is simple, such as a pairwise MRF with few parameters, the sums∑𝒙>iexp⁡(−Eθ​(𝒙))\sum_{{\bm{x}}_{>i}}\exp\left(-E_{\theta}({\bm{x}})\right)are generally complex functions of the whole prefix𝒙<i{\bm{x}}_{<i}, and they change with the chosen order. Approximating them byexp⁡(−eθ)\exp\left(-e_{\theta}\right)therefore requires a far more flexibleeθe_{\theta}than the energy it replaces, and the compact structure ofEθE_{\theta}is lost.

Large Language Models (LLMs).

LLMs are the setting in which this reparameterization fits best, since both of its costs are naturally mitigated. First, the order is given. Text is a sequence, and the left-to-right order in which it is written and read is a natural choice for the fixed order in Equation96, so no ordering has to be chosen or learned[20]. Second, the marginalized sums in Equation97are modeled by a highly flexible network. A Transformer decoder[180]computes−eθ​(⋅,𝒙<i)-e_{\theta}(\cdot;{\bm{x}}_{<i})as the logits over the token vocabulary from the entire prefix, which provides exactly the flexibility over the whole context that the approximation requires. With causal masking, allddconditionals in Equation99are computed in one forward pass over a training sequence, so learning remains exact maximum likelihood at scale[140,24], and generation is ancestral sampling, one token at a time.

5Representation Learning

So far, the energy itself has been the object of interest: in Section3it scores outputs for prediction, and in Section4it defines the distribution to sample from. In representation learning, the energy becomes a means rather than an end. The goal is a feature mapϕθ​(𝒙)\phi_{\theta}({\bm{x}})that is useful for downstream tasks, and the energy is the pretext through which it is learned:ϕθ\phi_{\theta}is placed inside an energy defined on a self-supervised task, such as matching two views of the same input, predicting the masked parts of an input, or denoising a corrupted input, and the energy is trained with one of the methods of Section2.5. After training, the energy is discarded andϕθ\phi_{\theta}is kept. From this view, self-supervised methods differ mainly in two choices, the structure of the energy and the learning method, and the learning methods they use are precisely those that avoid sampling from the model.

5.1Contrastive Representation Learning

FollowingDai et al. [35], contrastive methods can be read as learning a single conditional EBM between two related variables. Let(𝒙,𝒚)∼p⁡(𝒙,𝒚)({\bm{x}},{\bm{y}})\sim p({\bm{x}},{\bm{y}})be a positive pair, such as two augmented views of the same image, or an image and its caption, and letϕθ\phi_{\theta}andψθ\psi_{\theta}be the encoders of the two sides, which share parameters when𝒙{\bm{x}}and𝒚{\bm{y}}come from the same modality. The model is

pθ​(𝒙,𝒚)p⁡(𝒙)​p​(𝒚)∝exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚)),\displaystyle\frac{p_{\theta}({\bm{x}},{\bm{y}})}{p({\bm{x}})\,p({\bm{y}})}\propto\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right),(100)pθ(𝒚∣𝒙)=p⁡(𝒚)​exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))Zθ​(𝒙),Zθ(𝒙)=𝔼p⁡(𝒚)[exp(ϕθ(𝒙)⊤ψθ(𝒚))],\displaystyle p_{\theta}({\bm{y}}\mid{\bm{x}})=\frac{p({\bm{y}})\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)}{Z_{\theta}({\bm{x}})},\qquad Z_{\theta}({\bm{x}})=\mathbb{E}_{p({\bm{y}})}\left[\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)\right],pθ(𝒙∣𝒚)=p⁡(𝒙)​exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))Zθ​(𝒚),Zθ(𝒚)=𝔼p⁡(𝒙)[exp(ϕθ(𝒙)⊤ψθ(𝒚))],\displaystyle p_{\theta}({\bm{x}}\mid{\bm{y}})=\frac{p({\bm{x}})\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)}{Z_{\theta}({\bm{y}})},\qquad Z_{\theta}({\bm{y}})=\mathbb{E}_{p({\bm{x}})}\left[\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)\right],where the two conditionals have their own partition functions. This is an EBM with the bilinear energyEθ​(𝒙,𝒚)=−ϕθ​(𝒙)⊤​ψθ​(𝒚)E_{\theta}({\bm{x}},{\bm{y}})=-\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})relative to the base measurep⁡(𝒚)p({\bm{y}}), and it models the pointwise mutual information between the two sides. The representation lives inside the energy, andDai et al. [35]show that it is sufficient for downstream prediction. The structure of Equation100makes it convenient to learn: the base measure is the marginalp⁡(𝒚)p({\bm{y}}), which is exactly the distribution of the other samples in a batch, so the natural noise distribution for NCE ispn=p⁡(𝒚)p_{n}=p({\bm{y}}), and thelog⁡pn\log p_{n}terms in Equation43and Equation46cancel against the base measure, leaving the inner product as the logit. The remaining difficulty is the partition functionsZθ​(𝒙)Z_{\theta}({\bm{x}})andZθ​(𝒚)Z_{\theta}({\bm{y}}), which are intractable and differ for every input, and existing methods differ mainly in how they handle them.

SimCLR: Ranking NCE within One Modality.

SimCLR[30]takes𝒙{\bm{x}}and𝒚{\bm{y}}to be two augmentations of the same input, with a shared encoderϕθ=ψθ\phi_{\theta}=\psi_{\theta}. Applying ranking NCE Equation47topθ​(𝒚∣𝒙)p_{\theta}({\bm{y}}\mid{\bm{x}}), with the otherKKsamples in the batch as the noise, gives

ℒSimCLR(θ)=−𝔼[ϕθ(𝒙)⊤ϕθ(𝒚0)−log∑k=0Kexp(ϕθ(𝒙)⊤ϕθ(𝒚k))],\mathcal{L}_{\text{SimCLR}}(\theta)=-\mathbb{E}\left[\phi_{\theta}({\bm{x}})^{\top}\phi_{\theta}({\bm{y}}_{0})-\log\sum_{k=0}^{K}\exp\left(\phi_{\theta}({\bm{x}})^{\top}\phi_{\theta}({\bm{y}}_{k})\right)\right],(101)which is the InfoNCE objective[179]. Normalizing the features,ϕθ​(𝒙)/‖ϕθ​(𝒙)‖2\phi_{\theta}({\bm{x}})/\left\|\phi_{\theta}({\bm{x}})\right\|_{2}, and dividing the inner product by a temperature recovers SimCLR exactly[35]. Ranking NCE needs no partition function, sinceZθ​(𝒙)Z_{\theta}({\bm{x}})cancels within the softmax, but its gradient Equation48is a self-normalized importance sampling estimate whose bias decreases only asKKgrows, which is why these methods depend on large batches.

CLIP: Ranking NCE across Modalities.

CLIP[139]applies the same estimator to an image𝒙{\bm{x}}and its caption𝒚{\bm{y}}with separate encoders, and fits both conditionals of Equation100,

ℒCLIP​(θ)=\displaystyle\mathcal{L}_{\text{CLIP}}(\theta)=−𝔼[ϕθ(𝒙0)⊤ψθ(𝒚0)−log∑k=0Kexp(ϕθ(𝒙0)⊤ψθ(𝒚k))]\displaystyle-\mathbb{E}\left[\phi_{\theta}({\bm{x}}_{0})^{\top}\psi_{\theta}({\bm{y}}_{0})-\log\sum_{k=0}^{K}\exp\left(\phi_{\theta}({\bm{x}}_{0})^{\top}\psi_{\theta}({\bm{y}}_{k})\right)\right](102)−𝔼[ϕθ(𝒙0)⊤ψθ(𝒚0)−log∑k=0Kexp(ϕθ(𝒙k)⊤ψθ(𝒚0))],\displaystyle-\mathbb{E}\left[\phi_{\theta}({\bm{x}}_{0})^{\top}\psi_{\theta}({\bm{y}}_{0})-\log\sum_{k=0}^{K}\exp\left(\phi_{\theta}({\bm{x}}_{k})^{\top}\psi_{\theta}({\bm{y}}_{0})\right)\right],where the first term is ranking NCE forpθ​(𝒚∣𝒙0)p_{\theta}({\bm{y}}\mid{\bm{x}}_{0}), which identifies the caption𝒚0{\bm{y}}_{0}of the image𝒙0{\bm{x}}_{0}among theK+1K+1captions in the batch with the other captions drawn from the noisep⁡(𝒚)p({\bm{y}}), and the second term is ranking NCE forpθ​(𝒙∣𝒚0)p_{\theta}({\bm{x}}\mid{\bm{y}}_{0}), which identifies the image𝒙0{\bm{x}}_{0}of the caption𝒚0{\bm{y}}_{0}among theK+1K+1images with the other images drawn from the noisep⁡(𝒙)p({\bm{x}}). It inherits the large-batch requirement of ranking NCE.

Figure 6:Contrastive methods as estimators of the same EBM.Each panel shows the scoresϕθ​(𝒙i)⊤​ψθ​(𝒚j)\phi_{\theta}({\bm{x}}_{i})^{\top}\psi_{\theta}({\bm{y}}_{j})of a batch for the bilinear EBM Equation100, with the positive pairs on the diagonal. The methods differ in what estimates the partition functions: SimCLR sums each row (Σ\Sigma), and CLIP also each column; SigLIP classifies every pair separately, as positive or negative, with one learned biasbbshared by all pairs; AmorLIP predicts the partition functions (Z^\hat{Z}) from the representations instead of summing over the batch.

SigLIP: Binary NCE across Modalities.

SigLIP[200]replaces the softmax by a sigmoid on each pair. This is binary NCE Equation44with positive pairs drawn fromp⁡(𝒙,𝒚)p({\bm{x}},{\bm{y}})as data and mismatched pairs drawn fromp⁡(𝒙)​p​(𝒚)p({\bm{x}})p({\bm{y}})as noise,

ℒSigLIP​(θ,b)=−𝔼p⁡(𝒙,𝒚)​[log⁡sigm⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚)+b)]−𝔼p⁡(𝒙)​p​(𝒚)​[log⁡(1−sigm⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚)+b))],\mathcal{L}_{\text{SigLIP}}(\theta,b)=-\mathbb{E}_{p({\bm{x}},{\bm{y}})}\left[\log\mathrm{sigm}\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})+b\right)\right]-\mathbb{E}_{p({\bm{x}})p({\bm{y}})}\left[\log\left(1-\mathrm{sigm}\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})+b\right)\right)\right],(103)SigLIP thus learns the EBM Equation100through its joint distribution, which has a single partition function,

pθ​(𝒙,𝒚)=p⁡(𝒙)​p​(𝒚)​exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))Zθ,Zθ=𝔼p⁡(𝒙)​p​(𝒚)​[exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))].p_{\theta}({\bm{x}},{\bm{y}})=\frac{p({\bm{x}})\,p({\bm{y}})\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)}{Z_{\theta}},\qquad Z_{\theta}=\mathbb{E}_{p({\bm{x}})p({\bm{y}})}\left[\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)\right].(104)The biasb=−log⁡Zθb=-\log Z_{\theta}is thelog\log-partition constant−c-cof binary NCE in Equation42, so the objective is consistent for the joint model, and the conditionals with their partition functionsZθ​(𝒙)Z_{\theta}({\bm{x}})andZθ​(𝒚)Z_{\theta}({\bm{y}})follow from it without being estimated. Each pair contributes a separate term, so the gradient is unbiased for any batch size, which is the practical advantage of SigLIP over the ranking NCE of CLIP.

AmorLIP: Maximum Likelihood with Amortized Partition Functions.

Instead of an NCE surrogate, one can fit both conditionals of Equation100by maximum likelihood,

maxθ⁡2​𝔼p⁡(𝒙,𝒚)​[ϕθ​(𝒙)⊤​ψθ​(𝒚)]−𝔼p⁡(𝒙)​[log⁡Zθ​(𝒙)]−𝔼p⁡(𝒚)​[log⁡Zθ​(𝒚)],\max_{\theta}\;2\,\mathbb{E}_{p({\bm{x}},{\bm{y}})}\left[\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right]-\mathbb{E}_{p({\bm{x}})}\left[\log Z_{\theta}({\bm{x}})\right]-\mathbb{E}_{p({\bm{y}})}\left[\log Z_{\theta}({\bm{y}})\right],(105)which has the same gradient as the surrogate objective

maxθ⁡2​𝔼p⁡(𝒙,𝒚)​[ϕθ​(𝒙)⊤​ψθ​(𝒚)]−𝔼p⁡(𝒙)​p​(𝒚)​[exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))sg​(Zθ​(𝒙))]−𝔼p⁡(𝒙)​p​(𝒚)​[exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))sg​(Zθ​(𝒚))],\max_{\theta}\;2\,\mathbb{E}_{p({\bm{x}},{\bm{y}})}\left[\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right]-\mathbb{E}_{p({\bm{x}})p({\bm{y}})}\left[\frac{\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)}{\texttt{sg}\left(Z_{\theta}({\bm{x}})\right)}\right]-\mathbb{E}_{p({\bm{x}})p({\bm{y}})}\left[\frac{\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)}{\texttt{sg}\left(Z_{\theta}({\bm{y}})\right)}\right],(106)withsgthe stop-gradient operator. Given the values ofZθ​(𝒙)Z_{\theta}({\bm{x}})andZθ​(𝒚)Z_{\theta}({\bm{y}}), every term is an expectation that can be estimated without bias from small batches. The difficulty is that these partition functions are intractable and change with every input. Ranking NCE estimates them by the batch sum, which is biased for small batches, and binary NCE avoids them by fitting the joint model with a single constant. AmorLIP[166]instead amortizes them: sinceZθ​(𝒙)=𝔼p⁡(𝒚)​[exp⁡(ϕθ​(𝒙)⊤​ψθ​(𝒚))]Z_{\theta}({\bm{x}})=\mathbb{E}_{p({\bm{y}})}\left[\exp\left(\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})\right)\right]depends on𝒙{\bm{x}}only throughϕθ​(𝒙)\phi_{\theta}({\bm{x}}), it can be fitted by a lightweight network on top of the learned representation, trained with a variational objective alongside the encoders, and plugged into Equation106. This keeps the consistency of maximum likelihood while removing the dependence on large batches.

In summary, SimCLR, CLIP, SigLIP and AmorLIP learn the same EBM Equation100and differ only in the learning method of Section2.5: ranking NCE, which cancels the partition function within the batch; binary NCE, which fits the joint model with a single constant; and maximum likelihood, which estimates it with an amortized model (Figure6). The trade-offs among them are those of the estimators, between the batch size, the consistency of the estimator, and the cost of modeling the partition function.

Fixed-Point Learning of EBM Representation.

The methods above fit both sides of the energy Equation100jointly.Dai et al. [35]show that the representation can also be learned by a fixed-point iteration, in the spirit of power iteration for spectral decomposition, in which one side of the energy is frozen at the previous iterate and only the other side is updated. With a shared encoder as in SimCLR, theℓ\ell-th iteration fits the conditional EBMpθ​(𝒚∣𝒙)∝p⁡(𝒚)​exp⁡(ϕθ​(𝒙)⊤​ϕ(ℓ)​(𝒚))p_{\theta}({\bm{y}}\mid{\bm{x}})\propto p({\bm{y}})\exp\left(\phi_{\theta}({\bm{x}})^{\top}\phi^{(\ell)}({\bm{y}})\right), in which the representationϕ(ℓ)\phi^{(\ell)}of the target is fixed, by ranking NCE,

ϕ(ℓ+1)=argminϕ−𝔼[ϕ(𝒙)⊤ϕ(ℓ)(𝒚0)−log∑k=0Kexp(ϕ(𝒙)⊤ϕ(ℓ)(𝒚k))],\phi^{(\ell+1)}=\mathop{\mathrm{argmin}}_{\phi}\;-\mathbb{E}\left[\phi({\bm{x}})^{\top}\phi^{(\ell)}({\bm{y}}_{0})-\log\sum_{k=0}^{K}\exp\left(\phi({\bm{x}})^{\top}\phi^{(\ell)}({\bm{y}}_{k})\right)\right],(107)and a fixed pointϕ(ℓ+1)=ϕ(ℓ)\phi^{(\ell+1)}=\phi^{(\ell)}is a representation consistent with the EBM. MoCo[86]is a practical implementation of this iteration. It approximates theargmin\mathop{\mathrm{argmin}}by a few stochastic gradient steps on the query encoderϕ\phi, maintains the frozen key encoderϕ(ℓ)\phi^{(\ell)}as an exponential moving average of the query encoder, and draws the negatives𝒚k{\bm{y}}_{k}from a queue of keys computed in recent iterations. Since the keys are produced by a slowly changingϕ(ℓ)\phi^{(\ell)}that receives no gradient, the stale keys in the queue remain consistent with the current iterate, which provides many negatives without large batches.

5.2Word2vec

Word2vec[126,127]is an early and simple instance of the same construction, in which the encoders are lookup tables. It comes in two variants, which correspond to Section5.1and Section5.3, respectively.

Skip-Gram: Binary NCE for a Pairwise EBM.

Let(w,c)(w,c)be a word and a word in its context window. Skip-gram models their co-occurrence with the bilinear EBM Equation100[35],

pθ​(w,c)p⁡(w)​pn​(c)∝exp⁡(𝒖w⊤​𝒗c),\frac{p_{\theta}(w,c)}{p(w)\,p_{n}(c)}\propto\exp\left(\bm{u}_{w}^{\top}\bm{v}_{c}\right),(108)where𝒖w\bm{u}_{w}and𝒗c\bm{v}_{c}are the embeddings ofwwas a word and ofccas a context, andpn​(c)p_{n}(c)is the noise distribution over contexts used below; withpn​(c)=p​(c)p_{n}(c)=p(c), the ratio is the pointwise mutual information. Skip-gram with negative sampling fits Equation108by binary NCE Equation44, with observed pairs as data andkkpairs drawn fromp⁡(w)​pn​(c)p(w)\,p_{n}(c)as noise,

ℒSGNS​(θ)=−𝔼p⁡(w,c)​[log⁡sigm⁡(𝒖w⊤​𝒗c)]−k​𝔼p⁡(w)​pn​(c)​[log⁡sigm⁡(−𝒖w⊤​𝒗c)],\mathcal{L}_{\text{SGNS}}(\theta)=-\mathbb{E}_{p(w,c)}\left[\log\mathrm{sigm}\left(\bm{u}_{w}^{\top}\bm{v}_{c}\right)\right]-k\,\mathbb{E}_{p(w)\,p_{n}(c)}\left[\log\mathrm{sigm}\left(-\bm{u}_{w}^{\top}\bm{v}_{c}\right)\right],(109)where the noise distribution over contextspn​(c)p_{n}(c)is the unigram distribution raised to the power3/43/4and renormalized. Compared with Equation43, the logit is the inner product alone, so the biasb=−c−log⁡νb=-c-\log\nuis fixed at zero rather than learned as in SigLIP. Withν=k\nu=k, the optimal classifier then gives

𝒖w⋆⁣⊤​𝒗c⋆=log⁡p⁡(w,c)p⁡(w)​pn​(c)−log⁡k,\bm{u}_{w}^{\star\top}\bm{v}^{\star}_{c}=\log\frac{p(w,c)}{p(w)\,p_{n}(c)}-\log k,(110)which is the shifted pointwise mutual information that skip-gram is known to factorize implicitly[110]. In the EBM view, the shift−log⁡k-\log kis thelog\log-partition constant that binary NCE would otherwise have learned.

CBOW: Masked Prediction of a Single Word.

The continuous bag-of-words model predicts a word from the average of its context embeddings,

pθ​(w∣𝒙ctx)=exp⁡(𝒉​(𝒙ctx)⊤​𝒖w)∑w′∈𝒱exp⁡(𝒉​(𝒙ctx)⊤​𝒖w′),𝒉⁡(𝒙ctx)=1|𝒙ctx|​∑c∈𝒙ctx𝒗c.p_{\theta}(w\mid{\bm{x}}_{\text{ctx}})=\frac{\exp\left(\bm{h}({\bm{x}}_{\text{ctx}})^{\top}\bm{u}_{w}\right)}{\sum_{w^{\prime}\in\mathcal{V}}\exp\left(\bm{h}({\bm{x}}_{\text{ctx}})^{\top}\bm{u}_{w^{\prime}}\right)},\qquad\bm{h}({\bm{x}}_{\text{ctx}})=\frac{1}{\left|{\bm{x}}_{\text{ctx}}\right|}\sum_{c\in{\bm{x}}_{\text{ctx}}}\bm{v}_{c}.(111)This is a special case of the masked prediction EBM of BERT, discussed next in Section5.3, with a single hidden position and a context window as the visible tokens, and with the contextual encoder replaced by an average of embeddings. With one hidden position, it is the pseudolikelihood Equation50of the window. Since the partition function sums over the whole vocabulary, which was costly at the time, CBOW is trained in practice with the same negative sampling or with a hierarchical softmax[127].

5.3BERT

Masked language modeling, as in BERT[44], learns an EBM of the same bilinear form as Equation100, now between a corrupted sequence and the clean one. Given a sequence𝒙=(x1,…,xd){\bm{x}}=(x_{1},\ldots,x_{d})over the vocabulary𝒱\mathcal{V}, let𝒙~\tilde{\bm{x}}be the corrupted sequence in which a random subsetMMof the positions is replaced by[MASK]. BERT models the denoising distribution of the hidden tokens𝒙M{\bm{x}}_{M}given𝒙~\tilde{\bm{x}}as an EBM with the potential

pθ(𝒙M∣𝒙~)=exp⁡(−Eθ​(𝒙M,𝒙~))Zθ​(𝒙~),Eθ(𝒙M;𝒙~)=−∑j∈M𝒉θ,j(𝒙~)⊤𝒆xj=−ϕθ(𝒙~)⊤ψ(𝒙M),p_{\theta}({\bm{x}}_{M}\mid\tilde{\bm{x}})=\frac{\exp\left(-E_{\theta}({\bm{x}}_{M};\tilde{\bm{x}})\right)}{Z_{\theta}(\tilde{\bm{x}})},\qquad E_{\theta}({\bm{x}}_{M};\tilde{\bm{x}})=-\sum_{j\in M}\bm{h}_{\theta,j}(\tilde{\bm{x}})^{\top}\bm{e}_{x_{j}}=-\phi_{\theta}(\tilde{\bm{x}})^{\top}\psi({\bm{x}}_{M}),(112)where𝒉θ,j​(𝒙~)\bm{h}_{\theta,j}(\tilde{\bm{x}})is the contextual representation that a bidirectional Transformer computes at positionjj,𝒆v\bm{e}_{v}is the embedding of tokenvv, andϕθ​(𝒙~)=(𝒉θ,j​(𝒙~))j∈M\phi_{\theta}(\tilde{\bm{x}})=(\bm{h}_{\theta,j}(\tilde{\bm{x}}))_{j\in M}andψ⁡(𝒙M)=(𝒆xj)j∈M\psi({\bm{x}}_{M})=(\bm{e}_{x_{j}})_{j\in M}stack them over the masked positions. As in Section5.1, the representationϕθ\phi_{\theta}of the corrupted input enters the energy through an inner product with a representation of the target. The same structure appears in the multi-modal spectral representation ofDai et al. [35, Sec. 7.2], where, for discrete variables such as text, the diffusion loss is replaced by the masked diffusion loss, which scores the clean tokens through an inner product with the representation of the corrupted text. Since the potential is a sum over the masked positions, the partition function factorizes,

Zθ​(𝒙~)=∏j∈M∑v∈𝒱exp⁡(𝒉θ,j​(𝒙~)⊤​𝒆v),pθ​(𝒙M∣𝒙~)=∏j∈Mexp⁡(𝒉θ,j​(𝒙~)⊤​𝒆xj)∑v∈𝒱exp⁡(𝒉θ,j​(𝒙~)⊤​𝒆v),Z_{\theta}(\tilde{\bm{x}})=\prod_{j\in M}\sum_{v\in\mathcal{V}}\exp\left(\bm{h}_{\theta,j}(\tilde{\bm{x}})^{\top}\bm{e}_{v}\right),\qquad p_{\theta}({\bm{x}}_{M}\mid\tilde{\bm{x}})=\prod_{j\in M}\frac{\exp\left(\bm{h}_{\theta,j}(\tilde{\bm{x}})^{\top}\bm{e}_{x_{j}}\right)}{\sum_{v\in\mathcal{V}}\exp\left(\bm{h}_{\theta,j}(\tilde{\bm{x}})^{\top}\bm{e}_{v}\right)},(113)so it is a product of|M|\left|M\right|sums over|𝒱|\left|\mathcal{V}\right|values and can be computed exactly. Maximum likelihood of Equation112is therefore exact, and it is precisely the BERT objective,

ℒBERT(θ)=𝔼𝒙∼pd𝔼M∼qt0[−logpθ(𝒙M∣𝒙~)]=𝔼𝒙∼pd𝔼M∼qt0[−∑j∈Mlogpθ(xj∣𝒙~)],\mathcal{L}_{\text{BERT}}(\theta)=\mathbb{E}_{{\bm{x}}\sim p_{d}}\mathbb{E}_{M\sim q_{t_{0}}}\left[-\log p_{\theta}\left({\bm{x}}_{M}\mid\tilde{\bm{x}}\right)\right]=\mathbb{E}_{{\bm{x}}\sim p_{d}}\mathbb{E}_{M\sim q_{t_{0}}}\left[-\sum_{j\in M}\log p_{\theta}\left(x_{j}\mid\tilde{\bm{x}}\right)\right],(114)with a fixed masking ratiot0t_{0}, about15%15\%in BERT. BERT is thus a neural network generalization of word2vec, specifically of CBOW Equation111: it replaces the averaged context embeddings by a deep bidirectional Transformer, and it predicts several masked tokens at once under an independence assumption on the potential, which is a sum of per-position terms, so that the masked tokens are conditionally independent given𝒙~\tilde{\bm{x}}. This assumption is also what makes the partition function Equation113tractable. After training, the energy,i.e., the output layer over𝒆v\bm{e}_{v}, is discarded and the representation𝒉θ\bm{h}_{\theta}is kept.

Connection to Masked Discrete Diffusion and Pseudolikelihood.

Starting from BERT, its masking ratiot0t_{0}connects it to the two objectives related in Section2.5. Shrinking the mask to a single position,|M|=1\left|M\right|=1, turns Equation114into pseudolikelihood Equation50, in which every other token is visible. Averaging Equation114over all ratios with weight1/t1/tturns it into the masked diffusion objective Equation51, which bounds the negativelog\log-likelihood.Austin et al. [9]make the second connection precise: BERT is a one-step discrete diffusion model, whose transition matrix mixes the absorbing state[MASK]with a uniform transition, matching BERT’s practice of replacing some selected tokens by[MASK]and others by random tokens. BERT thus lies between the two: it hides more than one position, so it trains the model to predict tokens whose neighbors are also unknown, which pseudolikelihood never does, but it keeps a single ratio, so it learns the denoiser, and its representation, at one noise level only.

5.4Diffusion Representations

The methods in Section5.1learn the bilinear EBM Equation100by NCE, which needs negative samples and, in its ranking form, large batches. Denoising avoids both. We first derive the classical denoising auto-encoder[182,183]from a joint EBM over the input and a latent variable; the derived model justifies the bilinear structure of Equation100, with the DAE as a conditional EBM of this form. We then present the diffusion spectral representation[158,35]as its conditional extension, learned by score matching.

Denoising Auto-Encoders.

A denoising auto-encoder (DAE) corrupts the input as𝒙~=𝒙+σ​ϵ\tilde{\bm{x}}={\bm{x}}+\sigma\bm{\epsilon}. We derive it by parameterizing the distributionpσp_{\sigma}of the corrupted input with a latent-variable EBMpθp_{\theta}, in which the latent variable𝒉\bm{h}plays the role of the representation,

pσ​(𝒙~)=∫𝒩⁡(𝒙~,𝒙,σ2​I)​pd​(𝒙)​d𝒙,\displaystyle p_{\sigma}(\tilde{\bm{x}})=\int\mathcal{N}\left(\tilde{\bm{x}};{\bm{x}},\sigma^{2}I\right)\,p_{d}({\bm{x}})\,d{\bm{x}},(115)pθ(𝒙~)=1Zθ∑𝒉exp(−Eθ(𝒙~,𝒉))=exp⁡(−Fθ​(𝒙~))Zθ,𝒉θ(𝒙~)=𝔼pθ​(𝒉∣𝒙~)[𝒉],\displaystyle p_{\theta}(\tilde{\bm{x}})=\frac{1}{Z_{\theta}}\sum_{\bm{h}}\exp\left(-E_{\theta}(\tilde{\bm{x}},\bm{h})\right)=\frac{\exp\left(-F_{\theta}(\tilde{\bm{x}})\right)}{Z_{\theta}},\qquad\bm{h}_{\theta}(\tilde{\bm{x}})=\mathbb{E}_{p_{\theta}(\bm{h}\mid\tilde{\bm{x}})}\left[\bm{h}\right],whereFθ(𝒙~)=−log∑𝒉exp(−Eθ(𝒙~,𝒉))F_{\theta}(\tilde{\bm{x}})=-\log\sum_{\bm{h}}\exp\left(-E_{\theta}(\tilde{\bm{x}},\bm{h})\right)is the free energy, the sum becomes an integral for continuous𝒉\bm{h}, and the representation of𝒙~\tilde{\bm{x}}is the posterior mean of the latent. Herepσp_{\sigma}is the data distributionpdp_{d}convolved with the Gaussian corruption, andpθp_{\theta}is its parameterization: the latent-variable form is the modeling assumption, and learning fitspθp_{\theta}topσp_{\sigma}. We fitpθp_{\theta}topσp_{\sigma}by denoising score matching Equation55, which avoids the partition function and needs only the score of the model, an expectation under the posterior of the latent,

−∇𝒙~Fθ​(𝒙~)=−𝔼pθ​(𝒉∣𝒙~)​[∇𝒙~Eθ​(𝒙~,𝒉)].-\nabla_{\tilde{\bm{x}}}F_{\theta}(\tilde{\bm{x}})=-\mathbb{E}_{p_{\theta}(\bm{h}\mid\tilde{\bm{x}})}\left[\nabla_{\tilde{\bm{x}}}E_{\theta}(\tilde{\bm{x}},\bm{h})\right].(116)For a general joint energy, which couples the components of𝒉\bm{h}, this posterior, and hence both the score and the representation, require approximate inference over𝒉\bm{h}; a closed form needs the structure Equation117below.

Closed Form from Linearity in the Latent.

The posterior in Equation116becomes tractable when the energy is linear in𝒉\bm{h}, up to terms that act on each component separately,

Eθ​(𝒙~,𝒉)=Uθ​(𝒙~)−𝒉⊤​gθ​(𝒙~)+∑j=1mVj​(hj),E_{\theta}(\tilde{\bm{x}},\bm{h})=U_{\theta}(\tilde{\bm{x}})-\bm{h}^{\top}g_{\theta}(\tilde{\bm{x}})+\sum_{j=1}^{m}V_{j}(h_{j}),(117)whereVjV_{j}is a fixed base measure for thejj-th component, which may be discrete or continuous. The components of𝒉\bm{h}are then conditionally independent given𝒙~\tilde{\bm{x}}, and each posterior is an exponential family whose natural parameter is the featuregθ,j​(𝒙~)g_{\theta,j}(\tilde{\bm{x}}), withlog\log-partition functionAj(η)=log∫exp(ηhj−Vj(hj))dhjA_{j}(\eta)=\log\int\exp\left(\eta h_{j}-V_{j}(h_{j})\right)\,dh_{j}. The posterior, the representation, and the free energy are therefore available in closed form,

pθ​(𝒉∣𝒙~)=∏j=1mexp⁡(hj​gθ,j​(𝒙~)−Vj​(hj)−Aj​(gθ,j​(𝒙~))),\displaystyle p_{\theta}(\bm{h}\mid\tilde{\bm{x}})=\prod_{j=1}^{m}\exp\left(h_{j}\,g_{\theta,j}(\tilde{\bm{x}})-V_{j}(h_{j})-A_{j}\left(g_{\theta,j}(\tilde{\bm{x}})\right)\right),(118)hθ,j(𝒙~)=Aj′(gθ,j(𝒙~)),Fθ(𝒙~)=Uθ(𝒙~)−∑j=1mAj(gθ,j(𝒙~)),\displaystyle h_{\theta,j}(\tilde{\bm{x}})=A_{j}^{\prime}\left(g_{\theta,j}(\tilde{\bm{x}})\right),\qquad F_{\theta}(\tilde{\bm{x}})=U_{\theta}(\tilde{\bm{x}})-\sum_{j=1}^{m}A_{j}\left(g_{\theta,j}(\tilde{\bm{x}})\right),and the score Equation116is linear in the representation,

−∇𝒙~Fθ​(𝒙~)=−∇𝒙~Uθ​(𝒙~)+∇𝒙~gθ​(𝒙~)⊤​𝒉θ​(𝒙~).-\nabla_{\tilde{\bm{x}}}F_{\theta}(\tilde{\bm{x}})=-\nabla_{\tilde{\bm{x}}}U_{\theta}(\tilde{\bm{x}})+\nabla_{\tilde{\bm{x}}}g_{\theta}(\tilde{\bm{x}})^{\top}\bm{h}_{\theta}(\tilde{\bm{x}}).(119)For binary components,Vj=0V_{j}=0on{0,1}\left\{0,1\right\}, the posterior is Bernoulli,AjA_{j}is the softplus, and the encoder is the sigmoidsigm​(gθ​(𝒙~))\mathrm{sigm}\left(g_{\theta}(\tilde{\bm{x}})\right); for Gaussian components,Vj​(hj)=12​hj2V_{j}(h_{j})=\frac{1}{2}h_{j}^{2}, the posterior is𝒩​(gθ​(𝒙~),I)\mathcal{N}\left(g_{\theta}(\tilde{\bm{x}}),I\right), and the encoder isgθ​(𝒙~)g_{\theta}(\tilde{\bm{x}})itself. This is the structure of exponential-family harmoniums[188]. Closed form requires linearity in𝒉\bm{h}, not in the input: the featuresgθg_{\theta}may be a deep network.

From the Score to the DAE.

Substituting the closed-form score Equation119into denoising score matching Equation55and multiplying by2​σ42\sigma^{4}gives

σ4​𝔼𝒙∼pd,ϵ​[‖−∇𝒙~Fθ​(𝒙~)+𝒙~−𝒙σ2‖22]=𝔼𝒙∼pd,ϵ​[‖rθ​(𝒙~)−𝒙‖22],\displaystyle\sigma^{4}\,\mathbb{E}_{{\bm{x}}\sim p_{d},\,\bm{\epsilon}}\left[\Big\|-\nabla_{\tilde{\bm{x}}}F_{\theta}(\tilde{\bm{x}})+\frac{\tilde{\bm{x}}-{\bm{x}}}{\sigma^{2}}\Big\|_{2}^{2}\right]=\mathbb{E}_{{\bm{x}}\sim p_{d},\,\bm{\epsilon}}\left[\big\|r_{\theta}(\tilde{\bm{x}})-{\bm{x}}\big\|_{2}^{2}\right],(120)rθ​(𝒙~)=𝒙~−σ2​∇𝒙~Uθ​(𝒙~)+σ2​∇𝒙~gθ​(𝒙~)⊤​𝒉θ​(𝒙~),\displaystyle r_{\theta}(\tilde{\bm{x}})=\tilde{\bm{x}}-\sigma^{2}\nabla_{\tilde{\bm{x}}}U_{\theta}(\tilde{\bm{x}})+\sigma^{2}\nabla_{\tilde{\bm{x}}}g_{\theta}(\tilde{\bm{x}})^{\top}\bm{h}_{\theta}(\tilde{\bm{x}}),a reconstruction loss in whichrθr_{\theta}is a decoder that reads out the representation𝒉θ\bm{h}_{\theta}through∇𝒙~gθ​(𝒙~)⊤\nabla_{\tilde{\bm{x}}}g_{\theta}(\tilde{\bm{x}})^{\top}[183]. By Tweedie’s formula Equation83, the optimal reconstruction is the posterior mean𝔼⁡[𝒙∣𝒙~]\mathbb{E}\left[{\bm{x}}\mid\tilde{\bm{x}}\right], attained whenpθ=pσp_{\theta}=p_{\sigma}. A nonlineargθg_{\theta}gives a deep DAE, whose decoder matrix depends on the input. The classical DAE is the simplest case: with binary latents, a linear projectiongθ​(𝒙~)=W​𝒙~+𝒃g_{\theta}(\tilde{\bm{x}})=W\tilde{\bm{x}}+\bm{b}, and a quadraticUθ​(𝒙~)=1σ2​(12​‖𝒙~‖22−𝒄⊤​𝒙~)U_{\theta}(\tilde{\bm{x}})=\frac{1}{\sigma^{2}}\left(\frac{1}{2}\left\|\tilde{\bm{x}}\right\|_{2}^{2}-\bm{c}^{\top}\tilde{\bm{x}}\right), the joint energy is the Gaussian–binary RBM of Section2, and the encoder and the reconstruction become

𝒉θ​(𝒙~)=sigm⁡(W​𝒙~+𝒃),rθ​(𝒙~)=𝒄+σ2​W⊤​𝒉θ​(𝒙~),\bm{h}_{\theta}(\tilde{\bm{x}})=\mathrm{sigm}\left(W\tilde{\bm{x}}+\bm{b}\right),\qquad r_{\theta}(\tilde{\bm{x}})=\bm{c}+\sigma^{2}W^{\top}\bm{h}_{\theta}(\tilde{\bm{x}}),(121)a sigmoid encoder and a linear decoder whose weights are tied to the encoder up to the factorσ2\sigma^{2}[182,183]. With Gaussian latents instead, the same construction gives a linear encoder𝒉θ​(𝒙~)=W​𝒙~+𝒃\bm{h}_{\theta}(\tilde{\bm{x}})=W\tilde{\bm{x}}+\bm{b},i.e., a linear DAE.

DAE as a Conditional EBM.

The DAE can be derived as maximum likelihood for a Gaussian model of the denoising posterior whose mean is the reconstructionrθ​(𝒙~)r_{\theta}(\tilde{\bm{x}}), the model of𝔼⁡[𝒙∣𝒙~]\mathbb{E}\left[{\bm{x}}\mid\tilde{\bm{x}}\right]in Equation120,

pθ​(𝒙∣𝒙~)=𝒩⁡(𝒙,rθ​(𝒙~),I)\displaystyle p_{\theta}({\bm{x}}\mid\tilde{\bm{x}})=\mathcal{N}\left({\bm{x}};\,r_{\theta}(\tilde{\bm{x}}),I\right)∝e−12​‖𝒙‖22​exp⁡(rθ​(𝒙~)⊤​𝒙)\displaystyle\propto e^{-\frac{1}{2}\left\|{\bm{x}}\right\|_{2}^{2}}\exp\left(r_{\theta}(\tilde{\bm{x}})^{\top}{\bm{x}}\right)(122)∝e−12​‖𝒙‖22+𝒄⊤​𝒙exp(𝒉θ(𝒙~)⊤ψθ(𝒙)),ψθ(𝒙)=σ2W𝒙,\displaystyle\propto e^{-\frac{1}{2}\left\|{\bm{x}}\right\|_{2}^{2}+\bm{c}^{\top}{\bm{x}}}\exp\left(\bm{h}_{\theta}(\tilde{\bm{x}})^{\top}\psi_{\theta}({\bm{x}})\right),\qquad\psi_{\theta}({\bm{x}})=\sigma^{2}W{\bm{x}},whose negativelog\log-likelihood recovers the original DAE reconstruction loss[182],

ℒDAE​(θ)=−𝔼𝒙∼pd,ϵ​[log⁡pθ​(𝒙∣𝒙~)]=12​𝔼𝒙∼pd,ϵ​[‖rθ​(𝒙~)−𝒙‖22]+const.\mathcal{L}_{\text{DAE}}(\theta)=-\mathbb{E}_{{\bm{x}}\sim p_{d},\,\bm{\epsilon}}\left[\log p_{\theta}({\bm{x}}\mid\tilde{\bm{x}})\right]=\frac{1}{2}\,\mathbb{E}_{{\bm{x}}\sim p_{d},\,\bm{\epsilon}}\left[\big\|r_{\theta}(\tilde{\bm{x}})-{\bm{x}}\big\|_{2}^{2}\right]+\text{const}.(123)The second line of Equation122substitutes the classical reconstructionrθ​(𝒙~)=𝒄+σ2​W⊤​𝒉θ​(𝒙~)r_{\theta}(\tilde{\bm{x}})=\bm{c}+\sigma^{2}W^{\top}\bm{h}_{\theta}(\tilde{\bm{x}})of Equation121: since the reconstruction is affine in the representation, the encoder enters the energy bilinearly. The derivation thus justifies the bilinear structure, and brings the DAE into the framework of Equation100, as a conditional EBM with the corrupted input as the condition, the encoder𝒉θ​(𝒙~)\bm{h}_{\theta}(\tilde{\bm{x}})as its representation, and the clean input as the target. The original DAE used masking noise, the discrete counterpart that BERT later adopted.

Diffusion Spectral Representation.

The diffusion spectral representation keeps the conditional bilinear form Equation100and extends the DAE in three ways. The condition is a separate clean variable𝒙{\bm{x}}, such as an image, a prompt, or a state–action pair, rather than a corrupted copy of the target; the target is a corrupted variable𝒚~\tilde{\bm{y}}, at every noise levelttof the forward process Equation80,𝒚~=αt​𝒚+σt​ϵ\tilde{\bm{y}}=\alpha_{t}{\bm{y}}+\sigma_{t}\bm{\epsilon}, with one representationϕθ​(𝒙)\phi_{\theta}({\bm{x}})shared across noise levels; and the target featuresμθ​(𝒚~,t)\mu_{\theta}(\tilde{\bm{y}},t)are nonlinear, so the partition function over𝒚~\tilde{\bm{y}}is no longer available, and the model is learned by score matching instead of maximum likelihood. The DAE and the diffusion spectral representation are thus the same kind of conditional EBM, with the DAE as the single-level special case whose condition is the corrupted input itself, in the same way that BERT is the single-level special case of masked diffusion in Section5.3. FollowingDai et al. [35], the noisy conditionalpt​(𝒚~∣𝒙)=∫qt​(𝒚~∣𝒚)​p​(𝒚∣𝒙)​𝑑𝒚p_{t}(\tilde{\bm{y}}\mid{\bm{x}})=\int q_{t}(\tilde{\bm{y}}\mid{\bm{y}})\,p({\bm{y}}\mid{\bm{x}})\,d{\bm{y}}is parameterized with the bilinear form of Equation100,

pθ,t​(𝒚~∣𝒙)∝pt​(𝒚~)​exp⁡(ϕθ​(𝒙)⊤​μθ​(𝒚~,t)),p_{\theta,t}(\tilde{\bm{y}}\mid{\bm{x}})\propto p_{t}(\tilde{\bm{y}})\exp\left(\phi_{\theta}({\bm{x}})^{\top}\mu_{\theta}(\tilde{\bm{y}},t)\right),(124)where the base measurept​(𝒚~)p_{t}(\tilde{\bm{y}})is the distribution of the corrupted target, inherited from the base measurep⁡(𝒚)p({\bm{y}})of Equation100. In practice, it is absorbed into the inner product by appending a constant coordinate11toϕθ​(𝒙)\phi_{\theta}({\bm{x}}), whose corresponding coordinate ofμθ​(𝒚~,t)\mu_{\theta}(\tilde{\bm{y}},t)then representslog⁡pt​(𝒚~)\log p_{t}(\tilde{\bm{y}}). Sinceϕθ​(𝒙)\phi_{\theta}({\bm{x}})does not depend on𝒚~\tilde{\bm{y}}, the score with respect to𝒚~\tilde{\bm{y}}is linear inϕθ​(𝒙)\phi_{\theta}({\bm{x}}), read out through the Jacobian ofμθ\mu_{\theta}, and the partition function drops out,

∇𝒚~​log​pθ,t​(𝒚~∣𝒙)=∇𝒚~μθ​(𝒚~,t)⊤​ϕθ​(𝒙),\nabla_{\tilde{\bm{y}}}\log p_{\theta,t}(\tilde{\bm{y}}\mid{\bm{x}})=\nabla_{\tilde{\bm{y}}}\mu_{\theta}(\tilde{\bm{y}},t)^{\top}\phi_{\theta}({\bm{x}}),(125)with the base measure included through the constant coordinate. By Tweedie’s formula applied to the conditional,αt𝔼[𝒚∣𝒚~,𝒙]=𝒚~+σt2∇𝒚~logpt(𝒚~∣𝒙)\alpha_{t}\mathbb{E}\left[{\bm{y}}\mid\tilde{\bm{y}},{\bm{x}}\right]=\tilde{\bm{y}}+\sigma_{t}^{2}\nabla_{\tilde{\bm{y}}}\log p_{t}(\tilde{\bm{y}}\mid{\bm{x}}), so denoising score matching fitsϕθ\phi_{\theta}andμθ\mu_{\theta}by regression onto the clean target,

ℒdiff​(θ)\displaystyle\mathcal{L}_{\text{diff}}(\theta)=𝔼t​𝔼(𝒙,𝒚)∼pd,ϵ​[‖𝒚~+σt2​∇𝒚~μθ​(𝒚~,t)⊤​ϕθ​(𝒙)−αt​𝒚‖22]\displaystyle=\mathbb{E}_{t}\,\mathbb{E}_{({\bm{x}},{\bm{y}})\sim p_{d},\,\bm{\epsilon}}\left[\Big\|\tilde{\bm{y}}+\sigma_{t}^{2}\,\nabla_{\tilde{\bm{y}}}\mu_{\theta}(\tilde{\bm{y}},t)^{\top}\phi_{\theta}({\bm{x}})-\alpha_{t}{\bm{y}}\Big\|_{2}^{2}\right](126)=𝔼t​𝔼(𝒙,𝒚)∼pd,ϵ​[σt2​‖ϵ+σt​∇𝒚~μθ​(𝒚~,t)⊤​ϕθ​(𝒙)‖22].\displaystyle=\mathbb{E}_{t}\,\mathbb{E}_{({\bm{x}},{\bm{y}})\sim p_{d},\,\bm{\epsilon}}\left[\sigma_{t}^{2}\,\Big\|\bm{\epsilon}+\sigma_{t}\,\nabla_{\tilde{\bm{y}}}\mu_{\theta}(\tilde{\bm{y}},t)^{\top}\phi_{\theta}({\bm{x}})\Big\|_{2}^{2}\right].The second form shows that this is a conditional diffusion model whose noise predictor,−σt​∇𝒚~μθ​(𝒚~,t)⊤​ϕθ​(𝒙)-\sigma_{t}\nabla_{\tilde{\bm{y}}}\mu_{\theta}(\tilde{\bm{y}},t)^{\top}\phi_{\theta}({\bm{x}}), is linear in the representation of the condition. In practice, the Jacobian∇𝒚~μθ\nabla_{\tilde{\bm{y}}}\mu_{\theta}is parameterized directly by a network, which avoids second-order gradients[158]; after training, it is discarded andϕθ\phi_{\theta}is kept. For discrete targets such as text, the Gaussian corruption is replaced by masking and the regression by the masked diffusion loss[35, Sec. 7.2], which returns to the bilinear denoising EBM of BERT Equation112.

5.5Representation-Induced Decisive Models

Many uses of large language models are decisions rather than open-ended generation: classifying an input, judging whether a response satisfies a requirement, or retrieving the documents that answer a request. A generative LLM makes such a decision by decoding text, which takes a full autoregressive pass and returns a string rather than a distribution over the possible answers. Such inference is expensive: each decision costs one forward pass per generated token, often including a long reasoning trace, and estimating the distribution over the answers requires sampling many responses. Decisive foundation models[176]instead turn each query into a discriminative question: they take a context, a query, and a set of candidate answers, and return a distribution over the candidates. Unlike the discriminative models of Section3, whose classes are fixed in advance, the classes of a decisive model are specified by the instruction and vary from one query to another. Instruction-following retrievers[205]implement decisive foundation models by generalizing embedding models.

Instruction-Following Retrieval.

Instruction-following retrieval asks for the contextsXX, such as passages of a corpus, that satisfy an instructional queryQ=(I,q)Q=(I,q), which consists of a queryqqand an instructionIIthat specifies requirements such as a perspective, format, or level of detail, and possibly the candidate answers. Each pair(X,Q)(X,Q)thus poses a discriminative question with a yes-or-no answer: doesXXsatisfyQQ? InF-Embed[205]generalizes an embedding model to answer it. The score is the cosine similarity between the embeddings of the two sides,

sθ​(X,Q)=𝒙⊤​𝒒‖𝒙‖2​‖𝒒‖2,𝒙=gθX​(X),𝒒=gθQ​(I,q),s_{\theta}(X,Q)=\frac{\bm{x}^{\top}\bm{q}}{\left\|\bm{x}\right\|_{2}\left\|\bm{q}\right\|_{2}},\qquad\bm{x}=g_{\theta}^{X}(X),\qquad\bm{q}=g_{\theta}^{Q}(I,q),(127)wheregθXg_{\theta}^{X}is the context encoder, and the instructional-query encodergθQg_{\theta}^{Q}either encodes the concatenation of the instruction and the query, or encodes them separately and combines their embeddings by cross-attention. The score serves as the logit of the answer: with the two candidates yes and no,pθ​(yes∣X,Q)=σ⁡(sθ​(X,Q)+b)p_{\theta}(\text{yes}\mid X,Q)=\sigma\left(s_{\theta}(X,Q)+b\right)with an offsetbb, and when the instruction listsKKcandidate answers, each candidate receives a score and the answer distribution is the softmax of the scores over theKKcandidates, of which the logistic form is the caseK=2K=2. Retrieval asks this question for every context in the corpus and ranks the contexts by their scores; since the context encoder does not depend on the query, the context embeddings can be precomputed and indexed offline, so answering a new query costs only one encoding of the query and one inner product per context, which makes inference fast and scalable to large corpora with approximate nearest-neighbor search.

Generalizing Embedding Models.

Standard embedding models such as BERT[44]learn an embedding𝒙\bm{x}of the data only, and each new downstream question requires training a new classifier𝒘⊤​𝒙\bm{w}^{\top}\bm{x}on top of it. In InF-Embed, the context embedding plays the same role, but the more important part is the embedding headgθQg_{\theta}^{Q}for the query and the instruction, which maps each instructional query to the weights𝒒=gθQ​(I,q)\bm{q}=g_{\theta}^{Q}(I,q)of this classifier. A new question is therefore answered at inference time by one encoding, without training a new classifier, and the same context can be relevant to one instruction and irrelevant to another. InF-Embed thus generalizes embedding models from embedding the data to also embedding the questions asked about it, while the context embeddings remain query-independent and can still be precomputed.

Learning InF-Embed.

InF-Embed learns the score by ranking NCE Equation47: treating the score as a potential on both sides, it fits the conditionals of the contexts given the query and of the queries given the context. For a batch{(Xi,Qi)}\left\{(X_{i},Q_{i})\right\}, the negatives replace one side at a time,

ℓ⁡(θ)=−𝔼i​[log⁡exp⁡(sθ​(Xi,Qi))∑mexp⁡(sθ​(Xm,Qi))+∑Q′∈𝒩iexp⁡(sθ​(Xi,Q′))],\ell(\theta)=-\mathbb{E}_{i}\left[\log\frac{\exp\left(s_{\theta}(X_{i},Q_{i})\right)}{\sum_{m}\exp\left(s_{\theta}(X_{m},Q_{i})\right)+\sum_{Q^{\prime}\in\mathcal{N}_{i}}\exp\left(s_{\theta}(X_{i},Q^{\prime})\right)}\right],(128)where the first sum provides the negative contexts, and the set𝒩i\mathcal{N}_{i}of negative instructional queries contains those of the other examples as well as those that pair the queryqiq_{i}with the instruction of another example, so that the energy is contrasted against changes of the instruction alone. As in CLIP (Section5.1), fitting both conditionals trains both sides of the energy, and replacing one side at a time keeps the denominator linear in the batch size. The training data supply the noise distribution: each positive pair(X,Q)(X,Q)withQ=(I,q)Q=(I,q)comes with two negative pairs(X1−,(I−,q))(X_{1}^{-},(I^{-},q))and(X2−,(I,q−))(X_{2}^{-},(I,q^{-})), in which an LLM alters the instruction or the query slightly so that a different context becomes relevant. These hard negatives bring the noise distribution close to the data, which makes NCE statistically efficient, and they force the energy to depend on the instruction rather than on the query alone.

From Embeddings to Decisions.

InF-Embed is a bilinear representation following Equation100, with the context and the instructional query on the two sides. The major difference is in how it is used: in representation learning, the energy is discarded after training and the embedding is used alone for downstream tasks, whereas a decisive foundation model uses the learned model itself, which generalizes across queries and instructions, to make the decision. In general, the instructional queryQQitself may contain the candidate answers, which form a set𝒪⁡(Q)\mathcal{O}(Q), and the decision is

pθ​(o∣X,Q)=exp⁡(ϕθ​(X)⊤​ψθo​(Q))∑o′∈𝒪⁡(Q)exp⁡(ϕθ​(X)⊤​ψθo′​(Q)),o∈𝒪⁡(Q),p_{\theta}(o\mid X,Q)=\frac{\exp\left(\phi_{\theta}(X)^{\top}\psi_{\theta}^{o}(Q)\right)}{\sum_{o^{\prime}\in\mathcal{O}(Q)}\exp\left(\phi_{\theta}(X)^{\top}\psi_{\theta}^{o^{\prime}}(Q)\right)},\qquad o\in\mathcal{O}(Q),(129)whereϕθ\phi_{\theta}encodes the context, andψθ\psi_{\theta}encodes the instructional query once and returns an embeddingψθo​(Q)\psi_{\theta}^{o}(Q)for each of its candidates. InF-Embed is the case of the two candidates yes and no, whose logitϕθ​(X)⊤​(ψθyes​(Q)−ψθno​(Q))\phi_{\theta}(X)^{\top}\left(\psi_{\theta}^{\text{yes}}(Q)-\psi_{\theta}^{\text{no}}(Q)\right)is parameterized by the score Equation127.

The main difference from an LLM, which is also a softmax over bilinear energies, is that the potential in Equation129encodes the entire instructional queryQQat once and gives the answer in a single step, whereas an LLM factorizes the answer autoregressively and generates it token by token, each step a softmax over the vocabulary. Hence a decision costs one forward pass rather than one per generated token, which makes inference much faster than with an LLM.

6Reinforcement Learning and Planning through EBMs

EBMs enter reinforcement learning (RL) at several levels, depending on which part of the decision-making problem the energy models. In model-free RL, the energy is placed on the actions only: adding an entropy or KL regularizer to the reward or to the policy update makes the optimal policy an EBM over actions at each state, whose energy is the negativeQQ-function (Section6.1). Acting with such a policy requires sampling from this EBM (Section6.2), and inverse RL and imitation learning fit EBMs over actions or trajectories to expert demonstrations (Section6.3). Beyond the policy, the energy can be placed on the dynamics themselves, where an EBM world model yields a representation in which value functions are linear and can be learned by temporal-difference learning (Section6.4), and on whole trajectories, where planning becomes inference in a trajectory EBM that composes dynamics, behavior priors, goals, and constraints (Section6.5).

6.1Naturally Induced EBM Policies

Entropy-Regularized MDP.

Consider a Markov decision process with statesss, actionsaa, rewardr⁡(s,a)r(s,a), transitionP⁡(s′∣s,a)P(s^{\prime}\mid s,a), and discountγ∈(0,1)\gamma\in(0,1). Maximum-entropy RL seeks the policy

π⋆=argmaxπ𝔼π[∑t=0∞γt(r(st,at)+λH(π(⋅∣st)))],\pi^{\star}=\mathop{\mathrm{argmax}}_{\pi}\;\mathbb{E}_{\pi}\left[\sum_{t=0}^{\infty}\gamma^{t}\left(r(s_{t},a_{t})+\lambda\,H\left(\pi(\cdot\mid s_{t})\right)\right)\right],(130)whereHHis the entropy andλ>0\lambda>0is a temperature. Its solution is an EBM over actions, whose energy is the negative softQQ-function and whoselog\log-partition function is the soft value function,

π⋆(a∣s)=exp(Q⋆​(s,a)−V⋆​(s)λ),V⋆(s)=λlog∑aexp(Q⋆​(s,a)λ),\displaystyle\pi^{\star}(a\mid s)=\exp\left(\frac{Q^{\star}(s,a)-V^{\star}(s)}{\lambda}\right),\qquad V^{\star}(s)=\lambda\log\sum_{a}\exp\left(\frac{Q^{\star}(s,a)}{\lambda}\right),(131)Q⋆(s,a)=r(s,a)+γ𝔼s′∼P(⋅∣s,a)[V⋆(s′)].\displaystyle Q^{\star}(s,a)=r(s,a)+\gamma\,\mathbb{E}_{s^{\prime}\sim P(\cdot\mid s,a)}\left[V^{\star}(s^{\prime})\right].The last two equations form the soft Bellman equation, which replaces themax\maxover actions in the standard Bellman optimality equation by alog\log-sum-exp\exp, and recovers it asλ→0\lambda\to 0.

The entropy-regularized objective Equation130has been proposed from several different motivations, all of which lead to the same EBM Equation131:

  • •Probabilistic inference.Maximum-entropy inverse RL[207]applies the maximum entropy principle (Section2) to trajectories, and control as inference[109]casts optimal control as posterior inference in a graphical model whose potentials are exponentiated rewards.
  • •Tractability.Linearly-solvable MDPs[171]penalize the KL divergence of the controlled dynamics from passive dynamics, which makes the Bellman equation linear in the exponentiated value, so that optimal control reduces to an eigenvalue problem.
  • •Optimization smoothing.SBEED[37]interprets the entropy as Nesterov smoothing of the non-smoothmax\maxin the Bellman optimality equation, using that the negative entropy is the convex conjugate oflog\log-sum-exp\exp. The smoothed Bellman operator remains a contraction, and the smoothed Bellman equation admits a primal–dual reformulation that yields a convergent algorithm with nonlinear function approximation. The same operator appears as an alternative softmax operator for value updates[7].
  • •Robustness to noise.Viewing the policy as a channel with limited information,Rubin et al. [148]trade value against information, and softQQ-learning[66]uses the resulting soft updates to reduce the overestimation bias caused by noisy value estimates. Maximum-entropy RL also provably solves certain robust RL problems with perturbed rewards and dynamics[62]. Conversely, robustness to uncertain dynamics induces the same exponential form on the transition side: in soft robust MDPs, an adversary perturbs the transition kernel subject to a KL penalty, the worst case is the tilted kernelP~(s′∣s,a)∝P(s′∣s,a)exp(−V(s′)/λ)\tilde{P}(s^{\prime}\mid s,a)\propto P(s^{\prime}\mid s,a)\exp\left(-V(s^{\prime})/\lambda\right), an EBM over next states, and the problem is equivalent to a risk-sensitive MDP with the entropic risk measure[201].
  • •Exploration.The entropy keeps the policy stochastic, and path consistency learning[128], softQQ-learning[83], and soft actor–critic[84]use it to explore multiple modes of the action space.
  • •Unifying value- and policy-based methods.With the entropy, softQQ-learning and policy gradient methods become equivalent[152], and both are instances of a single convex-optimization view of entropy-regularized MDPs[132].

Whatever the motivation, the outcome is an EBM: acting is sampling from Equation131, and learning amounts to fitting its energy, so the tools of Section2apply directly.

KL-Regularized Policy Updates.

The entropy in Equation130modifies the MDP itself. A different use of the KL divergence keeps the vanilla MDP,i.e.,λ=0\lambda=0, and regularizes each policy update instead. Given the current policyπk\pi_{k}, trust-region and mirror-descent policy optimization[153,154,71]improve the policy while penalizing, or constraining, its KL divergence fromπk\pi_{k}. In the penalized form,

πk+1(⋅∣s)=argmaxπ𝔼a∼π[Qπk(s,a)]−1ηKL(π∥πk(⋅∣s))⟹πk+1(a∣s)∝πk(a∣s)exp(ηQπk(s,a)).\pi_{k+1}(\cdot\mid s)=\mathop{\mathrm{argmax}}_{\pi}\;\mathbb{E}_{a\sim\pi}\left[Q^{\pi_{k}}(s,a)\right]-\frac{1}{\eta}\,\mathrm{KL}\left(\pi\,\|\,\pi_{k}(\cdot\mid s)\right)\quad\Longrightarrow\quad\pi_{k+1}(a\mid s)\propto\pi_{k}(a\mid s)\exp\left(\eta\,Q^{\pi_{k}}(s,a)\right).(132)Each iterate is therefore a residual EBM Equation4whose base measure is the previous policy. Unrolling the recursion fromπ0\pi_{0}givesπk​(a∣s)∝π0​(a∣s)​exp⁡(η​∑j<kQπj​(s,a))\pi_{k}(a\mid s)\propto\pi_{0}(a\mid s)\exp\left(\eta\sum_{j<k}Q^{\pi_{j}}(s,a)\right), an EBM whose energy accumulates theQQ-functions of all previous iterates. Unlike Equation131, the temperature is not fixed: the energy grows withkk, so the iterates concentrate on the greedy actions and converge to the optimal policy of the vanilla MDP. The KL thus regularizes the optimization path rather than the solution, and the EBM structure appears in every update rather than at the optimum. KL regularization can also be taken toward a fixed reference policyπ0\pi_{0}rather than the previous iterate, which changes the objective rather than the update; the optimal policy is then the residual EBM with base measureπ0\pi_{0}. This is the setting of RLHF for language models[137], whereπ0\pi_{0}is the pretrained model and, in the single-step case,π⋆​(a∣s)∝π0​(a∣s)​exp⁡(r⁡(s,a)/λ)\pi^{\star}(a\mid s)\propto\pi_{0}(a\mid s)\exp\left(r(s,a)/\lambda\right)[141].

These EBM policies have also been used to balance exploration and exploitation through optimism and pessimism, both theoretically and practically:

  • •Value-incentivized actor–critic (VAC).Yang et al. [195]adopt the log-linear,i.e., energy-based, policy class derived from the maximum-entropy policy in a primal–dual actor–critic method that incentivizes exploration and achieves near-optimal regret, and extend it to KL-regularized MDPs.
  • •Value-incentivized preference optimization.For RLHF, VPO[26]regularizes the maximum likelihood estimate of the reward by the corresponding optimal KL-regularized value, which is the expectedlog\log-partition functionλ​𝔼​[log⁡Z⁡(s)]\lambda\,\mathbb{E}\left[\log Z(s)\right]of the EBM policy; its sign selects optimism for online exploration or pessimism for offline learning.

6.2RL for EBM Policies

The regularized policy updates of Section6.1are solved in closed form by EBMs over actions, Equation131and Equation132. The optimization is thus easy, but acting requires sampling actions from these EBMs, which brings back the sampling difficulty of Section2.4. For discrete actions, the partition function is a sum over|𝒜|\left|\mathcal{A}\right|actions, the policy is a softmax overQQ-values, and sampling is exact. For continuous actions, the partition function is an integral, and the commonly used methods fall into the following three classes.

Variational Policy Optimization.

The first restricts the policy to a familyπϕ\pi_{\phi}that is easy to sample from, such as a Gaussian with the reparameterization trick, and optimizes Equation130or Equation132within this family. By the variational bound Equation30, this projects the EBM onto the family,

maxϕ𝔼a∼πϕ(⋅∣s)[Q(s,a)]+λH(πϕ(⋅∣s))=−λKL(πϕ(⋅∣s)∥exp⁡(Q⁡(s,⋅)/λ)Z⁡(s))+λlogZ(s),\displaystyle\max_{\phi}\;\mathbb{E}_{a\sim\pi_{\phi}(\cdot\mid s)}\left[Q(s,a)\right]+\lambda\,H\left(\pi_{\phi}(\cdot\mid s)\right)=-\lambda\,\mathrm{KL}\left(\pi_{\phi}(\cdot\mid s)\,\Big\|\,\frac{\exp\left(Q(s,\cdot)/\lambda\right)}{Z(s)}\right)+\lambda\log Z(s),(133)maxϕ𝔼a∼πϕ(⋅∣s)[Qπk(s,a)]−1ηKL(πϕ(⋅∣s)∥πk(⋅∣s)).\displaystyle\max_{\phi}\;\mathbb{E}_{a\sim\pi_{\phi}(\cdot\mid s)}\left[Q^{\pi_{k}}(s,a)\right]-\frac{1}{\eta}\,\mathrm{KL}\left(\pi_{\phi}(\cdot\mid s)\,\|\,\pi_{k}(\cdot\mid s)\right).The first is the actor update of soft actor–critic (SAC)[84], and the second is mirror-descent policy optimization with a parametric policy[172], of which TRPO and PPO are constrained and clipped variants. Sampling is cheap, but the family limits the policy: a Gaussian cannot represent the multimodal EBMs that arise when several actions are nearly optimal.

MCMC Sampling.

The second samples from the EBM directly. The score of the policy is the action gradient of theQQ-function,∇a​log​π​(a∣s)=∇aQ​(s,a)/λ\nabla_{a}\log\pi(a\mid s)=\nabla_{a}Q(s,a)/\lambda, so Langevin dynamics Equation25draws actions bya←a+ϵλ​∇aQ​(s,a)+2​ϵ​𝝃a\leftarrow a+\frac{\epsilon}{\lambda}\nabla_{a}Q(s,a)+\sqrt{2\epsilon}\,\bm{\xi}. This represents any EBM, but each action requires many gradient evaluations ofQQ. SoftQQ-learning[83]amortizes the sampler: a networka=fϕ​(s,𝝃)a=f_{\phi}(s,\bm{\xi})is trained by amortized Stein variational gradient descent (SVGD)[118]so that its samples follow the EBM, which combines the expressiveness of the EBM with the cost of a single forward pass, as with the implicit samplers of Section2.4.

Diffusion Policies.

The third represents the policy by a diffusion model,i.e., a sequence of noise-perturbed EBMs (Section4.3), which keeps the expressiveness of the EBM while sampling by a fixed number of denoising steps. The obstacle is training: denoising score matching Equation55requires samples from the target policy, which are unavailable in online RL, since the target is known only through its energy. We writeaτa^{\tau}for the noisy action at diffusion timeτ\tau, witha0a^{0}the clean action, to distinguish it from the environment steptt, and𝒔θ​(aτ,s,τ)\bm{s}_{\theta}(a^{\tau};s,\tau)for the score network.Ma et al. [123]observe that the score matching loss can be reweighted by any positive functionggwithout changing its minimizer,𝒔θ​(aτ,s,τ)=∇aτ​log​pτ​(aτ∣s)\bm{s}_{\theta}(a^{\tau};s,\tau)=\nabla_{a^{\tau}}\log p_{\tau}(a^{\tau}\mid s),

ℒg​(θ,s,τ)=∫g⁡(aτ,s)​‖𝒔θ​(aτ,s,τ)−∇aτ​log​pτ​(aτ∣s)‖22​d​aτ,\mathcal{L}^{g}(\theta;s,\tau)=\int g(a^{\tau};s)\,\big\|\bm{s}_{\theta}(a^{\tau};s,\tau)-\nabla_{a^{\tau}}\log p_{\tau}(a^{\tau}\mid s)\big\|_{2}^{2}\,da^{\tau},(134)wherepτp_{\tau}is the noise-perturbed target policy, and chooseggso that the loss becomes tractable. For the KL-regularized update Equation132, choosingggproportional topτp_{\tau}times the partition function gives diffusion policy mirror descent (DPMD), a denoising score matching loss on samples from the current policy, weighted by the exponentiatedQQ-function,

ℒDPMD(θ;s,τ)=𝔼a0∼πk(⋅∣s),aτ∼qτ|0(⋅∣a0)[exp(ηQπk(s,a0))∥𝒔θ(aτ;s,τ)−∇aτlogqτ|0(aτ∣a0)∥22].\mathcal{L}_{\text{DPMD}}(\theta;s,\tau)=\mathbb{E}_{a^{0}\sim\pi_{k}(\cdot\mid s),\,a^{\tau}\sim q_{\tau|0}(\cdot\mid a^{0})}\left[\exp\left(\eta\,Q^{\pi_{k}}(s,a^{0})\right)\,\big\|\bm{s}_{\theta}(a^{\tau};s,\tau)-\nabla_{a^{\tau}}\log q_{\tau|0}(a^{\tau}\mid a^{0})\big\|_{2}^{2}\right].(135)For the entropy-regularized EBM Equation131, there is no previous policy to sample from. Soft diffusion actor–critic (SDAC) instead drawsaτa^{\tau}from a sampling distributionhτh_{\tau}of our choice, drawsa~0\tilde{a}^{0}from the Gaussianq~0|τ(⋅∣aτ)\tilde{q}_{0|\tau}(\cdot\mid a^{\tau})obtained by reversing the perturbation kernel, and weights the loss byexp⁡(Q⁡(s,a~0)/λ)\exp\left(Q(s,\tilde{a}^{0})/\lambda\right), so that only evaluations of the energy are needed,

ℒSDAC(θ;s,τ)=𝔼aτ∼hτ,a~0∼q~0|τ(⋅∣aτ)[exp(Q(s,a~0)/λ)∥𝒔θ(aτ;s,τ)−∇aτlogq~0|τ(a~0∣aτ)∥22].\mathcal{L}_{\text{SDAC}}(\theta;s,\tau)=\mathbb{E}_{a^{\tau}\sim h_{\tau},\,\tilde{a}^{0}\sim\tilde{q}_{0|\tau}(\cdot\mid a^{\tau})}\left[\exp\left(Q(s,\tilde{a}^{0})/\lambda\right)\,\big\|\bm{s}_{\theta}(a^{\tau};s,\tau)-\nabla_{a^{\tau}}\log\tilde{q}_{0|\tau}(\tilde{a}^{0}\mid a^{\tau})\big\|_{2}^{2}\right].(136)Both losses cost the same as standard diffusion training and avoid backpropagating through the denoising chain, and actions are drawn by the reverse diffusion, which plays the role of annealed Langevin dynamics on the EBM policy.

Contrastive Policy Learning.

The closed-form EBM policy can also be used to learn the policy directly from comparisons, without sampling from it. In RL from human feedback, a promptssis answered by a responseaa, and the policy is fine-tuned by the KL-regularized objective of Section6.1toward a reference policyπ0\pi_{0}, whose optimal policy is the residual EBM

π⋆(a∣s)=π0​(a∣s)​exp⁡(r⁡(s,a)/λ)Z⁡(s)⟺r(s,a)=λlogπ⋆​(a∣s)π0​(a∣s)+λlogZ(s).\pi^{\star}(a\mid s)=\frac{\pi_{0}(a\mid s)\exp\left(r(s,a)/\lambda\right)}{Z(s)}\quad\Longleftrightarrow\quad r(s,a)=\lambda\log\frac{\pi^{\star}(a\mid s)}{\pi_{0}(a\mid s)}+\lambda\log Z(s).(137)The second form expresses the reward through the policy, up to thelog\log-partition functionλ​log⁡Z​(s)\lambda\log Z(s), which depends only on the prompt. Direct preference optimization (DPO)[141]exploits this. Preferences between a chosen responseawa_{w}and a rejected responseala_{l}are modeled by the Bradley–Terry model[22],p⁡(aw≻al∣s)=sigm⁡(r⁡(s,aw)−r⁡(s,al))p(a_{w}\succ a_{l}\mid s)=\mathrm{sigm}\left(r(s,a_{w})-r(s,a_{l})\right), which depends only on reward differences, soZ⁡(s)Z(s)cancels. Parameterizing the policyπθ\pi_{\theta}in place ofπ⋆\pi^{\star}in Equation137gives the DPO loss

ℒDPO​(θ)=−𝔼(s,aw,al)​[log⁡sigm⁡(λ​log⁡πθ​(aw∣s)π0​(aw∣s)−λ​log⁡πθ​(al∣s)π0​(al∣s))].\mathcal{L}_{\text{DPO}}(\theta)=-\mathbb{E}_{(s,a_{w},a_{l})}\left[\log\mathrm{sigm}\left(\lambda\log\frac{\pi_{\theta}(a_{w}\mid s)}{\pi_{0}(a_{w}\mid s)}-\lambda\log\frac{\pi_{\theta}(a_{l}\mid s)}{\pi_{0}(a_{l}\mid s)}\right)\right].(138)In the EBM view,πθ\pi_{\theta}is a residual EBM with base measureπ0\pi_{0}, whose negative energy is the implicit reward of Equation137withπθ\pi_{\theta}in place ofπ⋆\pi^{\star}, and Equation138is a contrastive objective of the kind in Section2.5: as in ranking NCE with two candidates, the partition function cancels between the chosen and the rejected response, and the gradient lowers the energy ofawa_{w}and raises that ofala_{l}, weighted by how badly the current policy ranks them. The policy is thus learned without sampling from it and without fitting a separate reward model. Replacing the pair by a ranking ofKKresponses gives the corresponding Plackett–Luce,i.e., ranking NCE, objective, and the value-incentivized regularizer of VPO (Section6.1) adds thelog\log-partition functionλ​𝔼​[log⁡Z⁡(s)]\lambda\,\mathbb{E}\left[\log Z(s)\right]back for exploration.

6.3Inverse RL with EBMs

In inverse RL and imitation learning, the reward is unknown and only expert demonstrations are available. Assuming that the expert acts optimally in the entropy-regularized MDP Equation130, the demonstrations are samples from an EBM, and learning from them is EBM learning. Maximum-entropy IRL, implicit behavioral cloning, and GAIL fit such EBMs, and they differ mainly in which EBM they fit and in which learning method of Section2.5they use.

Maximum-Entropy IRL: Maximum Likelihood.

Maximum-entropy IRL[207]models the distribution of expert trajectoriesτ=(s0,a0,s1,a1,…)\tau=(s_{0},a_{0},s_{1},a_{1},\ldots)as an EBM whose energy is the negative return under a parameterized rewardrθr_{\theta},

pθ​(τ)=1Zθ​ρ⁡(s0)​∏tP⁡(st+1∣st,at)⏟base measure​exp⁡(∑trθ​(st,at)),p_{\theta}(\tau)=\frac{1}{Z_{\theta}}\,\underbrace{\rho(s_{0})\prod_{t}P(s_{t+1}\mid s_{t},a_{t})}_{\text{base measure}}\,\exp\left(\sum_{t}r_{\theta}(s_{t},a_{t})\right),(139)i.e., a residual EBM Equation4whose base measure is given by the dynamics. For a linear rewardrθ=θ⊤​𝒇​(s,a)r_{\theta}=\theta^{\top}{\bm{f}}(s,a), it is the maximum entropy distribution over trajectories that matches the expected features of the expert, as in Section2. Maximum likelihood on the demonstrations𝒟\mathcal{D}has the contrastive gradient Equation39,

∇θ​log​ℒ​(θ)=𝔼τ∼𝒟​[∑t∇θrθ​(st,at)]−𝔼τ∼pθ​[∑t∇θrθ​(st,at)],\nabla_{\theta}\log\mathcal{L}(\theta)=\mathbb{E}_{\tau\sim\mathcal{D}}\left[\sum_{t}\nabla_{\theta}r_{\theta}(s_{t},a_{t})\right]-\mathbb{E}_{\tau\sim p_{\theta}}\left[\sum_{t}\nabla_{\theta}r_{\theta}(s_{t},a_{t})\right],(140)which raises the reward of expert trajectories and lowers that of the model’s own. The negative samples come from the EBM Equation139. With deterministic dynamics, summing over trajectories backward in time yields the soft Bellman equation Equation131withλ=1\lambda=1, the EBM factorizes aspθ​(τ)=(ρ⁡(s0)​exp⁡Vθ​(s0)/Zθ)​∏tπθ​(at∣st)p_{\theta}(\tau)=\left(\rho(s_{0})\exp V_{\theta}(s_{0})/Z_{\theta}\right)\prod_{t}\pi_{\theta}(a_{t}\mid s_{t})along the trajectory withπθ​(a∣s)=exp⁡(Qθ​(s,a)−Vθ​(s))\pi_{\theta}(a\mid s)=\exp\left(Q_{\theta}(s,a)-V_{\theta}(s)\right), and the partition function isZθ=𝔼ρ​[exp⁡Vθ​(s0)]Z_{\theta}=\mathbb{E}_{\rho}\left[\exp V_{\theta}(s_{0})\right]; the sampler is thus the optimal policy of the entropy-regularized MDP with rewardrθr_{\theta}. Each gradient step therefore requires solving a forward maximum-entropy RL problem, the RL counterpart of running MCMC to convergence in maximum likelihood. With stochastic dynamics, the same summation gives the policyπθ​(a∣s)=exp⁡(Qθ​(s,a)−Vθ​(s))\pi_{\theta}(a\mid s)=\exp\left(Q_{\theta}(s,a)-V_{\theta}(s)\right)with

Vθ(s)=log∑aexpQθ(s,a),Qθ(s,a)=rθ(s,a)+log𝔼s′∼P(⋅∣s,a)[expVθ(s′)],V_{\theta}(s)=\log\sum_{a}\exp Q_{\theta}(s,a),\qquad Q_{\theta}(s,a)=r_{\theta}(s,a)+\log\mathbb{E}_{s^{\prime}\sim P(\cdot\mid s,a)}\left[\exp V_{\theta}(s^{\prime})\right],(141)whose backup takes thelog\log-expectation ofexp⁡Vθ\exp V_{\theta}rather than the expectation ofVθV_{\theta}. Maximum causal entropy IRL[206]instead uses the optimal policy of the entropy-regularized MDP Equation130[128,37]with rewardrθr_{\theta}, which is given by the standard soft Bellman equation Equation131, so that rolling outπθ\pi_{\theta}in the environment provides exact negative samples. Guided cost learning[64]avoids the inner loop by estimating the second expectation with importance sampling, using the current policy as the proposal, and improving the policy alongside the reward.

Implicit Behavioral Cloning: Ranking NCE.

Implicit behavioral cloning (IBC)[65]skips the reward and fits the expert policy itself as a conditional EBM,πθ​(a∣s)∝exp⁡(−Eθ​(s,a))\pi_{\theta}(a\mid s)\propto\exp\left(-E_{\theta}(s,a)\right), by ranking NCE Equation47,

ℒIBC​(θ)=−𝔼(s,a)∼𝒟​[log⁡exp⁡(−Eθ​(s,a))exp⁡(−Eθ​(s,a))+∑k=1Kexp⁡(−Eθ​(s,a~k))],\mathcal{L}_{\text{IBC}}(\theta)=-\mathbb{E}_{(s,a)\sim\mathcal{D}}\left[\log\frac{\exp\left(-E_{\theta}(s,a)\right)}{\exp\left(-E_{\theta}(s,a)\right)+\sum_{k=1}^{K}\exp\left(-E_{\theta}(s,\tilde{a}_{k})\right)}\right],(142)where the negative actionsa~k\tilde{a}_{k}are drawn uniformly from the action space. No dynamics or RL are involved, and actions are predicted by minimizing the energy,i.e., MAP prediction (Section2.4), with derivative-free optimization or Langevin dynamics. Compared with explicit regressiona=fθ​(s)a=f_{\theta}(s), the EBM represents multimodal and discontinuous expert behavior instead of averaging its modes, and IBC is the discriminative conditional EBM of Section3applied to actions.

GAIL: Adversarial Training.

Generative adversarial imitation learning (GAIL)[88]has the same learning target as IBC, the expert policy rather than the reward, but fits it by the adversarial training of Section2.5instead of NCE. Matching the occupancy measure of the expert with an entropy-regularized policy leads to

minπ⁡maxD​𝔼(s,a)∼πE​[log⁡D⁡(s,a)]+𝔼(s,a)∼π​[log⁡(1−D⁡(s,a))]−λ​H​(π),\min_{\pi}\max_{D}\;\mathbb{E}_{(s,a)\sim\pi_{E}}\left[\log D(s,a)\right]+\mathbb{E}_{(s,a)\sim\pi}\left[\log\left(1-D(s,a)\right)\right]-\lambda\,H(\pi),(143)where the policy is the learned sampler and the discriminatorDDprovides the contrastive signal between expert and policy samples. The policy is trained by RL with the surrogate reward−log⁡(1−D)-\log\left(1-D\right), and at the optimum its occupancy measure matches that of the expert, while the discriminator does not recover the expert’s reward. This is the structure of the entropy-regularized GAN in Section4.1, with the generator replaced by a policy acting in the environment. The two methods differ in their negative samples and in how the policy is represented. IBC uses uniform negatives and needs no interaction with the environment, but the policy is an explicit energy that must be minimized at every step. GAIL draws its negatives from the rollouts of the current policy, which also corrects the states that the policy itself visits, and the policy is an amortized sampler that acts in a single forward pass. Conversely, the adversarial form also recovers IRL:Finn et al. [63]show that guided cost learning is a GAN whose discriminator has the formD=1Zθ​exp⁡(−Eθ)/(1Zθ​exp⁡(−Eθ)+q)D=\frac{1}{Z_{\theta}}\exp\left(-E_{\theta}\right)/\left(\frac{1}{Z_{\theta}}\exp\left(-E_{\theta}\right)+q\right), whereqqis the density of the sampler, and adversarial IRL[68]uses this form at the level of state–action pairs to recover a reward that transfers across dynamics.

Which EBM Is Learned.

The three methods fit EBMs at different levels, which are related by the soft Bellman equation Equation131. Maximum-entropy IRL learns a per-step energy, the negative reward−rθ-r_{\theta}, whose EBM is over trajectories and whose policy is obtained only by solving the MDP with the dynamics. IBC and GAIL learn the policy directly, IBC as an explicit energy and GAIL as a sampler; if the expert is optimal for Equation130, the energy of the policy is the negative soft advantage,E(s,a)=−(Q⋆(s,a)−V⋆(s))/λE(s,a)=-\left(Q^{\star}(s,a)-V^{\star}(s)\right)/\lambda, which already integrates the future through the dynamics. The reward is recovered from it only through the soft Bellman equation,r⁡(s,a)=Q⋆​(s,a)−γ​𝔼s′​[V⋆​(s′)]r(s,a)=Q^{\star}(s,a)-\gamma\,\mathbb{E}_{s^{\prime}}\left[V^{\star}(s^{\prime})\right]. Learning the reward costs an RL problem in every step but yields an energy that transfers to new dynamics, whereas learning the policy avoids solving for the reward but is tied to the dynamics of the demonstrations.

6.4RL with EBM World Models

Figure 7:RL with an EBM world model.Top: the world model Equation144scores a transition by the inner product ofϕθ​(s,a)\phi_{\theta}(s,a)andνθ​(s′)\nu_{\theta}(s^{\prime}), and is fit to transitions from the replay buffer by score matching Equation126or ranking NCE Equation47. Random features linearize it Equation148, so that theQQ-function of every policy is linear inϕ⁡(s,a)\bm{\phi}(s,a)Equation146. Bottom:ϕθ\phi_{\theta}is frozen and used as the input of the value network Equation150, which computes these features with sinusoidal activations and is trained by TD learning, while the policy maximizesQξQ_{\xi}and its transitions fill the buffer. Figure adapted fromGao et al. [69].The previous subsections place the energy on actions and use no model of the dynamics. A world model,i.e., a model of the transitionℙ⁡(s′∣s,a)\mathbb{P}(s^{\prime}\mid s,a), is the other ingredient of RL, and it can itself be an EBM. Planners, discussed in Section6.5, roll out such a model, but an EBM world model can also be used without sampling from it, by extracting from it a representation in which value functions are linear and learning the value by temporal-difference (TD) learning[144,158,145,69], as summarized in Figure7. The world model is the bilinear EBM of Section5.1, with the state–action pair as the condition and the next state as the target,

ℙθ​(s′∣s,a)=exp⁡(ϕθ​(s,a)⊤​νθ​(s′))Zθ​(s,a),Zθ​(s,a)=∫exp⁡(ϕθ​(s,a)⊤​νθ​(s′))​d​s′,\mathbb{P}_{\theta}(s^{\prime}\mid s,a)=\frac{\exp\left(\phi_{\theta}(s,a)^{\top}\nu_{\theta}(s^{\prime})\right)}{Z_{\theta}(s,a)},\qquad Z_{\theta}(s,a)=\int\exp\left(\phi_{\theta}(s,a)^{\top}\nu_{\theta}(s^{\prime})\right)\,ds^{\prime},(144)i.e., an EBM with energyEθ​(s,a,s′)=−ϕθ​(s,a)⊤​νθ​(s′)E_{\theta}(s,a,s^{\prime})=-\phi_{\theta}(s,a)^{\top}\nu_{\theta}(s^{\prime}). The same construction extends to partially observed MDPs, where the state is replaced by a short window of past observations and actions, and a bilinear EBM over the next observation gives a representation of the belief in which value functions are again linear[202],[69, Section 6].

Linear Value Functions.

Suppose that the transition and the reward factorize through a feature mapϕ⁡(s,a)\bm{\phi}(s,a)in a Hilbert spaceℋ\mathcal{H},

ℙ⁡(s′∣s,a)=⟨ϕ⁡(s,a),𝝁⁡(s′)⟩ℋ,r⁡(s,a)=⟨ϕ⁡(s,a),𝜽r⟩ℋ,\mathbb{P}(s^{\prime}\mid s,a)=\left\langle\bm{\phi}(s,a),\bm{\mu}(s^{\prime})\right\rangle_{\mathcal{H}},\qquad r(s,a)=\left\langle\bm{\phi}(s,a),\bm{\theta}_{r}\right\rangle_{\mathcal{H}},(145)which always holds for some, possibly infinite-dimensional,ℋ\mathcal{H},e.g., by the singular value decomposition of the transition operator. Then theQQ-function of every policyπ\piis linear inϕ\bm{\phi}[69, Lemma 1], since by the Bellman equation

Qπ​(s,a)\displaystyle Q^{\pi}(s,a)=r⁡(s,a)+γ​∫ℙ⁡(s′∣s,a)​Vπ​(s′)​d​s′=⟨ϕ⁡(s,a),𝜼π⟩ℋ,\displaystyle=r(s,a)+\gamma\int\mathbb{P}(s^{\prime}\mid s,a)\,V^{\pi}(s^{\prime})\,ds^{\prime}=\left\langle\bm{\phi}(s,a),\bm{\eta}^{\pi}\right\rangle_{\mathcal{H}},(146)𝜼π\displaystyle\bm{\eta}^{\pi}=𝜽r+γ​∫𝝁⁡(s′)​Vπ​(s′)​d​s′.\displaystyle=\bm{\theta}_{r}+\gamma\int\bm{\mu}(s^{\prime})\,V^{\pi}(s^{\prime})\,ds^{\prime}.The representationϕ\bm{\phi}is therefore sufficient for theQQ-function of every policy, and only the weights𝜼π\bm{\eta}^{\pi}depend on the policy.

Linearizing the EBM World Model.

The EBM Equation144is not of the form Equation145, because the inner product sits inside the exponential, but it can be brought into that form with random features. Completing the square,ϕ⊤​ν=12​‖ϕ‖2+12​‖ν‖2−12​‖ϕ−ν‖2\phi^{\top}\nu=\frac{1}{2}\left\|\phi\right\|^{2}+\frac{1}{2}\left\|\nu\right\|^{2}-\frac{1}{2}\left\|\phi-\nu\right\|^{2}, turnsexp⁡(ϕ⊤​ν)\exp\left(\phi^{\top}\nu\right)into a Gaussian kernelk⁡(ϕ−ν)=exp⁡(−12​‖ϕ−ν‖2)k(\phi-\nu)=\exp\left(-\frac{1}{2}\left\|\phi-\nu\right\|^{2}\right)between the two representations, rescaled by functions of each side alone. A shift-invariant kernel is an expectation of products of random Fourier features[69, Lemma 2],

k⁡(𝒙−𝒚)=𝔼𝝎∼p⁡(𝝎)​[ζ𝝎​(𝒙)​ζ𝝎​(𝒚)∗],ζ𝝎​(𝒙)=ei​𝝎⊤​𝒙,k({\bm{x}}-{\bm{y}})=\mathbb{E}_{\bm{\omega}\sim p(\bm{\omega})}\left[\zeta_{\bm{\omega}}({\bm{x}})\,\zeta_{\bm{\omega}}({\bm{y}})^{*}\right],\qquad\zeta_{\bm{\omega}}({\bm{x}})=e^{\mathrm{i}\bm{\omega}^{\top}{\bm{x}}},(147)wherep⁡(𝝎)p(\bm{\omega})is the Fourier transform ofkk, which is𝒩⁡(0,I)\mathcal{N}\left(0,I\right)for the Gaussian kernel. Replacing the expectation byNNsamples gives finite features𝜻N​(𝒙)\bm{\zeta}_{N}({\bm{x}})of cosines and sines, and substituting into Equation144gives the factorization Equation145with

ϕEBM​(s,a)\displaystyle\bm{\phi}_{\text{EBM}}(s,a)=exp⁡(12​‖ϕθ​(s,a)‖2)​𝜻N​(ϕθ​(s,a))Zθ​(s,a)=𝜻N​(ϕθ​(s,a))⟨𝜻N​(ϕθ​(s,a)),𝒖⟩,\displaystyle=\frac{\exp\left(\frac{1}{2}\left\|\phi_{\theta}(s,a)\right\|^{2}\right)\,\bm{\zeta}_{N}\left(\phi_{\theta}(s,a)\right)}{Z_{\theta}(s,a)}=\frac{\bm{\zeta}_{N}\left(\phi_{\theta}(s,a)\right)}{\left\langle\bm{\zeta}_{N}\left(\phi_{\theta}(s,a)\right),\bm{u}\right\rangle},(148)𝝁EBM​(s′)\displaystyle\bm{\mu}_{\text{EBM}}(s^{\prime})=exp⁡(12​‖νθ​(s′)‖2)​𝜻N​(νθ​(s′)),\displaystyle=\exp\left(\tfrac{1}{2}\left\|\nu_{\theta}(s^{\prime})\right\|^{2}\right)\,\bm{\zeta}_{N}\left(\nu_{\theta}(s^{\prime})\right),where the second form uses that the partition function is itself linear in the same features,Zθ​(s,a)=⟨exp⁡(12​‖ϕθ‖2)​𝜻N​(ϕθ),𝒖⟩Z_{\theta}(s,a)=\left\langle\exp\left(\frac{1}{2}\left\|\phi_{\theta}\right\|^{2}\right)\bm{\zeta}_{N}(\phi_{\theta}),\bm{u}\right\ranglewith𝒖=∫𝝁EBM​(s′)​d​s′\bm{u}=\int\bm{\mu}_{\text{EBM}}(s^{\prime})\,ds^{\prime}. TheQQ-functions are thus linear in features computed fromϕθ​(s,a)\phi_{\theta}(s,a)alone. Stochastic nonlinear dynamics with Gaussian noise,s′=f⁡(s,a)+ϵs^{\prime}=f(s,a)+\bm{\epsilon}, are a special case, sinceℙ(s′∣s,a)∝exp(−‖s′−f(s,a)‖2/(2σ2))\mathbb{P}(s^{\prime}\mid s,a)\propto\exp\left(-\left\|s^{\prime}-f(s,a)\right\|^{2}/(2\sigma^{2})\right)is a Gaussian kernel betweenf⁡(s,a)f(s,a)ands′s^{\prime}, and the same random features give a finite-dimensional representation of the known or learned dynamics directly[144,145].

Learning the World Model.

Since the world model is the bilinear EBM of Section5, its representationϕθ\phi_{\theta}is learned by the same estimators, with the state–action pair as𝒙{\bm{x}}and the next state as𝒚{\bm{y}}. Diff-SR[158]uses score matching, the diffusion spectral representation of Section5.4: the next state is perturbed by a Gaussian kernel,ℙ⁡(s~′∣s′;β)=𝒩⁡(1−β​s′,β​I)\mathbb{P}(\tilde{s}^{\prime}\mid s^{\prime};\beta)=\mathcal{N}\left(\sqrt{1-\beta}\,s^{\prime},\beta I\right), the perturbed transition is parameterized asℙθ​(s~′∣s,a;β)∝exp⁡(ϕθ​(s,a)⊤​νθ​(s~′,β))\mathbb{P}_{\theta}(\tilde{s}^{\prime}\mid s,a;\beta)\propto\exp\left(\phi_{\theta}(s,a)^{\top}\nu_{\theta}(\tilde{s}^{\prime};\beta)\right)withϕθ\phi_{\theta}shared across noise levels, and its score∇s~′νθ​(s~′,β)⊤​ϕθ​(s,a)\nabla_{\tilde{s}^{\prime}}\nu_{\theta}(\tilde{s}^{\prime};\beta)^{\top}\phi_{\theta}(s,a)is regressed onto the score of the perturbation kernel, as in Equation126. CTRL-SR[69]uses ranking NCE Equation47instead, with the modelℙθ​(s′∣s,a)∝ℙ~​(s′)​exp⁡(ϕθ​(s,a)⊤​νθ​(s′))\mathbb{P}_{\theta}(s^{\prime}\mid s,a)\propto\tilde{\mathbb{P}}(s^{\prime})\exp\left(\phi_{\theta}(s,a)^{\top}\nu_{\theta}(s^{\prime})\right)relative to a noise distributionℙ~\tilde{\mathbb{P}}over next states; the noise term depends only ons′s^{\prime}and is absorbed into𝝁EBM\bm{\mu}_{\text{EBM}}, so it does not changeϕEBM\bm{\phi}_{\text{EBM}}. To avoid negatives that are too easy to tell apart from the true next state, the positives and negatives are perturbed by the same Gaussian kernel at several noise levels, and the ranking NCE losses are averaged over the levels, so that the classification becomes harder, and more informative, as the noise grows.

Relation to Successor Features.

Successor features[40,15]also make theQQ-function linear. Withr=⟨ϕ,𝜽r⟩ℋr=\left\langle\bm{\phi},\bm{\theta}_{r}\right\rangle_{\mathcal{H}},Qπ​(s,a)=⟨𝝍π​(s,a),𝜽r⟩ℋQ^{\pi}(s,a)=\left\langle\bm{\psi}^{\pi}(s,a),\bm{\theta}_{r}\right\rangle_{\mathcal{H}}, where the successor features satisfy their own Bellman equation,

𝝍π(s,a)=𝔼π[∑t⩾0γtϕ(st,at)|s0=s,a0=a]=ϕ(s,a)+γ𝔼s′∼ℙ(⋅∣s,a),a′∼π(⋅∣s′)[𝝍π(s′,a′)],\bm{\psi}^{\pi}(s,a)=\mathbb{E}_{\pi}\left[\sum_{t\geqslant 0}\gamma^{t}\bm{\phi}(s_{t},a_{t})\,\Big|\,s_{0}=s,a_{0}=a\right]=\bm{\phi}(s,a)+\gamma\,\mathbb{E}_{s^{\prime}\sim\mathbb{P}(\cdot\mid s,a),\,a^{\prime}\sim\pi(\cdot\mid s^{\prime})}\left[\bm{\psi}^{\pi}(s^{\prime},a^{\prime})\right],(149)and are learned by TD on the right-hand side, asQπQ^{\pi}is, with the vectorϕ\bm{\phi}in place of the reward. Its fixed point is𝝍π=(I−γ​ℙπ)−1​ϕ\bm{\psi}^{\pi}=(I-\gamma\mathbb{P}^{\pi})^{-1}\bm{\phi}, withℙπ(s′,a′∣s,a)=ℙ(s′∣s,a)π(a′∣s′)\mathbb{P}^{\pi}(s^{\prime},a^{\prime}\mid s,a)=\mathbb{P}(s^{\prime}\mid s,a)\,\pi(a^{\prime}\mid s^{\prime}), and learning low-rank successor features in this way is equivalent to taking the left singular vectors of the multi-step operator(I−γ​ℙπ)−1(I-\gamma\mathbb{P}^{\pi})^{-1}[143]. In the terms of Section5, the two representations differ in the pair of variables that the energy couples: the EBM world model couples the state–action pair with the next state, whereas successor features couple it with the discounted future occupancy underπ\pi. Successor features therefore depend on the policy: they transfer across rewards for a fixedπ\pi, but must be relearned by TD when the policy changes. The representationϕ\bm{\phi}factorizes the single-step transition, does not depend on the policy, and is sufficient for theQQ-function of every policy, which enters only through𝜼π\bm{\eta}^{\pi}; it is learned once from transitions by NCE or score matching, which is more convenient than TD.

Representation-Based TD.

Onceϕθ\phi_{\theta}is learned, it is frozen, and theQQ-function is fitted on top of it by TD learning, without sampling from the world model. Following Equation148, theQQ-network computes the random features ofϕθ​(s,a)\phi_{\theta}(s,a)with sinusoidal activations and adds one layer for the normalization,

Qξ​(s,a)\displaystyle Q_{\xi}(s,a)=act​(W2​[cos⁡(W1​ϕθ​(s,a));sin⁡(W1​ϕθ​(s,a))])⊤​𝜼,\displaystyle=\mathrm{act}\left(W_{2}\left[\cos\left(W_{1}\phi_{\theta}(s,a)\right);\sin\left(W_{1}\phi_{\theta}(s,a)\right)\right]\right)^{\top}\bm{\eta},(150)ℓTD​(ξ)\displaystyle\ell_{\text{TD}}(\xi)=𝔼(s,a,r,s′)∼𝒟​[(r+γ​𝔼a′∼π​[Qξ¯​(s′,a′)]−Qξ​(s,a))2],\displaystyle=\mathbb{E}_{(s,a,r,s^{\prime})\sim\mathcal{D}}\left[\left(r+\gamma\,\mathbb{E}_{a^{\prime}\sim\pi}\left[Q_{\bar{\xi}}(s^{\prime},a^{\prime})\right]-Q_{\xi}(s,a)\right)^{2}\right],whereξ=(W1,W2,𝜼)\xi=(W_{1},W_{2},\bm{\eta}),act\mathrm{act}is a nonlinear activation, andξ¯\bar{\xi}is a slowly updated target copy, and the policy maximizesQξQ_{\xi}. The TD objective does not trainϕθ\phi_{\theta}: by Equation146, the representation learned from the dynamics already spans theQQ-function of every policy, so TD only fits the policy-dependent weights. The EBM view thus separates the two parts of model-based RL: the world model is learned as an EBM by the estimators of Section2.5, and its partition function and sampler are never needed for control, since the random features linearize both the transition and its normalization.

6.5Planning with Trajectory EBMs

The policies of Sections6.1–6.3are EBMs over the action at a single state. Planning instead reasons about whole trajectories: given a model of the dynamics, such as the world models of Section6.4, and a task, it searches for sequences of states and actions that accomplish the task. The entropy regularization of Section6.1again turns this search into inference in an EBM, now over trajectories[8,173,109]. This EBM is where composition (Section2.3) is most useful: learned dynamics, behavior priors, goals, costs, and constraints each contribute an energy term, and a new task is a new sum of terms.

Planning as Inference over Trajectories.

Consider trajectoriesτ=(s0,a0,…,aT−1,sT)\tau=(s_{0},a_{0},\ldots,a_{T-1},s_{T})of horizonTTfrom a given initial states0s_{0}, with the base measure

p0​(τ)=∏t=0T−1π0​(at∣st)​P​(st+1∣st,at),p_{0}(\tau)=\prod_{t=0}^{T-1}\pi_{0}(a_{t}\mid s_{t})\,P(s_{t+1}\mid s_{t},a_{t}),(151)whereπ0\pi_{0}is a prior over actions: uniform for maximum entropy, or a behavior model learned from data for KL regularization. With the returnR⁡(τ)=∑t=0T−1r⁡(st,at)+rT​(sT)R(\tau)=\sum_{t=0}^{T-1}r(s_{t},a_{t})+r_{T}(s_{T}), whererTr_{T}scores the final state, maximum-entropy planning solves

maxq𝔼τ∼q[R(τ)]−λKL(q∥p0).\max_{q}\;\mathbb{E}_{\tau\sim q}\left[R(\tau)\right]-\lambda\,\mathrm{KL}\left(q\,\|\,p_{0}\right).(152)By the same argument as Equation56, withp0p_{0}in place of the uniform base measure, the solution is the residual EBM Equation4

q⋆​(τ)=p0​(τ)​exp⁡(R⁡(τ)/λ)Z,Z=𝔼τ∼p0​[exp⁡(R⁡(τ)/λ)],q^{\star}(\tau)=\frac{p_{0}(\tau)\exp\left(R(\tau)/\lambda\right)}{Z},\qquad Z=\mathbb{E}_{\tau\sim p_{0}}\left[\exp\left(R(\tau)/\lambda\right)\right],(153)and the optimal value isλ​log⁡Z\lambda\log Z. This is the trajectory EBM of maximum-entropy IRL Equation139with the roles reversed: IRL learns the reward from samples of this EBM, while planning draws samples from it for a given reward. Asλ→0\lambda\to 0,q⋆q^{\star}concentrates on the trajectories of highest return in the support ofp0p_{0}, and planning reduces to trajectory optimization,i.e., MAP prediction Equation34with this EBM. One caveat concerns stochastic dynamics. Sinceqqin Equation152ranges over all distributions over trajectories,q⋆q^{\star}also reweights the transitions toward favorable outcomes, which is the optimistic backup Equation141of Section6.3; requiringqqto keep the true dynamics instead gives the soft Bellman backup Equation131and a closed-loop policy. For deterministic dynamics, the two coincide, andq⋆q^{\star}is a distribution over action sequences, with the states given by rolling out the model. Most planners work in this setting: they sample or optimize an open-loop action sequence under a known or learned model, execute its first action, and plan again at the next step, as in model predictive control.

Refer to captionFigure 8:Planning by composing trajectory energies.The planning energy (Equation154) is a sum of terms that are independently specified: a prior over trajectories that start at the black dot (shown by its samples), an energy on the final state that is low near the goal (star; darker is lower), and an energy on every state that is high inside each obstacle (gray). Sampling the sum gives trajectories that reach the goal and avoid the obstacles (right), where trajectories are generated through MPPI with the prior.

Sampling-Based Planners.

Planners that roll out a model are samplers or optimizers of Equation153. Model predictive path integral control (MPPI)[189], derived from path integral control[99,169], drawsKKaction sequences from a Gaussian around the current plan, rolls them out, and moves the plan to their weighted average with weightswk∝exp⁡(R⁡(τk)/λ)w_{k}\propto\exp\left(R(\tau_{k})/\lambda\right). With the Gaussian asp0p_{0}, these are the weights of the self-normalized importance sampler of Section4.4, so each iteration estimates the mean ofq⋆q^{\star}. The cross-entropy method[149,41]replaces these weights by a hard selection, refitting the Gaussian to the sampled sequences with the highest returns. Iterating either method, with the refitted Gaussian as the nextp0p_{0}, is mirror descent over action sequences[184], the trajectory analogue of the policy update Equation132. For a differentiable model and reward, Langevin dynamics Equation25and gradient descent Equation35on the action sequence, with gradients backpropagated through the rollout, respectively sampleq⋆q^{\star}and find a MAP plan.

Composing Trajectory Energies.

Taking the negative logarithm of Equation153writes the planning distribution as a sum of energies,

E⁡(τ)=−∑t=0T−1logP(st+1∣st,at)⏟dynamics​−∑t=0T−1logπ0(at∣st)⏟behavior prior​−1λ∑t=0T−1r(st,at)⏟rewards and costs​−1λ​rT​(sT)⏟goal,E(\tau)=\underbrace{-\sum_{t=0}^{T-1}\log P(s_{t+1}\mid s_{t},a_{t})}_{\text{dynamics}}\;\underbrace{-\sum_{t=0}^{T-1}\log\pi_{0}(a_{t}\mid s_{t})}_{\text{behavior prior}}\;\underbrace{-\frac{1}{\lambda}\sum_{t=0}^{T-1}r(s_{t},a_{t})}_{\text{rewards and costs}}\;\underbrace{-\frac{1}{\lambda}\,r_{T}(s_{T})}_{\text{goal}},(154)which is an MRF Equation9over the trajectory whose factors can come from different sources: the dynamics from interaction data or a simulator, the behavior prior from demonstrations, and the rewards and goal from the task. For deterministic dynamics, the first term is a set energy Equation15withC→∞C\to\inftythat restrictsτ\tauto dynamically feasible trajectories. Following Section2.3, each term can be learned or specified separately and combined at inference time, and the task terms decompose further,e.g., into a goal energy onsTs_{T}and one energy per obstacle on eachsts_{t}. This example, which is also discussed in the introduction, is illustrated in Figure8. An energy describing plausible robot trajectories, combined with energies expressing a destination and obstacle constraints enables us to form plans towards the goal that avoids obstacles.Du et al. [53]learn an energy over state transitions in place of the dynamics and behavior terms, and plan by sampling state sequences from it together with start and goal constraints; planning in state space gives maximum-entropy inference of diverse plans and generalizes better to obstacles unseen during training.

Refer to captionFigure 9:Composing trajectory potentials for more obstacles.A diffusion model learns a potential over plans in two-dimensional mazes with six obstacles. In a maze with6+k6+kobstacles (orange: thekkextra ones), the potentials conditioned on different groups of obstacles are added, and sampling the sum gives a collision-free plan from the start (green star) to the goal (pink star) without retraining. The two rows are different problems. Reproduced fromLuo et al. [122].

Diffusion Planners.

Diffusion models can learn the dynamics and behavior terms of Equation154jointly, as one prior over trajectories. Diffuser[97]trains a diffusion model over state–action trajectories from offline data,i.e., a family of trajectory EBMs (Section4.3), and plans by sampling the perturbed distributionp~​(τ)∝pθ​(τ)​h​(τ)\tilde{p}(\tau)\propto p_{\theta}(\tau)\,h(\tau), wherehhencodes rewards, goals, or constraints. Reward guidance adds the gradient of a learned return modelJϕ​(τ)J_{\phi}(\tau)to the reverse process at every noise level, which is classifier guidance Equation86with the energy−Jϕ-J_{\phi}. It therefore targets the planning EBM Equation153with1/λ1/\lambdagiven by the guidance scale and the learned trajectory distributionpθp_{\theta}as the base measure, which keeps plans close to the trajectories that the data support. Goals are imposed by inpainting,i.e., by clamping the start and goal states, which conditions the joint energy as in Section2.3. Decision Diffuser[1]models state sequences, extracts actions with an inverse dynamics model, and conditions on returns, constraints, or skills by classifier-free guidance Equation88; conditioning on a single constraint or skill during training yields behavior at test time that satisfies several constraints together or composes skills, as in the conjunction Equation23. Potential-based diffusion motion planning[122]learns potentials over motion-planning trajectories with a diffusion model and composes the potentials of different motion constraints by addition, as in classical potential-based planning. Since these planners compose by summing scores or energies at each noise level, the caveat of Section4.3applies: reverse diffusion on summed scores only approximately samples the composed distribution, and MCMC on summed energies corrects it[49].

Sequence-Model Planners.

Sequence models such as Transformers can also serve as the prior over trajectories, treating states, actions, and returns as tokens. Autoregressive models factorize this prior in a fixed order (Section4.6), and the planners built on them differ in how they bring in the reward. Decision Transformer[28]conditions each action on the desired return-to-go and acts by conditioning on a high return, as Decision Diffuser does; with stochastic dynamics, this favors actions that were followed by lucky outcomes, the optimism discussed after Equation153. Trajectory Transformer[98]plans by beam search over the model’s likely continuations, keeping those with the highest predicted return, which is the greedy version of the sequential samplers of Section7.2. Both generate a plan one step at a time, so they cannot revise earlier actions in light of later ones.Chen et al. [27]instead train a masked language model over action sequences, which defines an implicit energy over the whole plan, as in BERT (Section5.3), and plan by iteratively resampling actions to lower it, in the manner of the Gibbs sampler of Section2.4, so that any step can be revised and constraints can be added as energy terms.

Planning with Generative World Models.

When states are images, the trajectory energy can be split between a model of observation sequences and a model of actions. UniPi[56]generates a video plan with a text-conditioned video diffusion model, conditioned on the current frame and a language descriptionggof the goal, and extracts actions with an inverse dynamics model,

p(o1:T,a0:T−1∣o0,g)=pθ(o1:T∣o0,g)∏t=0T−1pψ(at∣ot,ot+1),p(o_{1:T},a_{0:T-1}\mid o_{0},g)=p_{\theta}(o_{1:T}\mid o_{0},g)\prod_{t=0}^{T-1}p_{\psi}(a_{t}\mid o_{t},o_{t+1}),(155)whereoto_{t}is the observation at steptt. The video model, trained on broad data across tasks, plays the role of the dynamics and behavior terms of Equation154, the text plays the role of the goal, and only the small inverse dynamics model depends on the action space of the robot. Compositional foundation models for hierarchical planning[2]compose a language model that proposes subgoals, a video model that grounds them in visual plans, and an inverse dynamics model that turns the videos into actions, and enforce consistency among the three by iterative refinement. Video language planning[57]searches over long-horizon video plans with a tree search, using vision–language models as the policy and value function and a text-to-video model as the dynamics. In each case, separately trained models supply different factors of one distribution over trajectories, which is the sense in which learned dynamics, behavior models, and task objectives contribute components of a common inference problem.

Refer to captionFigure 10:Planning with a video model.The trajectory distribution Equation155factors into a video model, which turns the current frameo0o_{0}and the instructiongginto a video plano1:To_{1:T}(blue), and an inverse dynamics model, which infers each actionata_{t}from a pair of consecutive frames (orange). The video model, trained across tasks, supplies the dynamics and behavior terms of Equation154, and only the inverse dynamics model depends on the robot. Frames fromDu et al. [56], whereo1,…,o4o_{1},\ldots,o_{4}are generated.

Planning versus Policies.

Policies and planners represent the same EBM at different levels. For deterministic dynamics, the trajectory EBM Equation153factorizes along the trajectory into the soft-optimal policy given by Equation131, as shown for maximum-entropy IRL in Section6.3. A policy amortizes planning into one network for one reward and acts in a single forward pass. A planner keeps the terms of Equation154separate and pays with sampling or optimization at every decision, but a new goal, cost, or constraint only requires a new energy term rather than a new policy. This is the trade-off between amortized sampling and MCMC in Section2.4, and between learning the policy and learning the reward in Section6.3, now applied to acting.

7Inference-Time Computation

A recent source of improvement in large models is to spend more computation per input at inference time rather than at training time. In the EBM view, these procedures are samplers or optimizers for one distribution, the composition of a pretrained generator with a verifier, which is the KL-regularized EBM of Section6.1. We first describe this target, then view common inference-time methods as the samplers of Section2.4, Section4.4, and Section6.5, then show how composing learned energies supports reasoning on problems larger than those seen in training, and finally relate inference-time computation to fine-tuning, which amortizes the same sampler.

7.1Verifiers Define the Target

Letπ0​(𝒚∣𝒙)\pi_{0}({\bm{y}}\mid{\bm{x}})be a pretrained generator, such as a language model that answers a prompt𝒙{\bm{x}}with a response𝒚=(y1,…,yT){\bm{y}}=(y_{1},\ldots,y_{T}), and letr⁡(𝒙,𝒚)r({\bm{x}},{\bm{y}})be a verifier that scores complete responses, such as a learned reward model, a learned verifier[32], or a checker such as unit tests. The target of inference-time computation is the residual EBM

π⋆(𝒚∣𝒙)=π0​(𝒚∣𝒙)​exp⁡(r⁡(𝒙,𝒚)/λ)Z⁡(𝒙),Z(𝒙)=𝔼𝒚∼π0(⋅∣𝒙)[exp(r(𝒙,𝒚)/λ)],\pi^{\star}({\bm{y}}\mid{\bm{x}})=\frac{\pi_{0}({\bm{y}}\mid{\bm{x}})\exp\left(r({\bm{x}},{\bm{y}})/\lambda\right)}{Z({\bm{x}})},\qquad Z({\bm{x}})=\mathbb{E}_{{\bm{y}}\sim\pi_{0}(\cdot\mid{\bm{x}})}\left[\exp\left(r({\bm{x}},{\bm{y}})/\lambda\right)\right],(156)which is the optimal policy of the KL-regularized objective Equation137, with the prompt as the state and the response as the action. The temperatureλ\lambdatrades the verifier against the generator. For a binary verifier,r∈{0,1}r\in\left\{0,1\right\}, the limitλ→0\lambda\to 0givesπ⋆​(𝒚∣𝒙)=π0​(𝒚∣𝒙,r=1)\pi^{\star}({\bm{y}}\mid{\bm{x}})=\pi_{0}({\bm{y}}\mid{\bm{x}},r=1), the generator conditioned on being correct, which is the product ofπ0\pi_{0}with the set energy Equation15of correct responses, the logicalANDof Section2.3. Several verifiers compose in the same way, asπ0​∏kexp⁡(rk/λk)\pi_{0}\prod_{k}\exp\left(r_{k}/\lambda_{k}\right),e.g., for a correctness check and a style or safety reward. The verifier can even be the generator’s own likelihood, which sharpens the generator without any external signal, as discussed in Section7.2. Since verifiers are learned or incomplete, the temperature also limits how far the target moves from the generator, as measured byKL(π⋆∥π0)\mathrm{KL}\left(\pi^{\star}\|\pi_{0}\right), and thus how much an inaccurate verifier can be exploited. This is the requirement of Section2.3that each component be accurate where the composition places its mass. The target is a distribution, and the prediction can be a sample from it or its mode.

Figure 11:White-box, grey-box, and black-box adaptation of a language modelπ0\pi_{0}.White-box adaptation accesses both the parameters and the output probabilities ofπ0\pi_{0}and can fine-tune it. Grey-box adaptation accesses only the token probabilities, which a small adaptergθg_{\theta}reweights. Black-box adaptation accesses neither and only receives sampled text:π0\pi_{0}proposes candidate sentences andgθg_{\theta}scores them to decide which to extend, a sentence-level beam search forπθ∝π0​egθ\pi_{\theta}\propto\pi_{0}\,e^{g_{\theta}}Equation156. The flame marks trainable models and the snowflake marks fixed, inaccessible ones. Adapted fromSun et al. [167].#### Black-Box Adaptation.

The target Equation156requires only samples from the generator and evaluations of the verifier, not the parameters or the token probabilities ofπ0\pi_{0}. This enables us to directly adapt models, even when the strongest generators are often served only through an API, as black boxes. As illustrated in Figure11, white-box adaptation fine-tunes the parameters ofπ0\pi_{0}, and grey-box adaptation reweights its output token probabilities, but neither is available when the API returns only sampled text. The residual EBM still applies: BBox-Adapter[167]keepsπ0\pi_{0}fixed as the base measure and learns the energy as a small language modelgθ​(𝒙,𝒚)g_{\theta}({\bm{x}},{\bm{y}}),i.e.,r/λ=gθr/\lambda=g_{\theta}in Equation156, so thatπθ​(𝒚∣𝒙)∝π0​(𝒚∣𝒙)​exp⁡(gθ​(𝒙,𝒚))\pi_{\theta}({\bm{y}}\mid{\bm{x}})\propto\pi_{0}({\bm{y}}\mid{\bm{x}})\exp\left(g_{\theta}({\bm{x}},{\bm{y}})\right). The energy is trained by ranking NCE Equation47with the generator itself as the noise distribution: target-domain responses are the positives, the responses ofπ0\pi_{0}are the negatives, and since the model is a residual EBM with base measurepn=π0p_{n}=\pi_{0}, the unknownlog⁡π0\log\pi_{0}cancels from the logits, so its probabilities are never needed. The positives can come from ground truth or from human or AI feedback, and the negatives from previous adapted generations, which turns adaptation into an online loop that updates the verifier and the sampler together. Sampling fromπθ\pi_{\theta}also usesπ0\pi_{0}only as a proposal:π0\pi_{0}proposes candidate continuations andgθg_{\theta}scores them in a sentence-level beam search, a sequential variant of the samplers in Section7.2. The same construction adapts black-box text-to-video models: a small video model trained on domain-specific data plays the role of the energy on top of a large pretrained model that is accessed only through its score, without its weights[194].

7.2Samplers for the Target

Sampling Complete Responses.

The simplest methods drawNNcomplete responses𝒚1,…,𝒚N∼π0(⋅∣𝒙){\bm{y}}_{1},\ldots,{\bm{y}}_{N}\sim\pi_{0}(\cdot\mid{\bm{x}})and use the verifier only to select among them. Returning𝒚i{\bm{y}}_{i}with probability proportional toexp⁡(r⁡(𝒙,𝒚i)/λ)\exp\left(r({\bm{x}},{\bm{y}}_{i})/\lambda\right)is the self-normalized importance sampler of Section4.4with the generator as the proposal: it samples a distribution that interpolates betweenπ0\pi_{0}andπ⋆\pi^{\star}, and converges toπ⋆\pi^{\star}asN→∞N\to\infty. Best-of-NN, which returns the response with the highest reward, is also a residual EBM. If the reward of𝒚∼π0(⋅∣𝒙){\bm{y}}\sim\pi_{0}(\cdot\mid{\bm{x}})has a continuous distribution with cumulative distribution functionF𝒙F_{\bm{x}}, the returned response is distributed as[80]

πBoN​(𝒚∣𝒙)=N​π0​(𝒚∣𝒙)​F𝒙​(r⁡(𝒙,𝒚))N−1,\pi_{\text{BoN}}({\bm{y}}\mid{\bm{x}})=N\,\pi_{0}({\bm{y}}\mid{\bm{x}})\,F_{\bm{x}}\left(r({\bm{x}},{\bm{y}})\right)^{N-1},(157)since𝒚{\bm{y}}is returned when it is one of theNNdraws and the otherN−1N-1draws have lower rewards. This is the KL-regularized optimum Equation156for the transformed rewardlog⁡F𝒙​(r)\log F_{\bm{x}}(r), thelog\log-quantile of the reward under the generator, at temperatureλ=1/(N−1)\lambda=1/(N-1). IncreasingNNlowers the temperature, and the divergence from the generator is at mostlog⁡N−(N−1)/N\log N-(N-1)/N, with equality for continuous rewards[17]. Rejection sampling gives exact samples instead: whenr⩽rmaxr\leqslant r_{\max}, accepting𝒚∼π0(⋅∣𝒙){\bm{y}}\sim\pi_{0}(\cdot\mid{\bm{x}})with probabilityexp⁡((r⁡(𝒙,𝒚)−rmax)/λ)\exp\left((r({\bm{x}},{\bm{y}})-r_{\max})/\lambda\right)returns samples of Equation156. For a binary verifier withλ→0\lambda\to 0, it resamples until the verifier accepts, at an expected cost of1/𝔼𝒚∼π0(⋅∣𝒙)[r(𝒙,𝒚)]1/\mathbb{E}_{{\bm{y}}\sim\pi_{0}(\cdot\mid{\bm{x}})}\left[r({\bm{x}},{\bm{y}})\right]responses. Finally, majority voting over final answers, or self-consistency[187], is a Bayes prediction. Leta⁡(𝒚)a({\bm{y}})be the final answer extracted from a response. The most frequent answer among the samples estimates the mode of the marginal distributionp(a∣𝒙)=∑𝒚π0(𝒚∣𝒙)1[a(𝒚)=a]p(a\mid{\bm{x}})=\sum_{{\bm{y}}}\pi_{0}({\bm{y}}\mid{\bm{x}})\,\bm{1}[a({\bm{y}})=a], which is the Bayes prediction under the00–11loss on answers. It sums over the different responses that reach each answer, rather than taking the answer of the single most probable response, and weighting the votes byexp⁡(r/λ)\exp\left(r/\lambda\right)gives the same prediction underπ⋆\pi^{\star}.

Sequential Sampling and Search.

Sampling complete responses wastes computation on responses that go wrong early. Sinceπ0\pi_{0}is autoregressive, the target Equation156also factorizes over tokens, with the conditionals

π⋆(yt∣𝒙,𝒚<t)=π0(yt∣𝒙,𝒚<t)ψt​(𝒙,𝒚⩽t)ψt−1​(𝒙,𝒚<t),ψt(𝒙,𝒚⩽t)=𝔼𝒚>t∼π0(⋅∣𝒙,𝒚⩽t)[exp(r(𝒙,𝒚)/λ)],\pi^{\star}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})=\pi_{0}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})\,\frac{\psi_{t}({\bm{x}},{\bm{y}}_{\leqslant t})}{\psi_{t-1}({\bm{x}},{\bm{y}}_{<t})},\qquad\psi_{t}({\bm{x}},{\bm{y}}_{\leqslant t})=\mathbb{E}_{{\bm{y}}_{>t}\sim\pi_{0}(\cdot\mid{\bm{x}},{\bm{y}}_{\leqslant t})}\left[\exp\left(r({\bm{x}},{\bm{y}})/\lambda\right)\right],(158)whereψt\psi_{t}is the expected exponentiated reward of completing the prefix with the generator, andψ0=Z⁡(𝒙)\psi_{0}=Z({\bm{x}}). This is the fixed-order factorization of an EBM Equation96:π0​(𝒚⩽t∣𝒙)​ψt​(𝒙,𝒚⩽t)\pi_{0}({\bm{y}}_{\leqslant t}\mid{\bm{x}})\,\psi_{t}({\bm{x}},{\bm{y}}_{\leqslant t})is the sum over the unvisited tokens that autoregressive models reparameterize in Equation97. It is also the soft-optimal policy of the KL-regularized MDP of Section6.1whose state is the prefix, whose action appends a token, and whose rewardrrarrives at the end, withλ​log⁡ψt\lambda\log\psi_{t}as its soft value. Exact token-by-token sampling therefore needsψt\psi_{t}, which is as intractable asZ⁡(𝒙)Z({\bm{x}}), and practical methods approximate it. A future discriminator, which predicts an attribute of the completion from a prefix[193], learnsψt\psi_{t}for a classifier energy, which is the autoregressive counterpart of classifier guidance Equation86. Value models and process reward models, which score partial solutions[113], play the same role; for a binary verifier withλ→0\lambda\to 0,ψt\psi_{t}becomes, up to a constant, the probability that the generator completes the prefix correctly. With an approximateψt\psi_{t}, sequential Monte Carlo (SMC) recoversπ⋆\pi^{\star}as the number of particles grows: it extendsKKpartial responses in parallel, weights each extension by the ratio of successive approximate values, as in Equation158, resamples the partial responses according to their weights, and corrects with the true reward at the end[111,204]. Beam search keeps theKKpartial responses with the highest values, a greedy and deterministic version of this resampling, and tree search adds backtracking, as in the planners of Section6.5.

Composing Models Token by Token.

The same factorization explains a pitfall of composing autoregressive models. Sampling each token from the normalized product of the conditionals of two models gives

q⁡(𝒚∣𝒙)=∏t=1Tp1​(yt∣𝒙,𝒚<t)​p2​(yt∣𝒙,𝒚<t)Zt​(𝒙,𝒚<t)=p1​(𝒚∣𝒙)​p2​(𝒚∣𝒙)∏t=1TZt​(𝒙,𝒚<t),q({\bm{y}}\mid{\bm{x}})=\prod_{t=1}^{T}\frac{p_{1}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})\,p_{2}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})}{Z_{t}({\bm{x}},{\bm{y}}_{<t})}=\frac{p_{1}({\bm{y}}\mid{\bm{x}})\,p_{2}({\bm{y}}\mid{\bm{x}})}{\prod_{t=1}^{T}Z_{t}({\bm{x}},{\bm{y}}_{<t})},(159)whereZt​(𝒙,𝒚<t)=∑vp1​(v∣𝒙,𝒚<t)​p2​(v∣𝒙,𝒚<t)Z_{t}({\bm{x}},{\bm{y}}_{<t})=\sum_{v}p_{1}(v\mid{\bm{x}},{\bm{y}}_{<t})\,p_{2}(v\mid{\bm{x}},{\bm{y}}_{<t}). The per-token normalizers depend on the prefix, soqqis not the productp1​p2p_{1}p_{2}of Section2.3, for the same reason that summed scores do not give the score of a noised product in Section4.3: normalizing at every step does not commute with taking products. The weights∏tZt​(𝒙,𝒚<t)\prod_{t}Z_{t}({\bm{x}},{\bm{y}}_{<t})are available as the tokens are drawn, so importance sampling or SMC with these weights is needed to remove the bias. Existing decoding-time methods use such token-level compositions directly, without this correction: DExperts[116]multiplies the base model by an expert and divides it by an anti-expert, an inversion Equation22, and contrastive decoding[112]scores tokens by the ratio of a large model to a small one, restricted to the tokens the large model finds plausible, which is an inversion combined with a set energy Equation15.

Figure 12:Power distribution vs low-temperature sampling.The power distribution and low-temperature decoding choose the next token differently, here withα=2\alpha=2. Token A has one completion with probability0.40.4, and token B has three completions with probability0.20.2each. Low temperature sharpens the total probability of each token,(∑p)2\left(\sum p\right)^{2}, and prefers B; the power distribution sums the sharpened probabilities of the completions,∑p2\sum p^{2}, and prefers A.Refer to captionFigure 13:Metropolis–Hastings for the power distribution (Equation160).Here the response is𝒙=(x0,…,xT){\bm{x}}=(x_{0},\ldots,x_{T})and the generator ispp(𝒚{\bm{y}}andπ0\pi_{0}in the text). A positionttis chosen uniformly, the tokens fromttonward are resampled with a proposal model (shaded), and the candidate𝒙′{\bm{x}}^{\prime}replaces𝒙{\bm{x}}with the acceptance probabilityA⁡(𝒙,𝒙′)A({\bm{x}},{\bm{x}}^{\prime})of Equation24, which needspαp^{\alpha}only up to normalization; the step is repeatedNstepN_{\mathrm{step}}times. Figure fromKaran and Du [100].

Sharpening without a Verifier.

The verifier can also be the generator itself. Takingr⁡(𝒙,𝒚)=log⁡π0​(𝒚∣𝒙)r({\bm{x}},{\bm{y}})=\log\pi_{0}({\bm{y}}\mid{\bm{x}})andλ=1/(α−1)\lambda=1/(\alpha-1)in Equation156gives the power distribution

πα​(𝒚∣𝒙)∝π0​(𝒚∣𝒙)α,α>1,\pi_{\alpha}({\bm{y}}\mid{\bm{x}})\propto\pi_{0}({\bm{y}}\mid{\bm{x}})^{\alpha},\qquad\alpha>1,(160)which is the EBM of the generator at the lower temperature1/α1/\alpha, or, for integerα\alpha, the product ofα\alphacopies of the generator (Section2.3).Karan and Du [100]show that sampling from Equation160elicits reasoning from base language models without additional training or a verifier. Its single-sample accuracy is comparable to that of reinforcement learning with GRPO on the domain used for post-training and its accuracy over multiple samples is higher, since it avoids the loss of diversity that RL post-training causes. Low-temperature decoding, which samples each token fromπ0​(yt∣𝒙,𝒚<t)α\pi_{0}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})^{\alpha}after normalization, does not sample Equation160, for the same reason as the token-level product Equation159. Writing the conditionals through the sum over completions in Equation158, the two choose the next token according to

πα​(yt∣𝒙,𝒚<t)∝∑𝒚>tπ0​(𝒚∣𝒙)αandπ0​(yt∣𝒙,𝒚<t)α∝(∑𝒚>tπ0​(𝒚∣𝒙))α,\pi_{\alpha}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})\propto\sum_{{\bm{y}}_{>t}}\pi_{0}({\bm{y}}\mid{\bm{x}})^{\alpha}\qquad\text{and}\qquad\pi_{0}(y_{t}\mid{\bm{x}},{\bm{y}}_{<t})^{\alpha}\propto\left(\sum_{{\bm{y}}_{>t}}\pi_{0}({\bm{y}}\mid{\bm{x}})\right)^{\alpha},(161)respectively. That is, the power distribution sums the sharpened likelihoods of the completions, whereas low-temperature decoding sharpens the sum of their likelihoods. The power distribution therefore prefers tokens with a few high-likelihood completions, and low-temperature decoding prefers tokens whose probability is spread over many low-likelihood completions[100], as illustrated in the example of Figure12. The sum on the left equalsπ0​(𝒚⩽t∣𝒙)​ψt​(𝒙,𝒚⩽t)\pi_{0}({\bm{y}}_{\leqslant t}\mid{\bm{x}})\,\psi_{t}({\bm{x}},{\bm{y}}_{\leqslant t})in Equation158for this reward and is intractable. Instead of approximating it,Karan and Du [100]sample Equation160with Metropolis–Hastings Equation24, illustrated in Figure13. The proposal resamples the response from a uniformly chosen position onward with a proposal language model, with the acceptance probability dependent only on likelihoods of the current and proposed responses under the generator and the proposal, since the partition function cancels, and the MCMC steps are applied progressively as the response is generated. In the terms of Section7.4, RL fine-tuning fits a mode-seeking approximation to a sharpened distribution, whereas MCMC samples the sharpened distribution itself, which is consistent with the diversity that power sampling retains.

Reasoning by Energy Minimization.

When the verifier is itself a learned energy over complete outputs,Eθ​(𝒙,𝒚)E_{\theta}({\bm{x}},{\bm{y}}), inference can refine a candidate rather than only select among candidates, by minimizing the energy Equation35. IREM[52]trains an energy so that a few steps of gradient descent on it reach the answer (Section2.5), and on algorithmic tasks it solves harder problems than those seen in training by running more steps at test time. IRED[54]learns a sequence of annealed energy landscapes, supervised through both their scores and their energies, optimizes from the smoothest landscape to the sharpest, and adapts the number of steps to the difficulty of each problem, which lets it solve harder Sudoku puzzles and plan paths in larger graphs than in training. Energy-Based Transformers[76]learn such energies over inputs and candidate predictions at the scale of language and vision models, and use extra minimization steps and comparisons between candidates as a form of deliberate thinking. Inference-time computation then has two axes: more minimization steps refine each candidate, and more restarts, compared by their energies, select among candidates, which is best-of-NNwithr=−Eθr=-E_{\theta}. The same inference-time computation applies to diffusion models, where a verifier enters as classifier guidance Equation86. The two axes become local and global search[203]: more MCMC steps on the summed energy of the model and the verifier at each noise level refine each sample[49], and more branches of the denoising process, compared by the verifier, select among samples through breadth-first or depth-first tree search.

7.3Compositional Reasoning

So far, verifiers and learned energies have scored complete solutions, and harder problems have been met by spending more computation on the same energy, as IREM and IRED do by running more minimization steps. Many reasoning problems, however, are defined by constraints on parts of their solutions. Each clause of a 3-SAT problem involves three variables, a valid coloring of a graph gives different colors to the two endpoints of every edge, and a solution of theNN-queens problem places one queen in every row and column and at most one on every diagonal. A network trained end to end to map problems to solutions must learn this whole map from examples, and it often fails on problems larger than those it was trained on. The energy view suggests a different decomposition, illustrated in Figure14: learn an energy for each kind of constraint, compose the energies of the constraints that appear in a new problem, and solve the problem by minimizing the composition[135].

Figure 14:Compositional reasoning by energy minimization.An energyEθE_{\theta}is trained on a single constraint, a row of a chessboard that must hold one queen or an edge whose endpoints must differ in color, to be low on valid assignments and high on invalid ones (left). For a new problem, the energies of all its constraints are summed as in Equation162: one term for each row, column, and diagonal of an8×88\times 8board, or for each edge of a larger graph, with outlines marking the variables of a few of the terms (middle). Minimizing the sum solves the problem (right). Adapted fromOarga and Du [135].#### Composed Energies.

We write a problem𝒙{\bm{x}}as a set of constraintsc1,…,cKc_{1},\ldots,c_{K}, whereckc_{k}involves the variables𝒚Sk{\bm{y}}_{S_{k}}of the solution, such as the two endpoints of an edge or the three variables of a clause. An energyEθ​(c,𝒚S)E_{\theta}(c,{\bm{y}}_{S})that is low on the assignments satisfying a single constraint is composed into the energy of the whole problem,

E⁡(𝒙,𝒚)=∑k=1KEθ​(ck,𝒚Sk),E({\bm{x}},{\bm{y}})=\sum_{k=1}^{K}E_{\theta}\left(c_{k},{\bm{y}}_{S_{k}}\right),(162)which is an MRF Equation9whose factors share one learned energy and whose graph is given by the problem. When a solution exists, the minimizers of Equation162satisfy every constraint, which is the logicalANDEquation16of Section2.3. A problem with more variables and constraints than any training problem is a longer sum of the same terms, so training needs to cover the kinds of constraints rather than their combinations, which is the sample-complexity argument of Section2.3applied to reasoning.Oarga and Du [135]train such energies on single clauses of 3-SAT, single edges of graph coloring, and the rows of oneNN-queens solution, using the energy-parameterized denoising objective of Section4.3together with a contrastive loss that raises the energy of invalid assignments (Section2.5). They compose the energies over whole problems, including SAT instances and graphs larger than any used in training, and, since a sum of separately trained energies can have spurious minima, they can fine-tune the composition on complete solutions.

Minimizing the Composition.

The composed energy is harder to minimize than any of its terms: its minima are where all terms agree, it is non-convex, and gradient descent or Langevin dynamics Equation25from a single initialization is easily trapped.Oarga and Du [135]minimize it with parallel energy minimization (PEM), an SMC procedure over the noise levels of the energy: a population of candidates starts from noise, and at each level, the candidates are resampled in proportion toexp⁡(−E)\exp\left(-E\right), perturbed with noise, and moved by a gradient step on the energy at that level. Resampling discards candidates in poor local minima, and the noise keeps the population spread over different solutions. More candidates solve more problems, so the computation spent at inference can grow with the difficulty of a problem, which a network that predicts the solution in a single pass cannot do. With this sampler, the composed energies outperform learned solvers trained end to end on most of theNN-queens, 3-SAT, and graph-coloring benchmarks considered, including their larger instances[135].

Relation to Planning and Verification.

The composed energy Equation162has the structure of the trajectory energies of Section6.5, which are composed from dynamics, goals, and obstacles, and of the constraint solvers composed from diffusion models[197]: in each, the factors are learned separately and the graph is chosen for each problem. In the terms of Section7.1, each factor is a local verifier, and their sum is a verifier for the whole problem that was never trained on a whole problem. Since this verifier is a differentiable energy, it can refine candidates as well as select them, and the samplers of Section7.2apply to it directly.

7.4Amortizing Inference-Time Computation

Inference-time methods spend computation on each new input to draw approximate samples from the target distribution in Equation156,

π⋆(𝒚∣𝒙)=π0​(𝒚∣𝒙)​exp⁡(r⁡(𝒙,𝒚)/λ)Z⁡(𝒙),Z(𝒙)=𝔼𝒚∼π0(⋅∣𝒙)[exp(r(𝒙,𝒚)/λ)].\pi^{\star}({\bm{y}}\mid{\bm{x}})=\frac{\pi_{0}({\bm{y}}\mid{\bm{x}})\exp\left(r({\bm{x}},{\bm{y}})/\lambda\right)}{Z({\bm{x}})},\qquad Z({\bm{x}})=\mathbb{E}_{{\bm{y}}\sim\pi_{0}(\cdot\mid{\bm{x}})}\left[\exp\left(r({\bm{x}},{\bm{y}})/\lambda\right)\right].This distribution reweights the pretrained modelπ0\pi_{0}toward responses with higher verifier scores. Fine-tuning amortizes this computation into the generator’s weights: it learns a modelπθ\pi_{\theta}that approximates the target across inputs, allowing high-reward responses to be generated with less search at inference time. Below, we discuss three approaches to learning such a model.

RL Fine-Tuning.

KL-regularized RL rewards high verifier scores while keeping the model close toπ0\pi_{0}. Substituting the definition ofπ⋆\pi^{\star}into its objective gives

𝔼𝒚∼πθ(⋅∣𝒙)[r(𝒙,𝒚)]−λKL(πθ∥π0)=−λKL(πθ∥π⋆)+λlogZ(𝒙).\mathbb{E}_{{\bm{y}}\sim\pi_{\theta}(\cdot\mid{\bm{x}})}\left[r({\bm{x}},{\bm{y}})\right]-\lambda\,\mathrm{KL}\left(\pi_{\theta}\,\|\,\pi_{0}\right)=-\lambda\,\mathrm{KL}\left(\pi_{\theta}\,\|\,\pi^{\star}\right)+\lambda\log Z({\bm{x}}).(163)SinceZ⁡(𝒙)Z({\bm{x}})does not depend onθ\theta, maximizing this objective is equivalent to minimizing the reverse KL to the target, as in variational inference (Equation29) and policy learning (Equation133). This objective is often mode-seeking: whenπθ\pi_{\theta}cannot matchπ⋆\pi^{\star}exactly, it may concentrate on a few high-probability regions of the target.

Practical algorithms build on this objective. GRPO[156], for example, uses REINFORCE-style policy gradients (Equation32) with rewards normalized within a group of responses to the same prompt. It subtracts the group’s mean reward and divides by its standard deviation, then combines these normalized rewards with PPO-style clipping and a KL penalty to the reference model.

Rejection-Sampling Fine-Tuning.

A second approach uses the verifier to construct a training dataset. For each input, we sample several responses fromπ0\pi_{0}, discard those that fail the verifier, and train the model on those that pass. This is the basic idea behind methods such as STaR[199]and RFT[198], and it amortizes the rejection sampler of Section7.2into the weights ofπθ\pi_{\theta}. For a binary verifier,r∈{0,1}r\in\left\{0,1\right\}, the accepted responses are exact samples ofπ⋆​(𝒚∣𝒙)=π0​(𝒚∣𝒙,r=1)\pi^{\star}({\bm{y}}\mid{\bm{x}})=\pi_{0}({\bm{y}}\mid{\bm{x}},r=1), theλ→0\lambda\to 0limit of the target (Section7.1), which keeps the relative probabilities thatπ0\pi_{0}assigns to correct responses and removes the incorrect ones. The expectedlog\log-likelihood of these responses is

𝔼𝒚∼π⋆(⋅∣𝒙)[logπθ(𝒚∣𝒙)]=−KL(π⋆∥πθ)−H(π⋆).\mathbb{E}_{{\bm{y}}\sim\pi^{\star}(\cdot\mid{\bm{x}})}\left[\log\pi_{\theta}({\bm{y}}\mid{\bm{x}})\right]=-\mathrm{KL}\left(\pi^{\star}\,\|\,\pi_{\theta}\right)-H\left(\pi^{\star}\right).(164)SinceH⁡(π⋆)H\left(\pi^{\star}\right)does not depend onθ\theta, maximum-likelihood training minimizes the forward KL toπ⋆\pi^{\star}. For a binary verifier, the target of RL fine-tuning in Equation163tends to the sameπ⋆\pi^{\star}asλ→0\lambda\to 0, but optimizes the KL in the opposite direction. If a fixed number of responses is sampled per prompt and the accepted ones are pooled, each prompt is weighted by its pass rate underπ0\pi_{0}, so prompts thatπ0\pi_{0}does not solve are not trained on. The forward KL is mass-covering and whenπθ\pi_{\theta}cannot matchπ⋆\pi^{\star}exactly, it spreads its probability over all the successful solutions found during sampling, and may also place probability on responses that fail. In contrast, the reverse KL of RL fine-tuning avoids failing responses but may drop some solutions.

Best-of-NNDistillation.

A third approach takes the best-of-NNpolicy Equation157, itself a residual EBM, as the target. BOND[155]fitsπθ\pi_{\theta}toπBoN\pi_{\text{BoN}}by minimizing the Jeffreys divergence, a weighted sum of the forward and reverse KL,

minθ(1−α)KL(πBoN∥πθ)+αKL(πθ∥πBoN),α∈[0,1],\min_{\theta}\;(1-\alpha)\,\mathrm{KL}\left(\pi_{\text{BoN}}\,\|\,\pi_{\theta}\right)+\alpha\,\mathrm{KL}\left(\pi_{\theta}\,\|\,\pi_{\text{BoN}}\right),\qquad\alpha\in[0,1],(165)which balances the mass-covering and mode-seeking tendencies of the two approaches above, so that a single sample ofπθ\pi_{\theta}emulates best-of-NN. The forward term is supervised fine-tuning on best-of-NNsamples ofπ0\pi_{0}, with gradient−𝔼𝒚∼πBoN​[∇θ​log​πθ​(𝒚∣𝒙)]-\mathbb{E}_{{\bm{y}}\sim\pi_{\text{BoN}}}\left[\nabla_{\theta}\log\pi_{\theta}({\bm{y}}\mid{\bm{x}})\right]. By Equation157,log⁡πBoN=log⁡π0+(N−1)​log⁡F𝒙​(r)+log⁡N\log\pi_{\text{BoN}}=\log\pi_{0}+(N-1)\log F_{\bm{x}}(r)+\log N, so up to a constant the reverse term is−(N−1)-(N-1)times the RL objective Equation163with the rewardlog⁡F𝒙​(r)\log F_{\bm{x}}(r)andλ=1/(N−1)\lambda=1/(N-1). It is therefore minimized by KL-regularized RL with thelog\log-quantile as the reward, where the quantileF𝒙​(r​(𝒙,𝒚))F_{\bm{x}}(r({\bm{x}},{\bm{y}})), the fraction of samples ofπ0\pi_{0}with reward at mostr⁡(𝒙,𝒚)r({\bm{x}},{\bm{y}}), is estimated by Monte Carlo. Iterative BOND repeats this distillation, each round distilling the best-of-NNof a moving anchor policy, the model of the previous round, so that each round applies the transformation Equation157to the previous model.Yang et al. [196]show that this iteration converges to the equilibrium of a game between policies, and replace it with the win rate dominance (WIND) fixed point

π†(𝒚∣𝒙)∝π0(𝒚∣𝒙)exp(w†(𝒙,𝒚)/λ),w†(𝒙,𝒚)=𝔼𝒚′∼π†(⋅∣𝒙)[𝟏{r(𝒙,𝒚)⩾r(𝒙,𝒚′)}],\pi^{\dagger}({\bm{y}}\mid{\bm{x}})\propto\pi_{0}({\bm{y}}\mid{\bm{x}})\exp\left(w^{\dagger}({\bm{x}},{\bm{y}})/\lambda\right),\qquad w^{\dagger}({\bm{x}},{\bm{y}})=\mathbb{E}_{{\bm{y}}^{\prime}\sim\pi^{\dagger}(\cdot\mid{\bm{x}})}\left[\mathbf{1}\left\{r({\bm{x}},{\bm{y}})\geqslant r({\bm{x}},{\bm{y}}^{\prime})\right\}\right],(166)a residual EBM whose energy is the win rate of𝒚{\bm{y}}against the policy itself, which they solve with more sample-efficient algorithms.

Fine-Tuned Models as Proposals.

A fine-tuned model can also serve as a proposal for the samplers of Section7.2. To useπθ\pi_{\theta}as an importance-sampling proposal for the original target, each candidate receives weight

ω⁡(𝒚,𝒙)=π0​(𝒚∣𝒙)​exp⁡(r⁡(𝒙,𝒚)/λ)πθ​(𝒚∣𝒙).\omega({\bm{y}},{\bm{x}})=\frac{\pi_{0}({\bm{y}}\mid{\bm{x}})\exp\left(r({\bm{x}},{\bm{y}})/\lambda\right)}{\pi_{\theta}({\bm{y}}\mid{\bm{x}})}.These weights correct for the change in proposal, providedπθ\pi_{\theta}assigns nonzero probability whereverπ⋆\pi^{\star}does. Whenπθ=π⋆\pi_{\theta}=\pi^{\star}, every weight equalsZ⁡(𝒙)Z({\bm{x}}): the generator already samples from the target. More generally, proposals that cover the target and produce less variable weights can reduce the number of candidates needed. A proposal concentrated on only a few solutions may rarely generate other responses favored by the target.

Tradeoff Between Finetuning and Inference.

More broadly, fine-tuning pays a training cost to reduce search across many later inputs, sometimes making a single sample sufficient. Inference-time methods spend computation on each input but can adapt to a new verifier without retraining the generator. The same trade-off appears between learned samplers and MCMC in Section2.4, and between policies and planners in Section6.5: computation can be spent during training to make later inference cheaper, or during inference to adapt to the problem at hand.

7.5Best-of-NNSampling-Aware Fine-Tuning

(a) Amortization (Section7.4)πθ\pi_{\theta}one sample𝒚∼πθ(⋅∣𝒙){\bm{y}}\sim\pi_{\theta}(\cdot\mid{\bm{x}})loss onπθ\pi_{\theta}:KL(πθ∥π⋆)\mathrm{KL}(\pi_{\theta}\,\|\,\pi^{\star}),KL(q∥πθ)\mathrm{KL}(q\,\|\,\pi_{\theta}), …gradient(b) Best-of-NNsampling fine-tuning (Section7.5)πθ\pi_{\theta}𝒚1,…,𝒚N{\bm{y}}_{1},\ldots,{\bm{y}}_{N}∼πθ(⋅∣𝒙)\sim\pi_{\theta}(\cdot\mid{\bm{x}})verifierrrarg⁡maxi⁡r⁡(𝒙,𝒚i)\arg\max_{i}r({\bm{x}},{\bm{y}}_{i})𝒚∼πBoN{\bm{y}}\sim\pi_{\text{BoN}}loss onπBoN\pi_{\text{BoN}}:log⁡πBoN\log\pi_{\text{BoN}}orRRgradient through the EBM form ofπBoN\pi_{\text{BoN}}

Figure 15:Two ways to fine-tune for inference-time computation.(a) Amortization trainsπθ\pi_{\theta}so that its own samples approximate the target, and inference draws a single sample. (b) Best-of-NNsampling fine-tuning keeps best-of-NNat inference time and trainsπθ\pi_{\theta}through the distributionπBoN\pi_{\text{BoN}}of the selected response, whose EBM form Equation167replaces the non-differentiable selection.One round of best-of-NNdistillation (Section7.4) makesπθ\pi_{\theta}only as good as best-of-NNofπ0\pi_{0}. To improve further, iterative BOND distills best-of-NNof the distilled model again, round after round, and byYang et al. [196]these rounds reach the WIND equilibrium Equation166only after distilling repeatedly until convergence. This motivates a different approach: keep best-of-NNwith a fixedNNat inference time, and update the base policy for it directly. Inference-aware fine-tuning[31]places the loss not onπθ\pi_{\theta}but on the distributionπBoN\pi_{\text{BoN}}of the response that best-of-NNreturns fromπθ\pi_{\theta}, as compared in Figure15. Since only the best ofNNsamples is used,πθ\pi_{\theta}does not need to put most of its mass on good responses; it only needs one of itsNNsamples to be good, which leaves room for diverse responses.

Best-of-NNPolicy as an EBM.

Best-of-NNselects by anarg⁡max\arg\maxoverNNsamples, which cannot be differentiated with respect toθ\theta. Its output distribution, however, has an explicit density: by Equation157withπθ\pi_{\theta}in place ofπ0\pi_{0},πBoN\pi_{\text{BoN}}is a residual EBM onπθ\pi_{\theta}whose energy is thelog\logwin rate of𝒚{\bm{y}}against samples ofπθ\pi_{\theta}.Chow et al. [31]use the variational approximation

πBoN(𝒚∣𝒙)=πθ​(𝒚∣𝒙)​exp⁡(βN​wθ​(𝒙,𝒚))Zθ​(𝒙),wθ(𝒙,𝒚)=𝔼𝒚′∼πθ(⋅∣𝒙)[𝟏{r(𝒙,𝒚)⩾r(𝒙,𝒚′)}],\pi_{\text{BoN}}({\bm{y}}\mid{\bm{x}})=\frac{\pi_{\theta}({\bm{y}}\mid{\bm{x}})\exp\left(\beta_{N}\,w_{\theta}({\bm{x}},{\bm{y}})\right)}{Z_{\theta}({\bm{x}})},\qquad w_{\theta}({\bm{x}},{\bm{y}})=\mathbb{E}_{{\bm{y}}^{\prime}\sim\pi_{\theta}(\cdot\mid{\bm{x}})}\left[\mathbf{1}\left\{r({\bm{x}},{\bm{y}})\geqslant r({\bm{x}},{\bm{y}}^{\prime})\right\}\right],(167)withβN\beta_{N}increasing inNN. Since bothπθ\pi_{\theta}and the win ratewθw_{\theta}depend onθ\theta, the unnormalizedlog\log-densityfθ=log⁡πθ+βN​wθf_{\theta}=\log\pi_{\theta}+\beta_{N}w_{\theta}has the gradient

∇θfθ(𝒙,𝒚)=∇θlogπθ(𝒚∣𝒙)−βN𝔼𝒚′∼πθ(⋅∣𝒙)[∇θlogπθ(𝒚′∣𝒙)1{r(𝒙,𝒚)<r(𝒙,𝒚′)}],\nabla_{\theta}f_{\theta}({\bm{x}},{\bm{y}})=\nabla_{\theta}\log\pi_{\theta}({\bm{y}}\mid{\bm{x}})-\beta_{N}\,\mathbb{E}_{{\bm{y}}^{\prime}\sim\pi_{\theta}(\cdot\mid{\bm{x}})}\left[\nabla_{\theta}\log\pi_{\theta}({\bm{y}}^{\prime}\mid{\bm{x}})\,\mathbf{1}\left\{r({\bm{x}},{\bm{y}})<r({\bm{x}},{\bm{y}}^{\prime})\right\}\right],(168)where the second term differentiates the win rate through the samples ofπθ\pi_{\theta}. The two losses below are written in terms of this gradient.

Supervised Fine-Tuning.

Given expert responses(𝒙,𝒚)∼𝒟({\bm{x}},{\bm{y}})\sim\mathcal{D}, inference-aware supervised fine-tuning maximizes their likelihood underπBoN\pi_{\text{BoN}}rather than underπθ\pi_{\theta},

maxθ⁡𝔼(𝒙,𝒚)∼𝒟​[log⁡πBoN​(𝒚∣𝒙)]=𝔼(𝒙,𝒚)∼𝒟​[log⁡πθ​(𝒚∣𝒙)+βN​wθ​(𝒙,𝒚)−log⁡Zθ​(𝒙)],\max_{\theta}\;\mathbb{E}_{({\bm{x}},{\bm{y}})\sim\mathcal{D}}\left[\log\pi_{\text{BoN}}({\bm{y}}\mid{\bm{x}})\right]=\mathbb{E}_{({\bm{x}},{\bm{y}})\sim\mathcal{D}}\left[\log\pi_{\theta}({\bm{y}}\mid{\bm{x}})+\beta_{N}\,w_{\theta}({\bm{x}},{\bm{y}})-\log Z_{\theta}({\bm{x}})\right],(169)whereZθ(𝒙)=𝔼𝒚∼πθ(⋅∣𝒙)[exp(βNwθ(𝒙,𝒚))]Z_{\theta}({\bm{x}})=\mathbb{E}_{{\bm{y}}\sim\pi_{\theta}(\cdot\mid{\bm{x}})}\left[\exp\left(\beta_{N}w_{\theta}({\bm{x}},{\bm{y}})\right)\right]. Its gradient is that of maximum likelihood for an EBM Equation40,

𝔼(𝒙,𝒚)∼𝒟[∇θfθ(𝒙,𝒚)]−𝔼𝒙∼𝒟,𝒚∼πBoN(⋅∣𝒙)[∇θfθ(𝒙,𝒚)],\mathbb{E}_{({\bm{x}},{\bm{y}})\sim\mathcal{D}}\left[\nabla_{\theta}f_{\theta}({\bm{x}},{\bm{y}})\right]-\mathbb{E}_{{\bm{x}}\sim\mathcal{D},\,{\bm{y}}\sim\pi_{\text{BoN}}(\cdot\mid{\bm{x}})}\left[\nabla_{\theta}f_{\theta}({\bm{x}},{\bm{y}})\right],(170)in which the expert responses are the positives and the responses selected by best-of-NNare the negatives. The first term increases the likelihood of the expert responses and their win rate againstπθ\pi_{\theta}, and the second lowers the likelihood of the responses that best-of-NNalready selects, which avoids over-fitting.

Reinforcement Learning.

With an environment rewardR⁡(𝒙,𝒚)R({\bm{x}},{\bm{y}}), which may differ from the verifier scorerr, inference-aware RL maximizes the reward of the selected response,

maxθJ(θ)=𝔼𝒙∼𝒟,𝒚∼πBoN(⋅∣𝒙)[R(𝒙,𝒚)],∇θJ(θ)=𝔼𝒙∼𝒟,𝒚∼πBoN[∇θfθ(𝒙,𝒚)(R(𝒙,𝒚)−b(𝒙))],\max_{\theta}\;J(\theta)=\mathbb{E}_{{\bm{x}}\sim\mathcal{D},\,{\bm{y}}\sim\pi_{\text{BoN}}(\cdot\mid{\bm{x}})}\left[R({\bm{x}},{\bm{y}})\right],\qquad\nabla_{\theta}J(\theta)=\mathbb{E}_{{\bm{x}}\sim\mathcal{D},\,{\bm{y}}\sim\pi_{\text{BoN}}}\left[\nabla_{\theta}f_{\theta}({\bm{x}},{\bm{y}})\left(R({\bm{x}},{\bm{y}})-b({\bm{x}})\right)\right],(171)with a baselineb(𝒙)=𝔼𝒚∼πBoN(⋅∣𝒙)[R(𝒙,𝒚)]b({\bm{x}})=\mathbb{E}_{{\bm{y}}\sim\pi_{\text{BoN}}(\cdot\mid{\bm{x}})}\left[R({\bm{x}},{\bm{y}})\right]. This is REINFORCE Equation32with the samples drawn from best-of-NNinstead of fromπθ\pi_{\theta}, and since the reward isRRrather thanrr, it also tolerates errors of the verifier.

Amortization (Section7.4) trainsπθ\pi_{\theta}to approximate the target on its own, whereas best-of-NNsampling-aware fine-tuning keeps best-of-NNat inference time and trainsπθ\pi_{\theta}for it. WritingπBoN\pi_{\text{BoN}}as a residual EBM onπθ\pi_{\theta}Equation167gives the selection a differentiable density, so supervised fine-tuning becomes maximum likelihood for this EBM, with best-of-NNsamples as negatives, and RL becomes REINFORCE on best-of-NNsamples. In both cases the generator is trained as a proposal for best-of-NNrather than as a sampler on its own, and it learns to interleave its best responses with more diverse ones, trading exploitation for exploration asNNgrows.

8Discussion

Throughout this tutorial, we have used EBMs as a single lens on machine learning. This organization grew out of the courseCSE 6243at Georgia Tech, where students appreciated learning machine learning along a single thread, in which each new method is introduced as a different choice within the same EBM framework, rather than as a catalog of separate model families, tasks, and algorithms, as in the traditional organization of machine learning courses. Any EBM is specified by three choices: the energy, which determines what the model can represent; the inference procedure, which samples from or optimizes the energy; and the learning method, which fits the energy to data. We close by summarizing how this view serves three purposes: understanding existing methods, organizing them into one framework, and developing new algorithms.

Understanding Existing Literature.

Many methods that were developed separately, often under different names and motivations, turn out to be EBMs with particular choices of the three components. In discriminative learning, logistic regression, CRFs, and structured prediction energy networks are conditional EBMs that differ in the structure of the energy over outputs (Section3). In generative modeling, GANs pair a potential with a learned sampler, normalizing flows and autoregressive models restrict the energy so that the partition function becomes tractable and sampling takes a single pass, diffusion and flow models learn the score of noise-perturbed EBMs, and energy-inspired and deep equilibrium models turn an inference procedure into the model itself (Section4). In representation learning, contrastive methods including MoCo, word2vec, BERT, diffusion representations, and denoising auto-encoders all learn a bilinear EBM whose factors are the representation, and they differ mainly in the learning method; for the denoising auto-encoder, the bilinear form follows from score matching of a latent-variable EBM (Section5). Instruction-following retrievers use the same bilinear EBM as a decisive model, by embedding the question as well as the data (Section5.5). In decision making, maximum-entropy RL, mirror-descent policy updates, and KL-regularized fine-tuning of language models from human feedback yield EBM policies in closed form, and inverse RL and imitation learning fit EBMs from demonstrations (Section6). Beyond the policy, an EBM world model of the dynamics gives a representation in which value functions are linear (Section6.4), and planning is inference in an EBM over trajectories (Section6.5). Inference-time computation in large models, such as best-of-NNselection, search over partial solutions, and iterative refinement, consists of samplers for one residual EBM that composes a pretrained generator with a verifier (Section7). Seen this way, the differences among these methods are differences in how they handle the partition function and sampling, rather than differences in what they model.

Organizing the Framework.

The three components also organize the methods into a common structure. On the learning side, maximum likelihood, contrastive divergence, NCE, pseudolikelihood, score matching, and adversarial training share the same gradient and differ only in the sampler that produces the negative samples (Section2.6). The same axis reappears in every application: SimCLR and CLIP use ranking NCE, SigLIP and word2vec use binary NCE, AmorLIP uses maximum likelihood with an amortized partition function, MoCo uses a fixed-point iteration, and diffusion representations and denoising auto-encoders use score matching (Section5); maximum-entropy IRL, implicit behavioral cloning, and GAIL fit EBMs from demonstrations by maximum likelihood, NCE, and adversarial training (Section6.3). On the inference side, MCMC, variational inference, and amortized samplers appear in the same roles, whether the samples are images, tokens, or actions (Section2.4, Section6.2, Section7), and fine-tuning and inference-time computation target the same KL-regularized EBM, differing only in whether its cost is paid during training or at inference (Section7.4), and best-of-NNsampling fine-tuning lies between the two, training the generator for the sampler that uses it (Section7.5). Placing a method on these axes makes its trade-offs explicit, such as the dependence of NCE on the batch size, the bias of short MCMC chains, or the loss of the global energy in autoregressive reparameterizations, and shows which alternatives are available for each component. Table3in AppendixAplaces every method of this tutorial on these components.

Developing New Algorithms.

Finally, the framework suggests new algorithms by replacing one component while keeping the others. Replacing the learning method of a known EBM gives new estimators: fitting the bilinear representation EBM by score matching instead of NCE gives diffusion spectral representations, and by maximum likelihood with an amortized partition function gives AmorLIP (Section5). Replacing the policy class in RL by an EBM, and its learning by reweighted score matching, gives diffusion policy optimization (Section6.2). Using the structure of the EBM itself gives new objectives: the smoothed Bellman equation of SBEED, and the value-incentivized regularizers of VAC and VPO, which use thelog\log-partition function of the EBM policy for optimism and pessimism (Section6.1). Placing the energy on the dynamics gives EBM world models, whose representation makes value functions linear and learnable by temporal-difference learning (Section6.4). Treating the best-of-NNpolicy itself as a residual EBM gives objectives for distilling it and for fine-tuning the generator for it (Section7.4, Section7.5). Using the learned energy itself rather than the representation, with an embedding head for the query and the instruction, gives decisive models that answer new questions in a single forward pass (Section5.5). Composition is perhaps the most distinctive capability: since the energies of independently trained models can be added to form products of distributions (Section2.3), as already exploited by classifier and classifier-free guidance (Section4.3), EBMs provide a principled way to combine pretrained models, constraints, and verifiers at inference time without retraining. In planning, learned dynamics, behavior priors, goals, and constraints each contribute an energy term, and a new task is a new sum of terms (Section6.5); in reasoning, energies learned for individual constraints are composed to solve problems larger than those seen in training (Section7.3). We expect this view to remain useful as new models are developed: whenever a model defines an unnormalized score over its outputs, the tools for inference and learning surveyed here apply to it directly.

Limitations.

The EBM view explains how methods relate, but it does not by itself tell which one works better. Two methods that fit the same energy can behave very differently in practice, since their performance also depends on how the energy is parameterized, on inductive biases such as the architecture and, in contrastive learning, the data augmentations that define the positive pairs, and on the statistical and computational properties of the estimator. The intended use also matters. Methods with the same optimum may serve different purposes, as the denoising auto-encoder and a diffusion model fit the same score at a given noise level but are used for representation and for sampling, respectively; and different uses favor different learning methods: maximum likelihood when calibrated likelihoods are needed, as for density evaluation, score matching when the model is used for sampling, since it learns the score that the sampler follows, and NCE when only relative scores between candidates matter, as in retrieval and ranking. Composition has limitations of its own: the composed distribution is meaningful only when the component energies have compatible scales and the product is normalizable, and sampling from or optimizing the composed landscape can be much harder than for each component. We therefore suggest that readers weigh these factors together for their own setting, and choose the parameterization of the energy and the methods for learning and inference to the characteristics of the problem.

Acknowledgements

This paper is supported by NSF ECCS-2401391, ONR N000142512173, NSF IIS-2403240, NSF IIS-2552007, DARPA Young Faculty Award, and the Toyota Research Institute.

References

  • [1]A. Ajay, Y. Du, A. Gupta, J. B. Tenenbaum, T. S. Jaakkola, and P. Agrawal(2023)Is conditional generative modeling all you need for decision making?.InInternational Conference on Learning Representations (ICLR),Cited by:§6.5.
  • [2]A. Ajay, S. Han, Y. Du, S. Li, A. Gupta, T. S. Jaakkola, J. B. Tenenbaum, L. P. Kaelbling, A. Srivastava, and P. Agrawal(2023)Compositional foundation models for hierarchical planning.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§6.5.
  • [3]M. S. Albergo and E. Vanden-Eijnden(2023)Building normalizing flows with stochastic interpolants.InInternational Conference on Learning Representations (ICLR),Cited by:§4.3.
  • [4]Y. Altun and A. Smola(2006)Unifying divergence minimization and statistical inference via convex duality.InConference on Learning Theory (COLT),pp. 139–153.Cited by:2nd item,§2.1,§2.2.
  • [5]M. Arbel, L. Zhou, and A. Gretton(2021)Generalized energy based models.InInternational Conference on Learning Representations (ICLR),Cited by:§2.1.
  • [6]M. Arjovsky, S. Chintala, and L. Bottou(2017)Wasserstein generative adversarial networks.InInternational Conference on Machine Learning (ICML),pp. 214–223.Cited by:§4.1.
  • [7]K. Asadi and M. L. Littman(2017)An alternative softmax operator for reinforcement learning.InInternational Conference on Machine Learning (ICML),pp. 243–252.Cited by:3rd item.
  • [8]H. Attias(2003)Planning by probabilistic inference.InInternational Conference on Artificial Intelligence and Statistics (AISTATS),Cited by:§6.5.
  • [9]J. Austin, D. D. Johnson, J. Ho, D. Tarlow, and R. van den Berg(2021)Structured denoising diffusion models in discrete state-spaces.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.5,§4.3,§5.3.
  • [10]S. Bai, J. Z. Kolter, and V. Koltun(2019)Deep equilibrium models.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§4.5,§4.5.
  • [11]S. Bai, V. Koltun, and J. Z. Kolter(2021)Stabilizing equilibrium models by Jacobian regularization.InInternational Conference on Machine Learning (ICML),pp. 554–565.Cited by:§4.5.
  • [12]X. Bai and L. Melas-Kyriazi(2024)Fixed point diffusion models.InIEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR),pp. 9430–9440.Cited by:§4.5.
  • [13]A. Banerjee, S. Merugu, I. S. Dhillon, and J. Ghosh(2005)Clustering with Bregman divergences.Journal of Machine Learning Research6,pp. 1705–1749.Cited by:1st item.
  • [14]A. Barp, F. Briol, A. B. Duncan, M. Girolami, and L. Mackey(2019)Minimum Stein discrepancy estimators.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.6.
  • [15]A. Barreto, W. Dabney, R. Munos, J. J. Hunt, T. Schaul, H. P. van Hasselt, and D. Silver(2017)Successor features for transfer in reinforcement learning.Advances in Neural Information Processing Systems (NeurIPS)30.Cited by:§6.4.
  • [16]M. Bauer and A. Mnih(2019)Resampled priors for variational autoencoders.InInternational Conference on Artificial Intelligence and Statistics (AISTATS),pp. 66–75.Cited by:§4.4.
  • [17]A. Beirami, A. Agarwal, J. Berant, A. D’Amour, J. Eisenstein, C. Nagpal, and A. T. Suresh(2025)Theoretical guarantees on the best-of-n alignment policy.InInternational Conference on Machine Learning (ICML),Cited by:§7.2.
  • [18]D. Belanger and A. McCallum(2016)Structured prediction energy networks.InInternational Conference on Machine Learning (ICML),pp. 983–992.Cited by:§3.2.
  • [19]D. Belanger, B. Yang, and A. McCallum(2017)End-to-end learning for structured prediction energy networks.InInternational Conference on Machine Learning (ICML),pp. 429–439.Cited by:§3.2.
  • [20]Y. Bengio, R. Ducharme, P. Vincent, and C. Jauvin(2003)A neural probabilistic language model.Journal of Machine Learning Research3,pp. 1137–1155.Cited by:§4.6.
  • [21]J. Besag(1975)Statistical analysis of non-lattice data.Journal of the Royal Statistical Society: Series D (The Statistician)24(3),pp. 179–195.Cited by:§2.5,§2.5,§3.1,2nd item.
  • [22]R. A. Bradley and M. E. Terry(1952)Rank analysis of incomplete block designs: i. The method of paired comparisons.Biometrika39(3/4),pp. 324–345.Cited by:§6.2.
  • [23]L. D. Brown(1986)Fundamentals of statistical exponential families: with applications in statistical decision theory.Lecture Notes–Monograph Series, Vol.9,Institute of Mathematical Statistics.Cited by:§2.1.
  • [24]T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell,et al.(2020)Language models are few-shot learners.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 1877–1901.Cited by:§4.6.
  • [25]S. Canu and A. Smola(2006)Kernel methods and the exponential family.Neurocomputing69(7–9),pp. 714–720.Cited by:2nd item.
  • [26]S. Cen, J. Mei, K. Goshvadi, H. Dai, T. Yang, S. Yang, D. Schuurmans, Y. Chi, and B. Dai(2025)Value-incentivized preference optimization: a unified approach to online and offline RLHF.InInternational Conference on Learning Representations (ICLR),Cited by:2nd item.
  • [27]H. Chen, Y. Du, Y. Chen, J. B. Tenenbaum, and P. A. Vela(2023)Planning with sequence models through iterative energy minimization.InInternational Conference on Learning Representations (ICLR),Cited by:§6.5.
  • [28]L. Chen, K. Lu, A. Rajeswaran, K. Lee, A. Grover, M. Laskin, P. Abbeel, A. Srinivas, and I. Mordatch(2021)Decision transformer: reinforcement learning via sequence modeling.InAdvances in Neural Information Processing Systems,Vol.34,pp. 15084–15097.Cited by:§6.5.
  • [29]R. T. Q. Chen, Y. Rubanova, J. Bettencourt, and D. Duvenaud(2018)Neural ordinary differential equations.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 6571–6583.Cited by:§4.2.
  • [30]T. Chen, S. Kornblith, M. Norouzi, and G. Hinton(2020)A simple framework for contrastive learning of visual representations.InInternational Conference on Machine Learning (ICML),pp. 1597–1607.Cited by:§5.1.
  • [31]Y. Chow, G. Tennenholtz, I. Gur, V. Zhuang, B. Dai, S. Thiagarajan, C. Boutilier, R. Agarwal, A. Kumar, and A. Faust(2025)Inference-aware fine-tuning for best-of-N sampling in large language models.InInternational Conference on Learning Representations (ICLR),Cited by:§7.5,§7.5.
  • [32]K. Cobbe, V. Kosaraju, M. Bavarian,et al.(2021)Training verifiers to solve math word problems.arXiv preprint arXiv:2110.14168.Cited by:§7.1.
  • [33]M. Collins(2002)Discriminative training methods for hidden Markov models: theory and experiments with perceptron algorithms.InConference on Empirical Methods in Natural Language Processing (EMNLP),pp. 1–8.Cited by:§3.1.
  • [34]B. Dai, H. Dai, A. Gretton, L. Song, D. Schuurmans, and N. He(2019)Kernel exponential family estimation via doubly dual embedding.InInternational Conference on Artificial Intelligence and Statistics (AISTATS),pp. 2321–2330.Cited by:2nd item,§2.4,§2.5.
  • [35]B. Dai, N. Li, and D. Schuurmans(2026)Spectral ghost in representation learning: from component analysis to self-supervised learning.arXiv preprint arXiv:2601.20154.Cited by:§5.1,§5.1,§5.1,§5.1,§5.2,§5.3,§5.4,§5.4,§5.4.
  • [36]B. Dai, Z. Liu, H. Dai, N. He, A. Gretton, L. Song, and D. Schuurmans(2019)Exponential family estimation via adversarial dynamics embedding.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.4,§2.4,§2.5,§2.5,§2.6,§2.6,§2.6,§2.6,Table 1,§4.1,§4.4.
  • [37]B. Dai, A. Shaw, L. Li, L. Xiao, N. He, Z. Liu, J. Chen, and L. Song(2018)SBEED: convergent reinforcement learning with nonlinear function approximation.InInternational Conference on Machine Learning (ICML),pp. 1125–1134.Cited by:3rd item,§6.3.
  • [38]H. Dai, B. Dai, and L. Song(2016)Discriminative embeddings of latent variable models for structured data.InInternational Conference on Machine Learning (ICML),pp. 2702–2711.Cited by:§2.5.
  • [39]Z. Dai, A. Almahairi, P. Bachman, E. Hovy, and A. Courville(2017)Calibrating energy-based generative adversarial networks.InInternational Conference on Learning Representations (ICLR),Cited by:§2.5,§2.5,§4.1.
  • [40]P. Dayan(1993)Improving generalization for temporal difference learning: the successor representation.Neural computation5(4),pp. 613–624.Cited by:§6.4.
  • [41]P. de Boer, D. P. Kroese, S. Mannor, and R. Y. Rubinstein(2005)A tutorial on the cross-entropy method.Annals of Operations Research134(1),pp. 19–67.Cited by:§6.5.
  • [42]M. Demircigil, J. Heusel, M. Löwe, S. Upgang, and F. Vermet(2017)On a model of associative memory with huge storage capacity.Journal of Statistical Physics168(2),pp. 288–299.Cited by:§4.4.
  • [43]Y. Deng, A. Bakhtin, M. Ott, A. Szlam, and M. Ranzato(2020)Residual energy-based models for text generation.InInternational Conference on Learning Representations (ICLR),Cited by:§2.1.
  • [44]J. Devlin, M. Chang, K. Lee, and K. Toutanova(2019)BERT: pre-training of deep bidirectional transformers for language understanding.InConference of the North American Chapter of the Association for Computational Linguistics (NAACL),pp. 4171–4186.Cited by:§5.3,§5.5.
  • [45]P. Dhariwal and A. Nichol(2021)Diffusion models beat GANs on image synthesis.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§4.3.
  • [46]N. Ding and S. V. N. Vishwanathan(2010)T-logistic regression.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 514–522.Cited by:1st item.
  • [47]L. Dinh, D. Krueger, and Y. Bengio(2015)NICE: non-linear independent components estimation.InInternational Conference on Learning Representations (ICLR) Workshop,Cited by:§4.2.
  • [48]L. Dinh, J. Sohl-Dickstein, and S. Bengio(2017)Density estimation using Real NVP.InInternational Conference on Learning Representations (ICLR),Cited by:§4.2.
  • [49]Y. Du, C. Durkan, R. Strudel, J. B. Tenenbaum, S. Dieleman, R. Fergus, J. Sohl-Dickstein, A. Doucet, and W. Grathwohl(2023)Reduce, reuse, recycle: compositional generation with energy-based diffusion models and MCMC.InInternational Conference on Machine Learning (ICML),pp. 8489–8510.Cited by:§2.3,Figure 4,3rd item,§4.3,§4.3,§6.5,§7.2.
  • [50]Y. Du and L. P. Kaelbling(2024)Position: compositional generative modeling: a single model is not all you need.InInternational Conference on Machine Learning (ICML),pp. 11721–11732.Cited by:item 1,§2.3,§2.3.
  • [51]Y. Du, S. Li, and I. Mordatch(2020)Compositional visual generation with energy based models.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 6637–6647.Cited by:Figure 1,§2.3,§2.3,§2.3.
  • [52]Y. Du, S. Li, J. Tenenbaum, and I. Mordatch(2022)Learning iterative reasoning through energy minimization.InInternational Conference on Machine Learning (ICML),pp. 5570–5582.Cited by:§2.5,§4.5,§7.2.
  • [53]Y. Du, T. Lin, and I. Mordatch(2019)Model based planning with energy based models.InConference on Robot Learning,Cited by:§6.5.
  • [54]Y. Du, J. Mao, and J. B. Tenenbaum(2024)Learning iterative reasoning through energy diffusion.InInternational Conference on Machine Learning (ICML),Cited by:§7.2.
  • [55]Y. Du and I. Mordatch(2019)Implicit generation and modeling with energy based models.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.5,§2.6.
  • [56]Y. Du, S. Yang, B. Dai, H. Dai, O. Nachum, J. B. Tenenbaum, D. Schuurmans, and P. Abbeel(2023)Learning universal policies via text-guided video generation.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:Figure 10,§6.5.
  • [57]Y. Du, S. Yang, P. Florence, F. Xia, A. Wahid, B. Ichter, P. Sermanet, T. Yu, P. Abbeel, J. B. Tenenbaum, L. P. Kaelbling, A. Zeng, and J. Tompson(2024)Video language planning.InInternational Conference on Learning Representations (ICLR),Cited by:§6.5.
  • [58]Y. Du(2025)Learning generalizable systems by learning composable energy landscapes.Ph.D. Thesis,Massachusetts Institute of Technology.Cited by:§2.3.
  • [59]S. Duane, A. D. Kennedy, B. J. Pendleton, and D. Roweth(1987)Hybrid Monte Carlo.Physics Letters B195(2),pp. 216–222.Cited by:§2.4.
  • [60]M. Dudík, S. J. Phillips, and R. E. Schapire(2007)Maximum entropy density estimation with generalized regularization and an application to species distribution modeling.Journal of Machine Learning Research8,pp. 1217–1260.Cited by:2nd item,§2.1,§2.2.
  • [61]B. Efron(2011)Tweedie’s formula and selection bias.Journal of the American Statistical Association106(496),pp. 1602–1614.Cited by:§4.3.
  • [62]B. Eysenbach and S. Levine(2022)Maximum entropy RL (provably) solves some robust RL problems.InInternational Conference on Learning Representations (ICLR),Cited by:4th item.
  • [63]C. Finn, P. Christiano, P. Abbeel, and S. Levine(2016)A connection between generative adversarial networks, inverse reinforcement learning, and energy-based models.arXiv preprint arXiv:1611.03852.Cited by:§6.3.
  • [64]C. Finn, S. Levine, and P. Abbeel(2016)Guided cost learning: deep inverse optimal control via policy optimization.InInternational Conference on Machine Learning (ICML),pp. 49–58.Cited by:§6.3.
  • [65]P. Florence, C. Lynch, A. Zeng, O. A. Ramirez, A. Wahid, L. Downs, A. Wong, J. Lee, I. Mordatch, and J. Tompson(2022)Implicit behavioral cloning.InConference on Robot Learning (CoRL),pp. 158–168.Cited by:§6.3.
  • [66]R. Fox, A. Pakman, and N. Tishby(2016)Taming the noise in reinforcement learning via soft updates.InConference on Uncertainty in Artificial Intelligence (UAI),pp. 582–591.Cited by:4th item.
  • [67]R. Frongillo and M. D. Reid(2014)Convex foundations for generalized MaxEnt models.InAIP Conference Proceedings,Vol.1636,pp. 11–16.Cited by:1st item,§2.2.
  • [68]J. Fu, K. Luo, and S. Levine(2018)Learning robust rewards with adversarial inverse reinforcement learning.InInternational Conference on Learning Representations (ICLR),Cited by:§6.3.
  • [69]C. Gao, H. Sun, N. Li, D. Schuurmans, and B. Dai(2025)Spectral representation-based reinforcement learning.arXiv preprint arXiv:2512.15036.Cited by:Figure 7,§6.4,§6.4,§6.4,§6.4,§6.4.
  • [70]R. Gao, E. Nijkamp, D. P. Kingma, Z. Xu, A. M. Dai, and Y. N. Wu(2020)Flow contrastive estimation of energy-based models.InIEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR),pp. 7518–7528.Cited by:§4.2.
  • [71]M. Geist, B. Scherrer, and O. Pietquin(2019)A theory of regularized Markov decision processes.InInternational Conference on Machine Learning (ICML),pp. 2160–2169.Cited by:§6.1.
  • [72]S. Geman and D. Geman(1984)Stochastic relaxation, Gibbs distributions, and the Bayesian restoration of images.IEEE Transactions on Pattern Analysis and Machine Intelligence6(6),pp. 721–741.Cited by:§2.4.
  • [73]Z. Geng, A. Pokle, and J. Z. Kolter(2023)One-step diffusion distillation via deep equilibrium models.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§4.5.
  • [74]Z. Geng, X. Zhang, S. Bai, Y. Wang, and Z. Lin(2021)On training implicit models.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§4.5.
  • [75]H. Georgii(2011)Gibbs measures and phase transitions.Vol.9,Walter de Gruyter.Cited by:§2.1.
  • [76]A. Gladstone, G. Nanduru, M. M. Islam,et al.(2026)Energy-based transformers are scalable learners and thinkers.InInternational Conference on Learning Representations (ICLR),Cited by:§7.2.
  • [77]I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio(2014)Generative adversarial nets.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 2672–2680.Cited by:§2.5,§4.1,§4.1.
  • [78]W. Grathwohl, R. T. Q. Chen, J. Bettencourt, I. Sutskever, and D. Duvenaud(2019)FFJORD: free-form continuous dynamics for scalable reversible generative models.InInternational Conference on Learning Representations (ICLR),Cited by:§4.2.
  • [79]P. D. Grünwald and A. P. Dawid(2004)Game theory, maximum entropy, minimum discrepancy and robust Bayesian decision theory.The Annals of Statistics32(4),pp. 1367–1433.Cited by:1st item,§2.2.
  • [80]L. Gui, C. Gârbacea, and V. Veitch(2024)BoNBoN alignment for large language models and the sweetness of best-of-n sampling.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§7.2.
  • [81]M. Gutmann and A. Hyvärinen(2010)Noise-contrastive estimation: a new estimation principle for unnormalized statistical models.InInternational Conference on Artificial Intelligence and Statistics (AISTATS),pp. 297–304.Cited by:§2.5,§2.5,§2.5.
  • [82]M. Gygli, M. Norouzi, and A. Angelova(2017)Deep value networks learn to evaluate and iteratively refine structured outputs.InInternational Conference on Machine Learning (ICML),pp. 1341–1351.Cited by:§3.2.
  • [83]T. Haarnoja, H. Tang, P. Abbeel, and S. Levine(2017)Reinforcement learning with deep energy-based policies.InInternational Conference on Machine Learning (ICML),pp. 1352–1361.Cited by:5th item,§6.2.
  • [84]T. Haarnoja, A. Zhou, P. Abbeel, and S. Levine(2018)Soft actor-critic: off-policy maximum entropy deep reinforcement learning with a stochastic actor.InInternational Conference on Machine Learning (ICML),pp. 1861–1870.Cited by:5th item,§6.2.
  • [85]W. K. Hastings(1970)Monte Carlo sampling methods using Markov chains and their applications.Biometrika57(1),pp. 97–109.Cited by:§2.4.
  • [86]K. He, H. Fan, Y. Wu, S. Xie, and R. Girshick(2020)Momentum contrast for unsupervised visual representation learning.InIEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR),pp. 9729–9738.Cited by:§5.1.
  • [87]G. E. Hinton(2002)Training products of experts by minimizing contrastive divergence.Neural Computation14(8),pp. 1771–1800.Cited by:§2.3,§2.5,§2.6.
  • [88]J. Ho and S. Ermon(2016)Generative adversarial imitation learning.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 4565–4573.Cited by:§6.3.
  • [89]J. Ho, A. Jain, and P. Abbeel(2020)Denoising diffusion probabilistic models.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 6840–6851.Cited by:§4.3.
  • [90]J. Ho and T. Salimans(2021)Classifier-free diffusion guidance.InNeurIPS Workshop on Deep Generative Models and Downstream Applications,Cited by:§4.3.
  • [91]M. D. Hoffman and A. Gelman(2014)The No-U-Turn sampler: adaptively setting path lengths in Hamiltonian Monte Carlo.Journal of Machine Learning Research15(1),pp. 1593–1623.Cited by:§2.4.
  • [92]E. Hoogeboom, A. A. Gritsenko, J. Bastings, B. Poole, R. van den Berg, and T. Salimans(2022)Autoregressive diffusion models.InInternational Conference on Learning Representations (ICLR),Cited by:§2.5,§4.6.
  • [93]J. J. Hopfield(1982)Neural networks and physical systems with emergent collective computational abilities.Proceedings of the National Academy of Sciences79(8),pp. 2554–2558.Cited by:§4.4.
  • [94]A. Hyvärinen(2005)Estimation of non-normalized statistical models by score matching.Journal of Machine Learning Research6,pp. 695–709.Cited by:§2.5,§2.5,§2.5.
  • [95]A. Hyvärinen(2006)Consistency of pseudolikelihood estimation of fully visible Boltzmann machines.Neural Computation18(10),pp. 2283–2292.Cited by:§2.5.
  • [96]A. Hyvärinen(2007)Some extensions of score matching.Computational Statistics & Data Analysis51(5),pp. 2499–2512.Cited by:§2.5,§2.6,§2.6.
  • [97]M. Janner, Y. Du, J. B. Tenenbaum, and S. Levine(2022)Planning with diffusion for flexible behavior synthesis.InInternational Conference on Machine Learning (ICML),pp. 9902–9915.Cited by:§6.5.
  • [98]M. Janner, Q. Li, and S. Levine(2021)Offline reinforcement learning as one big sequence modeling problem.InAdvances in Neural Information Processing Systems,Vol.34,pp. 1273–1286.Cited by:§6.5.
  • [99]H. J. Kappen(2005)Linear theory for control of nonlinear stochastic systems.Physical Review Letters95(20),pp. 200201.Cited by:§6.5.
  • [100]A. Karan and Y. Du(2025)Reasoning with sampling: your base model is smarter than you think.arXiv preprint arXiv:2510.14901.Cited by:Figure 13,§7.2,§7.2.
  • [101]T. Kim and Y. Bengio(2016)Deep directed generative models with energy-based probability estimation.arXiv preprint arXiv:1606.03439.Cited by:§2.4,§2.5,§2.5,§4.1.
  • [102]D. P. Kingma and P. Dhariwal(2018)Glow: generative flow with invertible 1x1 convolutions.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 10215–10224.Cited by:§4.2.
  • [103]D. P. Kingma, T. Salimans, R. Jozefowicz, X. Chen, I. Sutskever, and M. Welling(2016)Improved variational inference with inverse autoregressive flow.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 4743–4751.Cited by:§4.2.
  • [104]D. P. Kingma and M. Welling(2014)Auto-encoding variational Bayes.InInternational Conference on Learning Representations (ICLR),Cited by:§2.4,§2.4.
  • [105]D. Krotov and J. J. Hopfield(2016)Dense associative memory for pattern recognition.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 1172–1180.Cited by:§4.4.
  • [106]J. Lafferty, A. McCallum, and F. Pereira(2001)Conditional random fields: probabilistic models for segmenting and labeling sequence data.InInternational Conference on Machine Learning (ICML),pp. 282–289.Cited by:§3.1,§3.1.
  • [107]D. Lawson, G. Tucker, B. Dai, and R. Ranganath(2019)Energy-inspired models: learning with sampler-induced distributions.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 8501–8513.Cited by:§4.4.
  • [108]Y. LeCun, S. Chopra, R. Hadsell, M. Ranzato, and F. J. Huang(2006)A tutorial on energy-based learning.InPredicting Structured Data,Cited by:§3.1.
  • [109]S. Levine(2018)Reinforcement learning and control as probabilistic inference: tutorial and review.arXiv preprint arXiv:1805.00909.Cited by:1st item,§6.5.
  • [110]O. Levy and Y. Goldberg(2014)Neural word embedding as implicit matrix factorization.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 2177–2185.Cited by:§5.2.
  • [111]A. K. Lew, T. Zhi-Xuan, G. Grand, and V. K. Mansinghka(2023)Sequential Monte Carlo steering of large language models using probabilistic programs.arXiv preprint arXiv:2306.03081.Cited by:§7.2.
  • [112]X. L. Li, A. Holtzman, D. Fried, P. Liang, J. Eisner, T. Hashimoto, L. Zettlemoyer, and M. Lewis(2023)Contrastive decoding: open-ended text generation as optimization.InAnnual Meeting of the Association for Computational Linguistics (ACL),Cited by:§7.2.
  • [113]H. Lightman, V. Kosaraju, Y. Burda, H. Edwards, B. Baker, T. Lee, J. Leike, J. Schulman, I. Sutskever, and K. Cobbe(2024)Let’s verify step by step.InInternational Conference on Learning Representations (ICLR),Cited by:§7.2.
  • [114]B. G. Lindsay(1988)Composite likelihood methods.Contemporary Mathematics80,pp. 221–239.Cited by:§2.6.
  • [115]Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, and M. Le(2023)Flow matching for generative modeling.InInternational Conference on Learning Representations (ICLR),Cited by:§4.3.
  • [116]A. Liu, M. Sap, X. Lu, S. Swayamdipta, C. Bhagavatula, N. A. Smith, and Y. Choi(2021)DExperts: decoding-time controlled text generation with experts and anti-experts.InAnnual Meeting of the Association for Computational Linguistics (ACL),Cited by:§7.2.
  • [117]N. Liu, S. Li, Y. Du, A. Torralba, and J. B. Tenenbaum(2022)Compositional visual generation with composable diffusion models.InEuropean Conference on Computer Vision (ECCV),Cited by:§2.3,§2.3.
  • [118]Q. Liu and D. Wang(2016)Stein variational gradient descent: a general purpose Bayesian inference algorithm.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 2378–2386.Cited by:§6.2.
  • [119]X. Liu, C. Gong, and Q. Liu(2023)Flow straight and fast: learning to generate and transfer data with rectified flow.InInternational Conference on Learning Representations (ICLR),Cited by:§4.3.
  • [120]A. Lou, C. Meng, and S. Ermon(2024)Discrete diffusion modeling by estimating the ratios of the data distribution.InInternational Conference on Machine Learning (ICML),pp. 32819–32848.Cited by:§4.3.
  • [121]C. Lu, J. Chen, C. Li, Q. Wang, and J. Zhu(2021)Implicit normalizing flows.InInternational Conference on Learning Representations (ICLR),Cited by:§4.5.
  • [122]Y. Luo, C. Sun, J. B. Tenenbaum, and Y. Du(2024)Potential based diffusion motion planning.InInternational Conference on Machine Learning (ICML),Cited by:Figure 9,§6.5.
  • [123]H. Ma, T. Chen, K. Wang, N. Li, and B. Dai(2025)Efficient online reinforcement learning for diffusion policy.InInternational Conference on Machine Learning (ICML),pp. 41837–41853.Cited by:§6.2.
  • [124]Z. Ma and M. Collins(2018)Noise contrastive estimation and negative sampling for conditional models: consistency and statistical efficiency.InConference on Empirical Methods in Natural Language Processing (EMNLP),pp. 3698–3707.Cited by:§2.5,§2.5.
  • [125]N. Metropolis, A. W. Rosenbluth, M. N. Rosenbluth, A. H. Teller, and E. Teller(1953)Equation of state calculations by fast computing machines.The Journal of Chemical Physics21(6),pp. 1087–1092.Cited by:§2.4.
  • [126]T. Mikolov, K. Chen, G. Corrado, and J. Dean(2013)Efficient estimation of word representations in vector space.arXiv preprint arXiv:1301.3781.Cited by:§5.2.
  • [127]T. Mikolov, I. Sutskever, K. Chen, G. S. Corrado, and J. Dean(2013)Distributed representations of words and phrases and their compositionality.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 3111–3119.Cited by:§5.2,§5.2.
  • [128]O. Nachum, M. Norouzi, K. Xu, and D. Schuurmans(2017)Bridging the gap between value and policy based reinforcement learning.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 2775–2785.Cited by:5th item,§6.3.
  • [129]J. Naudts(2008)Generalised exponential families and associated entropy functions.Entropy10(3),pp. 131–149.Cited by:1st item,1st item.
  • [130]R. M. Neal(2011)MCMC using Hamiltonian dynamics.InHandbook of Markov Chain Monte Carlo,pp. 113–162.Cited by:§2.4.
  • [131]R. M. Neal(2005)Hamiltonian importance sampling.Note:Talk at the Banff International Research Station workshop on Mathematical Issues in Molecular Dynamics, June 2005. Slides:https://www.cs.utoronto.ca/~radford/ftp/his-talk.pdfCited by:§4.4.
  • [132]G. Neu, A. Jonsson, and V. Gómez(2017)A unified view of entropy-regularized Markov decision processes.arXiv preprint arXiv:1705.07798.Cited by:6th item.
  • [133]E. Nijkamp, M. Hill, S. Zhu, and Y. N. Wu(2019)Learning non-convergent non-persistent short-run MCMC toward energy-based model.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.6.
  • [134]S. Nowozin, B. Cseke, and R. Tomioka(2016)F-GAN: training generative neural samplers using variational divergence minimization.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 271–279.Cited by:§4.1.
  • [135]A. Oarga and Y. Du(2025)Generalizable reasoning through compositional energy minimization.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:Figure 14,§7.3,§7.3,§7.3.
  • [136]J. Ou, S. Nie, K. Xue, F. Zhu, J. Sun, Z. Li, and C. Li(2025)Your absorbing discrete diffusion secretly models the conditional distributions of clean data.InInternational Conference on Learning Representations (ICLR),Cited by:§2.5,§4.6.
  • [137]L. Ouyang, J. Wu, X. Jiang, D. Almeida, C. Wainwright, P. Mishkin, C. Zhang, S. Agarwal, K. Slama, A. Ray,et al.(2022)Training language models to follow instructions with human feedback.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 27730–27744.Cited by:§6.1.
  • [138]G. Papamakarios, T. Pavlakou, and I. Murray(2017)Masked autoregressive flow for density estimation.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 2338–2347.Cited by:§4.2.
  • [139]A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, G. Krueger, and I. Sutskever(2021)Learning transferable visual models from natural language supervision.InInternational Conference on Machine Learning (ICML),pp. 8748–8763.Cited by:§5.1.
  • [140]A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, and I. Sutskever(2019)Language models are unsupervised multitask learners.Technical reportOpenAI.Cited by:§4.6.
  • [141]R. Rafailov, A. Sharma, E. Mitchell, C. D. Manning, S. Ermon, and C. Finn(2023)Direct preference optimization: your language model is secretly a reward model.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 53728–53741.Cited by:§6.1,§6.2.
  • [142]H. Ramsauer, B. Schäfl, J. Lehner, P. Seidl, M. Widrich, L. Gruber, M. Holzleitner, T. Adler, D. Kreil, M. K. Kopp, G. Klambauer, J. Brandstetter, and S. Hochreiter(2021)Hopfield networks is all you need.InInternational Conference on Learning Representations (ICLR),Cited by:§4.4,§4.4.
  • [143]T. Ren, T. Zhang, L. Lee, J. E. Gonzalez, D. Schuurmans, and B. Dai(2023)Spectral decomposition representation for reinforcement learning.InThe Eleventh International Conference on Learning Representations (ICLR),Cited by:§6.4.
  • [144]T. Ren, T. Zhang, C. Szepesvári, and B. Dai(2022)A free lunch from the noise: provable and practical exploration for representation learning.InConference on Uncertainty in Artificial Intelligence (UAI),pp. 1686–1696.Cited by:§6.4,§6.4.
  • [145]Z. Ren, T. Ren, H. Ma, N. Li, and B. Dai(2025)Stochastic nonlinear control via finite-dimensional spectral dynamics embedding.IEEE Transactions on Automatic Control.Cited by:§6.4,§6.4.
  • [146]D. J. Rezende and S. Mohamed(2015)Variational inference with normalizing flows.InInternational Conference on Machine Learning (ICML),pp. 1530–1538.Cited by:§2.4,§2.5,§4.2.
  • [147]G. O. Roberts and R. L. Tweedie(1996)Exponential convergence of Langevin distributions and their discrete approximations.Bernoulli2(4),pp. 341–363.Cited by:§2.4.
  • [148]J. Rubin, O. Shamir, and N. Tishby(2012)Trading value and information in MDPs.InDecision Making with Imperfect Decision Makers,pp. 57–74.Cited by:4th item.
  • [149]R. Rubinstein(1999)The cross-entropy method for combinatorial and continuous optimization.Methodology and Computing in Applied Probability1(2),pp. 127–190.Cited by:§6.5.
  • [150]S. S. Sahoo, M. Arriola, Y. Schiff, A. Gokaslan, E. Marroquin, J. T. Chiu, A. Rush, and V. Kuleshov(2024)Simple and effective masked diffusion language models.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.5.
  • [151]T. Salimans and J. Ho(2021)Should EBMs model the energy or the score?.InICLR Workshop on Energy Based Models,Cited by:3rd item.
  • [152]J. Schulman, X. Chen, and P. Abbeel(2017)Equivalence between policy gradients and soft Q-learning.arXiv preprint arXiv:1704.06440.Cited by:6th item.
  • [153]J. Schulman, S. Levine, P. Abbeel, M. Jordan, and P. Moritz(2015)Trust region policy optimization.InInternational Conference on Machine Learning (ICML),pp. 1889–1897.Cited by:§6.1.
  • [154]J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov(2017)Proximal policy optimization algorithms.arXiv preprint arXiv:1707.06347.Cited by:§6.1.
  • [155]P. G. Sessa, R. Dadashi, L. Hussenot, J. Ferret, N. Vieillard, A. Ramé, B. Shariari, S. Perrin, A. Friesen, G. Cideron,et al.(2024)BOND: aligning LLMs with best-of-N distillation.arXiv preprint arXiv:2407.14622.Cited by:§7.4.
  • [156]Z. Shao, P. Wang, Q. Zhu,et al.(2024)DeepSeekMath: pushing the limits of mathematical reasoning in open language models.arXiv preprint arXiv:2402.03300.Cited by:§7.4.
  • [157]J. Shi, K. Han, Z. Wang, A. Doucet, and M. K. Titsias(2024)Simplified and generalized masked diffusion for discrete data.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§2.5.
  • [158]D. Shribak, C. Gao, Y. Li, C. Xiao, and B. Dai(2024)Diffusion spectral representation for reinforcement learning.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 110028–110056.Cited by:§5.4,§5.4,§6.4,§6.4.
  • [159]J. Sohl-Dickstein, P. B. Battaglino, and M. R. DeWeese(2011)New method for parameter estimation in probabilistic models: minimum probability flow.Physical Review Letters107(22),pp. 220601.Cited by:§2.6.
  • [160]J. Sohl-Dickstein, E. Weiss, N. Maheswaranathan, and S. Ganguli(2015)Deep unsupervised learning using nonequilibrium thermodynamics.InInternational Conference on Machine Learning (ICML),pp. 2256–2265.Cited by:§4.3.
  • [161]Y. Song and S. Ermon(2019)Generative modeling by estimating gradients of the data distribution.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 11918–11930.Cited by:§2.5,§2.5,§4.3.
  • [162]Y. Song, S. Garg, J. Shi, and S. Ermon(2019)Sliced score matching: a scalable approach to density and score estimation.InConference on Uncertainty in Artificial Intelligence (UAI),pp. 574–584.Cited by:§2.5.
  • [163]Y. Song, J. Sohl-Dickstein, D. P. Kingma, A. Kumar, S. Ermon, and B. Poole(2021)Score-based generative modeling through stochastic differential equations.InInternational Conference on Learning Representations (ICLR),Cited by:§2.5,§4.3,§4.3,§4.3.
  • [164]B. Sriperumbudur, K. Fukumizu, A. Gretton, A. Hyvärinen, and R. Kumar(2017)Density estimation in infinite dimensional exponential families.Journal of Machine Learning Research18(57),pp. 1–59.Cited by:2nd item.
  • [165]H. Sun, L. Yu, B. Dai, D. Schuurmans, and H. Dai(2023)Score-based continuous-time discrete diffusion models.InInternational Conference on Learning Representations (ICLR),Cited by:§2.5,§2.5,§4.3.
  • [166]H. Sun, Y. Li, Y. Zhuang, N. He, H. Dai, and B. Dai(2025)AmorLIP: efficient language-image pretraining via amortization.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 47754–47778.Cited by:§5.1.
  • [167]H. Sun, Y. Zhuang, W. Wei, C. Zhang, and B. Dai(2024)BBox-Adapter: lightweight adapting for black-box large language models.InInternational Conference on Machine Learning (ICML),pp. 47280–47304.Cited by:Figure 11,§7.1.
  • [168]B. Taskar, C. Guestrin, and D. Koller(2003)Max-margin Markov networks.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 25–32.Cited by:§3.1.
  • [169]E. Theodorou, J. Buchli, and S. Schaal(2010)A generalized path integral control approach to reinforcement learning.Journal of Machine Learning Research11,pp. 3137–3181.Cited by:§6.5.
  • [170]T. Tieleman(2008)Training restricted Boltzmann machines using approximations to the likelihood gradient.InInternational Conference on Machine Learning (ICML),pp. 1064–1071.Cited by:§2.6.
  • [171]E. Todorov(2006)Linearly-solvable Markov decision problems.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 1369–1376.Cited by:2nd item.
  • [172]M. Tomar, L. Shani, Y. Efroni, and M. Ghavamzadeh(2022)Mirror descent policy optimization.InInternational Conference on Learning Representations (ICLR),Cited by:§6.2.
  • [173]M. Toussaint(2009)Robot trajectory optimization using approximate inference.InInternational Conference on Machine Learning (ICML),pp. 1049–1056.Cited by:§6.5.
  • [174]I. Tsochantaridis, T. Joachims, T. Hofmann, and Y. Altun(2005)Large margin methods for structured and interdependent output variables.Journal of Machine Learning Research6,pp. 1453–1484.Cited by:§3.1,§3.2.
  • [175]L. Tu and K. Gimpel(2018)Learning approximate inference networks for structured prediction.InInternational Conference on Learning Representations (ICLR),Cited by:§3.2.
  • [176]TypeSafe AI(2026)Introducing system one models & Jev.Note:https://typesafe.ai/blog/introducing-system-one-models-and-jevCited by:§5.5.
  • [177]B. Uria, M. Côté, K. Gregor, I. Murray, and H. Larochelle(2016)Neural autoregressive distribution estimation.Journal of Machine Learning Research17(205),pp. 1–37.Cited by:§4.6.
  • [178]B. Uria, I. Murray, and H. Larochelle(2014)A deep and tractable density estimator.InInternational Conference on Machine Learning (ICML),pp. 467–475.Cited by:§2.5,§4.6.
  • [179]A. van den Oord, Y. Li, and O. Vinyals(2018)Representation learning with contrastive predictive coding.arXiv preprint arXiv:1807.03748.Cited by:§2.6,§5.1.
  • [180]A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin(2017)Attention is all you need.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§4.6.
  • [181]D. Vickrey, C. C. Lin, and D. Koller(2010)Non-local contrastive objectives.InInternational Conference on Machine Learning (ICML),pp. 1103–1110.Cited by:§2.6.
  • [182]P. Vincent, H. Larochelle, Y. Bengio, and P. Manzagol(2008)Extracting and composing robust features with denoising autoencoders.InInternational Conference on Machine Learning (ICML),pp. 1096–1103.Cited by:§5.4,§5.4,§5.4.
  • [183]P. Vincent(2011)A connection between score matching and denoising autoencoders.Neural Computation23(7),pp. 1661–1674.Cited by:§2.5,§4.3,§4.3,§5.4,§5.4,§5.4.
  • [184]N. Wagener, C. Cheng, J. Sacks, and B. Boots(2019)An online learning approach to model predictive control.InRobotics: Science and Systems (RSS),Cited by:§6.5.
  • [185]M. J. Wainwright and M. I. Jordan(2008)Graphical models, exponential families, and variational inference.Foundations and Trends® in Machine Learning1(1–2),pp. 1–305.Cited by:§2.1,§2.4,§3.1.
  • [186]R. Wang and Y. Du(2025)Equilibrium matching: generative modeling with implicit energy-based models.arXiv preprint arXiv:2510.02300.Cited by:§2.5,§4.5.
  • [187]X. Wang, J. Wei, D. Schuurmans, Q. Le, E. Chi, S. Narang, A. Chowdhery, and D. Zhou(2023)Self-consistency improves chain of thought reasoning in language models.InInternational Conference on Learning Representations (ICLR),Cited by:§7.2.
  • [188]M. Welling, M. Rosen-Zvi, and G. E. Hinton(2004)Exponential family harmoniums with an application to information retrieval.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 1481–1488.Cited by:§5.4.
  • [189]G. Williams, A. Aldrich, and E. A. Theodorou(2017)Model predictive path integral control: from theory to parallel computation.Journal of Guidance, Control, and Dynamics40(2),pp. 344–357.Cited by:§6.5.
  • [190]R. J. Williams(1992)Simple statistical gradient-following algorithms for connectionist reinforcement learning.Machine Learning8(3–4),pp. 229–256.Cited by:§2.4.
  • [191]E. Winston and J. Z. Kolter(2020)Monotone operator equilibrium networks.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§4.5.
  • [192]S. Wu Fung, H. Heaton, Q. Li, D. McKenzie, S. Osher, and W. Yin(2022)JFB: jacobian-free backpropagation for implicit networks.InAAAI Conference on Artificial Intelligence (AAAI),pp. 6648–6656.Cited by:§4.5.
  • [193]K. Yang and D. Klein(2021)FUDGE: controlled text generation with future discriminators.InConference of the North American Chapter of the Association for Computational Linguistics (NAACL),Cited by:§7.2.
  • [194]S. Yang, Y. Du, B. Dai, D. Schuurmans, J. B. Tenenbaum, and P. Abbeel(2024)Probabilistic adaptation of black-box text-to-video models.InInternational Conference on Learning Representations (ICLR),Cited by:§2.3,§4.3,§7.1.
  • [195]T. Yang, B. Dai, L. Xiao, and Y. Chi(2025)Exploration from a primal-dual lens: value-incentivized actor-critic methods for sample-efficient online RL.InAdvances in Neural Information Processing Systems (NeurIPS),pp. 40470–40521.Cited by:1st item.
  • [196]T. Yang, J. Mei, H. Dai, Z. Wen, S. Cen, D. Schuurmans, Y. Chi, and B. Dai(2025)Faster WIND: accelerating iterative best-of-N distillation for LLM alignment.arXiv preprint arXiv:2410.20727.Cited by:§7.4,§7.5.
  • [197]Z. Yang, J. Mao, Y. Du, J. Wu, J. B. Tenenbaum, T. Lozano-Pérez, and L. P. Kaelbling(2023)Compositional diffusion-based continuous constraint solvers.InConference on Robot Learning (CoRL),pp. 3242–3265.Cited by:item 1,§2.3,§7.3.
  • [198]Z. Yuan, H. Yuan, C. Li, G. Dong, K. Lu, C. Tan, C. Zhou, and J. Zhou(2023)Scaling relationship on learning mathematical reasoning with large language models.arXiv preprint arXiv:2308.01825.Cited by:§7.4.
  • [199]E. Zelikman, Y. Wu, J. Mu, and N. D. Goodman(2022)STaR: bootstrapping reasoning with reasoning.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:§7.4.
  • [200]X. Zhai, B. Mustafa, A. Kolesnikov, and L. Beyer(2023)Sigmoid loss for language image pre-training.InIEEE/CVF International Conference on Computer Vision (ICCV),pp. 11975–11986.Cited by:§5.1.
  • [201]R. Zhang, Y. Hu, and N. Li(2024)Soft robust MDPs and risk-sensitive MDPs: equivalence, policy gradient, and sample complexity.InInternational Conference on Learning Representations (ICLR),Cited by:4th item.
  • [202]T. Zhang, T. Ren, C. Xiao, W. Xiao, J. E. Gonzalez, D. Schuurmans, and B. Dai(2023)Energy-based predictive representations for partially observed reinforcement learning.InProceedings of the Conference on Uncertainty in Artificial Intelligence (UAI),pp. 2477–2487.Cited by:§6.4.
  • [203]X. Zhang, H. Lin, H. Ye, J. Y. Zou, J. Ma, Y. Liang, and Y. Du(2026)Inference-time scaling of diffusion models through classical search.InInternational Conference on Learning Representations,Vol.2026,pp. 39133–39166.Cited by:§7.2.
  • [204]S. Zhao, R. Brekelmans, A. Makhzani, and R. Grosse(2024)Probabilistic inference in language models via twisted sequential Monte Carlo.InInternational Conference on Machine Learning (ICML),Cited by:§7.2.
  • [205]Y. Zhuang, A. Trinh, R. Qiang, H. Sun, C. Zhang, H. Dai, and B. Dai(2025)Towards better instruction following retrieval models.arXiv preprint arXiv:2505.21439.Cited by:§5.5,§5.5.
  • [206]B. D. Ziebart, J. A. Bagnell, and A. K. Dey(2010)Modeling interaction via the principle of maximum causal entropy.InInternational Conference on Machine Learning (ICML),pp. 1255–1262.Cited by:§6.3.
  • [207]B. D. Ziebart, A. L. Maas, J. A. Bagnell, and A. K. Dey(2008)Maximum entropy inverse reinforcement learning.InAAAI Conference on Artificial Intelligence (AAAI),pp. 1433–1438.Cited by:1st item,§6.3.

Appendix AOverview of Methods

Table3summarizes the methods discussed in this tutorial by the three components of an EBM, the energy, the inference procedure, and the learning method, together with how each handles the partition function. Each entry follows the corresponding section, listed in the last column.

Table 3:Methods in this tutorial as EBMs.MethodEnergyInferenceLearningPartition functionSec.Logistic regressionlinear infb​(𝒙)f_{b}({\bm{x}})energy minimizationMLEexact by enumeration3.1Chain CRFunary and pairwise termsViterbiMLE; max-marginexact by the forward algorithm3.1SPENdeep, non-decomposable over𝒚{\bm{y}}projected gradient descent on relaxed𝒚{\bm{y}}structured SVM; end-to-endintractable; no probabilistic model3.2GANdiscriminator as potentiallearned generatoradversarialpotential need not be normalized; generator samples the EBM only with entropy regularization4.1Normalizing flow−log⁡p-\log pby change of variablesexact, one pass𝒙=gθ​(𝒛){\bm{x}}=g_{\theta}(\bm{z})exact MLE, no negative phaseZθ=1Z_{\theta}=1for everyθ\theta4.2Diffusion / flow matchingfamily of EBMs{pt}\{p_{t}\}, one per noise levelreverse SDE/ODE; annealed Langevindenoising score matching; velocity regressiondrops out of the score4.3Energy-inspired modellearnedEθE_{\theta}times proposalπ\piSNIS / Hamiltonian importance samplinglower bound on sampler likelihood (ranking NCE)batch denominator→Zθ\to Z_{\theta}asK→∞K\to\infty4.4Modern Hopfieldlog-sum-exp energy of stored patternsCCCP update,i.e., attention——4.4DEQfixed point; energy minimizer only ifffis a gradient steproot findingimplicit differentiation—4.5Autoregressivesum of normalized conditionalsancestral samplingexact MLE, per-step cross-entropiessoftmax over|V||V|per step4.6SimCLR / CLIP−ϕθ​(𝒙)⊤​ψθ​(𝒚)-\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})— (energy discarded)ranking NCEcancels in softmax; batch sum, biased for smallKK5.1SigLIP−ϕθ​(𝒙)⊤​ψθ​(𝒚)-\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})—binary NCElearnedb=−log⁡Zθb=-\log Z_{\theta}5.1Word2vecuw⊤​vcu_{w}^{\top}v_{c}—binary NCEbias fixed, shift−log⁡k-\log k5.2MoCoϕθ​(𝒙)⊤​ϕ(ℓ)​(𝒚)\phi_{\theta}({\bm{x}})^{\top}\phi^{(\ell)}({\bm{y}}), target frozen—fixed-point iteration via ranking NCEcancels in softmax; negatives from queue5.1AmorLIP−ϕθ​(𝒙)⊤​ψθ​(𝒚)-\phi_{\theta}({\bm{x}})^{\top}\psi_{\theta}({\bm{y}})—MLEamortized by a light network5.1BERT−ϕθ​(𝒙~)⊤​ψ​(𝒙M)-\phi_{\theta}(\tilde{\bm{x}})^{\top}\psi({\bm{x}}_{M}), summed over masked positions—MLE at a fixed mask ratiot0t_{0}factorizes over masked positions5.3DAEhθ​(𝒙~)⊤​ψθ​(𝒙)h_{\theta}(\tilde{\bm{x}})^{\top}\psi_{\theta}({\bm{x}})—score matching (Gaussian MLE)avoided5.4Diffusion spectral repr.ϕθ​(𝒙)⊤​μθ​(𝒚~,t)\phi_{\theta}({\bm{x}})^{\top}\mu_{\theta}(\tilde{\bm{y}},t)—score matchingdrops out of the score5.4InF-Embed / decisive modelsθ​(X,Q)s_{\theta}(X,Q);ϕθ​(X)⊤​ψθo​(Q)\phi_{\theta}(X)^{\top}\psi^{o}_{\theta}(Q)sigmoid or softmax over candidates, one forward passranking NCEover candidates𝒪⁡(Q)\mathcal{O}(Q)5.5MaxEnt RL / softQQ−Q/λ-Q/\lambdaexact softmax; Langevin; amortized SVGD; Gaussian (SAC)soft BellmanV=λ​log⁡ZV=\lambda\log Z6.1,6.2KL-regularized RL / RLHFπ0​exp⁡(r/λ)\pi_{0}\exp(r/\lambda)closed-form residual EBMmirror descent (TRPO/PPO); DPOcancels in DPO6.1Diffusion policy−Q/λ-Q/\lambdareverse diffusionreweighted score matchingabsorbed by the reweighting6.2MaxEnt IRL−-return over trajectoriessoft-optimal policyMLEZθ=𝔼ρ​[exp⁡Vθ]Z_{\theta}=\mathbb{E}_{\rho}[\exp V_{\theta}]6.3IBC / GAILpolicy energyEθ​(s,a)E_{\theta}(s,a)energy minimization / policy samplerranking NCE / adversarialcancels (NCE); avoided (adversarial)6.3EBM world model−ϕθ​(s,a)⊤​νθ​(s′)-\phi_{\theta}(s,a)^{\top}\nu_{\theta}(s^{\prime})no sampling: representation and TDranking NCE; score matchinglinearized by random features6.4Trajectory planningdynamics, behavior prior, cost, and goalMPPI/CEM; Langevin; diffusion; searchterms learned or specified separatelyZ=𝔼p0​[exp⁡(R/λ)]Z=\mathbb{E}_{p_{0}}[\exp(R/\lambda)]6.5Best-of-NN/ SMC / power samplingπ0​exp⁡(r/λ)\pi_{0}\exp(r/\lambda);π0α\pi_{0}^{\alpha}rejection sampling; IS; SMC; MH—IS weights; cancels in MH7.2BBox-Adapterπ0​(𝒚∣𝒙)​exp⁡(gθ​(𝒙,𝒚))\pi_{0}({\bm{y}}\mid{\bm{x}})\exp(g_{\theta}({\bm{x}},{\bm{y}}))π0\pi_{0}proposes,gθg_{\theta}scores in beam searchranking NCE withπ0\pi_{0}as noiselog⁡π0\log\pi_{0}cancels from the logits7.1IREM / IRED / EBTlearned energyEθ​(𝒙,𝒚)E_{\theta}({\bm{x}},{\bm{y}})over complete outputsgradient descent with restartsfew-step descent; annealed landscapes—7.2Compositional reasoningMRF sharing one learned energyparallel energy minimizationdenoising and contrastive, per constraint—7.3RL / rejection-sampling fine-tuningπ0​exp⁡(r/λ)\pi_{0}\exp(r/\lambda)less search, sometimes a single samplereverse KL (RL); forward KL (rejection sampling)Z⁡(𝒙)Z({\bm{x}})drops out7.4BONDπBoN\pi_{\text{BoN}}, energylog⁡F𝒙​(r)\log F_{\bm{x}}(r)onπ0\pi_{0}a single sampleJeffreys divergence toπBoN\pi_{\text{BoN}}: SFT on best-of-NNsamples and RL withlog⁡F𝒙​(r)\log F_{\bm{x}}(r)πBoN\pi_{\text{BoN}}normalized in closed form7.4Iterative BONDbest-of-NNof the previous modela single sampleBOND repeated with a moving anchornormalized in closed form7.4WINDwin rate against the policy itself, onπ0\pi_{0}a single samplefixed point of iterative BOND, with sample-efficient solvers—7.4Inference-aware fine-tuningπθ​exp⁡(βN​wθ)\pi_{\theta}\exp(\beta_{N}w_{\theta}),wθw_{\theta}the win ratebest-of-NNoverπθ\pi_{\theta}likelihood or reward underπBoN\pi_{\text{BoN}}samples ofπBoN\pi_{\text{BoN}}in the gradient7.5

Similar Articles

Implicit generation and generalization methods for energy-based models

OpenAI Blog

OpenAI presents implicit generation and generalization methods for energy-based models (EBMs) that use Langevin dynamics for iterative refinement to generate samples without explicit generator networks. The approach offers advantages including adaptive computation time, flexibility in learning disconnected data modes, and built-in compositionality through product of experts.

A connection between generative adversarial networks, inverse reinforcement learning, and energy-based models

OpenAI Blog

This paper establishes mathematical equivalences between generative adversarial networks (GANs), inverse reinforcement learning (IRL), and energy-based models (EBMs), demonstrating that certain IRL methods are equivalent to GANs with evaluable generator density. The work bridges three research communities to enable knowledge transfer for developing more stable and scalable algorithms.

Energy Generative Modeling: A Lyapunov-based Energy Matching Perspective

arXiv cs.LG

This paper proposes a unified framework for energy-based generative models by casting density transport as a nonlinear control problem with KL divergence as a Lyapunov function. It derives finite-step stopping criteria and demonstrates how nonlinear control theory tools can be applied to static scalar energy models.

OpenESM: Energy-Steered Models Are Scalable Foundation Learners

Hugging Face Daily Papers

OpenESM 提出能量引导模型(ESM),将能量引导的潜状态优化与 token 生成统一到单一架构中,在大规模语料上进行能量引导预训练,表现出良好的扩展性并在多数下游任务上超越 GPT,同时完全开源模型权重与训练基础设施。