Training Energy-Based Models Without Normalization Constants

57 concepts54 papers1 proposal

Probabilistic modeling often forces a difficult trade-off between expressivity and tractability. Ideally, we want to define a probability distribution $p(x)$ using a highly flexible function, such as a deep neural network. Energy-Based Models (EBMs) allow us to do exactly this by expressing the probability density as:

$$p(x; \theta) = \frac{e^{-E(x; \theta)}}{Z(\theta)}$$

where $E(x; \theta)$ is the energy function mapping an input $x$ to a scalar value, and $Z(\theta)$ is the normalization constant, or partition function, defined as the integral over the entire input space:

$$Z(\theta) = \int e^{-E(x; \theta)} dx$$

The core crisis of EBMs is that computing $Z(\theta)$ is mathematically intractable for high-dimensional data. Because $Z(\theta)$ depends on the model parameters $\theta$, we cannot simply ignore it during training. If we attempt to train the model using standard Maximum Likelihood Estimation (MLE), the gradient of the log-likelihood with respect to $\theta$ yields two opposing forces:

$$\nabla_\theta \log p(x; \theta) = -\nabla_\theta E(x; \theta) + \mathbb{E}_{x' \sim p(x'; \theta)}[\nabla_\theta E(x'; \theta)]$$

The first term is simple: it pushes down the energy of the observed data point $x$. The second term, however, is the gradient of the log partition function ($\nabla_\theta \log Z(\theta)$). It acts as a counterweight, pulling up the energy of all possible points by taking an expectation over the model's current distribution.

As highlighted by Wood et al. and Swersky et al., evaluating this expectation requires generating samples from the model itself, typically via slow, unstable Markov Chain Monte Carlo (MCMC) methods. This computational bottleneck has motivated a rich ecosystem of alternative objectives designed to bypass or eliminate the partition function entirely.

Bypassing Z via Spatial Derivatives

If a constant is preventing you from optimizing an equation, the cleanest mathematical solution is to apply an operator that makes it vanish. In continuous spaces, we can eliminate $Z(\theta)$ by taking the derivative of the log-density with respect to the input data $x$ rather than the parameters $\theta$. This derivative is known as the score function:

$$\psi(x) = \nabla_x \log p(x; \theta) = \nabla_x \left( -E(x; \theta) - \log Z(\theta) \right) = -\nabla_x E(x; \theta)$$

Because $Z(\theta)$ does not depend on $x$, its derivative is zero. The partition function simply disappears.

Instead of maximizing the likelihood of the data, we can train the model to minimize the difference between its predicted score function and the true score function of the data distribution. This framework, known as Score Matching, allows us to learn the exact shape of the energy landscape without ever knowing its absolute normalization scale.

Swersky et al. demonstrated the foundational connections between score matching and the reconstruction objectives of autoencoders, showing that regularized autoencoders implicitly learn unnormalized energy densities. To scale this to complex, high-dimensional distributions, Meng et al. integrated autoregressive architectures with score matching, capturing intricate dependencies without normalization constraints.

Crucially, this mathematical detour does not sacrifice accuracy for speed. Pabbaraju et al. provided rigorous proofs demonstrating that for specific natural probability families, score matching is exponentially faster to compute than MLE while maintaining nearly identical sample efficiency.

Bypassing Z via Local Perturbations

While score matching elegantly solves the partition function problem for continuous data, it fails for discrete data (such as text or graphs) where the spatial gradient $\nabla_x$ is undefined. As noted by He et al., calculating the normalizing constant over discrete vocabularies remains a massive bottleneck.

To eliminate $Z(\theta)$ in discrete spaces, we can shift our perspective from global integration to local comparison. Instead of asking "what is the absolute probability of this data point?", we ask "is this real data point more probable than a slightly corrupted version of itself?".

Consider a data point $x$ and a perturbed neighbor $x'$. The ratio of their probabilities cancels out the partition function completely:

$$\frac{p(x; \theta)}{p(x'; \theta)} = \frac{e^{-E(x; \theta)} / Z(\theta)}{e^{-E(x'; \theta)} / Z(\theta)} = e^{E(x'; \theta) - E(x; \theta)}$$

By optimizing objectives that look at these localized energy differences, we can force the model to build a "valley" of low energy around the true data distribution while raising the energy of the surrounding perturbed space.

This insight underpins several modern training methodologies:

  • Contrastive Divergence: Rather than running MCMC chains to convergence to estimate the global expectation, we initialize short MCMC chains directly on the data points. Yu et al. advanced this via Pseudo-Spherical Contrastive Divergence, utilizing specialized scoring rules to stabilize training and eliminate finicky adversarial optimization loops.
  • Energy Discrepancy (ED): To avoid MCMC sampling entirely, Schröder et al. proposed comparing data points directly to explicitly perturbed versions of themselves. As detailed in Energy Discrepancies: A Score-Independent Loss for Energy-Based Models, this approach acts as a bridge between score matching and MLE, preventing the "nearsightedness" of purely local objectives and allowing the model to capture global structures like mixture weights accurately.

Sample-Free Evaluation and Diagnostics

The intractability of the partition function does not merely break MLE training; it also paralyzes model evaluation. Without $Z(\theta)$, we cannot compute the log-likelihood of a test set to determine if a model has converged or overfit.

Historically, researchers relied on approximations like Annealed Importance Sampling (AIS) to estimate $Z(\theta)$. However, as Burda demonstrated, AIS estimates are frequently over-optimistic, overestimating the true log-likelihood of a model.

To circumvent this, recent work adapts the same mathematical tricks used in training to create sample-free evaluation metrics. If a model has perfectly learned the data distribution, the Stein discrepancy between the model and the data should be zero.

Grathwohl et al. operationalized this by introducing the Learned Stein Discrepancy (LSD). By training a neural network "critic" to maximize a score-based boundary condition, LSD directly measures the fit of an unnormalized EBM without ever drawing samples from it. For formal statistical verification, Schrab et al. developed the KSD Aggregated Goodness-of-fit Test (KSDAGG), which aggregates multiple kernel-based Stein tests to provide a non-parametric, sample-free method for evaluating unnormalized models in high dimensions.

Key Foundational Work

Sparse Feature Learning for Deep Belief Networks (2007) — contributed 1 concept elements to this direction.
Modeling Neural Population Spiking Activity with Gibbs Distributions (2005) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_partition_function_intractability_intrac_e9d70953,
  title = {partition function intractability (intractable partition function)},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/partition-function-intractability-intractable-partition-function/rdr_e9d70953dfe94b5486ea7e950dd40759},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-23},
}

This exact version (version 1, frozen text):

@misc{lacuna_partition_function_intractability_intrac_e9d70953_v1,
  title = {partition function intractability (intractable partition function)},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/partition-function-intractability-intractable-partition-function/rdr_e9d70953dfe94b5486ea7e950dd40759/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-23},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake