Predictive Embeddings, JEPA, and Energy-Based Models › Energy Functions and Compatibility Learning
World Models HandbookAll chapters Predictive Embeddings, JEPA, and Energy-Based Models › Energy Functions and Compatibility LearningOne section · Sections in this chapter4 / 10 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Energy functions supply a scalar language for compatibility and multimodal prediction. They cover normalized probabilistic models, explicit-negative contrastive objectives, and unnormalized scores, but writing a stop-gradient discrepancy as an energy does not by itself explain the optimization dynamics that prevent collapse. The distinctions between these uses matter more here than a single historical lineage.
Definition and the Boltzmann connection
An energy-based model assigns a scalar energy to a pair. When the energy is measurable and the partition function satisfies , it defines a density over continuous relative to a chosen base measure through the Boltzmann, or Gibbs, form:
where:
- : the conditional density over targets given context
- : the context input
- : the target variable
- : the parameters of the energy function
- : the scalar energy assigned to the pair , parameterized by
- : the partition function, which normalizes the distribution over
- : a dummy variable of integration over possible targets under base measure
For a discrete target space, the integral in is replaced by a sum. Adding an -dependent constant to every energy leaves the normalized conditional distribution unchanged. Only energy differences matter, so the energy zero point, or additive offset, is not identifiable; multiplying all energies would generally change the distribution's effective temperature. A low energy is not by itself a probability. In continuous spaces, probability mass depends on the relative depths and integrated shapes or volumes of the wells, not depth alone.
The quantity is the partition function. Computing or differentiating it is a central practical difficulty in likelihood-based energy learning. Training by maximum likelihood gives
where:
- : the gradient, with respect to , of the model log-density of the observed target
- : the context input
- : the observed target
- : the parameters of the energy function
- : the gradient of the energy of the observed pair
- : the expected energy gradient under the model's current distribution over
- : a sample from the model distribution
The first term is the positive phase: it pushes the energy of observed pairs down. The second term is the negative phase: it pushes up the energy of pairs the model currently considers likely. Without the negative phase, nothing in this maximum-likelihood objective opposes lowering observed energies through a broad or nearly uniform downward shift, so the model need not learn meaningful relative normalization. Approximating the model expectation is the main computational problem for likelihood-trained EBMs. Other energy objectives replace maximum likelihood rather than approximate this particular term.
Different objectives under the energy lens
Maximum-likelihood sampling. Run Langevin dynamics or a Markov chain targeting to draw for the negative phase. Under suitable convergence conditions this is exact in the limit, but high-dimensional mixing can be slow or unstable. Denoising diffusion uses a different construction in which iterative sampling is part of the model; for a normalized Gibbs density the score identity is .
Contrastive estimation. Train a sampled classification objective over one positive and a finite candidate set of negatives drawn from a chosen marginal, minibatch, noise distribution, or proposal. The candidates are generally resampled during training; they are not equilibrium samples from the current EBM. A canonical form is InfoNCE:
where:
- : the context input
- : the true successor (positive example)
- : the -th negative example drawn from a proposal distribution
- : the number of negatives
- : the parameters of the energy function
- : the energy assigned to the pair
- the expectation is over the data distribution and the negative sampling distribution
- : the InfoNCE contrastive loss
Under the standard sampling construction, with one positive from the joint distribution and negatives drawn independently from the target marginal, InfoNCE yields the lower bound , where and are the context and target random variables. Increasing the candidate count can raise the ceiling of this particular bound, but a tighter numerical bound is not guaranteed for every finite model or negative sampler. Computing more candidate scores also raises training cost.
Asymmetry. The third option, used by several joint-embedding methods, is to avoid explicit negatives and use architectural asymmetry together with other anti-collapse mechanisms. The illustrative squared prediction discrepancy used here can be read as a compatibility score
where:
- : the context input
- : the target input
- : conditioning information, such as an action
- : the context encoder, parameterized by
- : the parameters of the context encoder
- : the target encoder, parameterized by
- : the parameters of the target encoder
- : the predictor, parameterized by
- : the parameters of the predictor
- : the predictor applied to the context embedding and conditioning input
- : the stop-gradient target embedding
- : the compatibility energy assigned to the pair under conditioning , parameterized by , , and
- : the stop-gradient operator, which detaches its argument from the computation graph
- : the squared Euclidean norm
but stop-gradient and EMA do not estimate the maximum-likelihood negative-phase expectation above. They change the optimization dynamics of the positive-pair regression problem. Because the target branch is detached and, with an EMA decay close to one, updated on a slower timescale, the two branches cannot co-adapt through the same instantaneous gradient. Collapse can still be a mathematical solution, so practical methods rely on combinations of architecture, normalization, predictor dynamics, data augmentation or masking, and, in some variants, explicit variance regularization. Calling the method self-distillation describes the teacher-student relation; it should not be mistaken for likelihood training of a normalized energy model.
Compatibility learning uses an energy to measure how well two entities fit together: a state and its successor, a goal and a trajectory, or an action and a state. Low energy means compatible; high energy means incompatible. When an energy is the negative log of an unnormalized trajectory posterior, minimizing it corresponds to MAP, or a zero-temperature limit of, control as inference from Part II: Inference, Decisions, and Control. This relation is not restricted to discrete control.
Why the energy view is worth the detour
Three practical benefits come from thinking in energies rather than in losses.
First, you can compose energies. If scores progress toward a goal and scores obstacle avoidance, then, for , expresses a weighted soft tradeoff. For nonnegative, comparably scaled penalties with aligned zero points, the sublevel set lies inside , which supports an approximate joint-constraint interpretation. Arbitrary energies do not implement an exact intersection, and new terms must be calibrated against the existing objective.
Second, an energy can represent multiple separated low-energy wells, although sampling among them may still be difficult. A squared-error point predictor instead returns the conditional mean. Depending on the mode locations and probabilities, that mean can lie between the wells, including in an implausible high-energy region.
Third, the energy lens covers several objectives without making them equivalent. Contrastive predictive coding and InfoNCE use sampled classification; triplet and margin losses use discriminative ranking; score matching uses a derivative-based criterion that avoids the partition function. For likelihood-trained EBMs, ask how the negative phase is estimated. For alternative objectives, ask what replaces likelihood training and what prevents a flat, uninformative score.
The cost is that sampling or minimizing a general high-dimensional energy is often iterative, and evaluating is intractable in general. Tractable structure or an amortized proposal can reduce that cost. When iterative inference requires many model evaluations, its latency can matter in planners with tight per-query budgets.