EBMs and Diffusion: The tradeoff between scale and structure
The common origins
You have a big dataset of real images and want to train a network that would output real-looking images. In the high-dimensional space of pixels, only an extremely small percentage makes up the space of real images. Pixel space is extremely sparse, where the same image with different lighting could live very far apart from the original. Encoding the distribution of real images in lower dimensions and training the network to map them directly to their actual points in pixel space is a possible technique.1 But this comes with the constraints of assuming a prior distribution like the Gaussian over the encodings of the real images, which may not be how they are actually distributed.2 How can we make the network learn the actual distribution of real images?
One can train a network to look at any image and output a “realness score”, but raw network outputs cannot allocate a fixed budget of scores across training. For the network to have normalised probabilities, we have to divide across the entire pixel space by a normalisation constant.
Calculating implies that we sum the network assigned values across the entire pixel space. This is completely intractable. Instead, we reframe the above expression to get a tractable form. Outlier3 provides a brilliant breakdown of this proof and its motivations for Diffusion.
Taking the logarithm of the probability density:
Taking the gradient with respect to the input :
Since depends on the parameters but not on the input :
Hence, the score is:
This reframed expression doesn’t require us to compute at all. So, instead of directly approximating , we train the network to optimise for the score—. This reframed loss objective is known as Fisher Divergence4,5 or popularly known as score matching, where the network learns the score—the direction in data space where the probability of finding real data is high. But we still don’t have the true target score for the network to learn. Modern generative methods bypass this target via derivatives (EBMs) or via noise (diffusion and flow matching models).
- Formulating the score via derivatives: Using integration by parts, Hyvärinen reformulates the target such that the unknown true score drops out of the loss equation.5 The reframed target requires us to compute first and second derivatives of the network’s own outputs (energies). So, the score here is the derivative of the scalar output of the network with respect to the input, i.e., the data.
(Here, the first term is just the second derivative of the energy with respect to the input, i.e., the curvature of the energy landscape. The second term is the first derivative, i.e., the slope of the energy landscape.)
- Formulating the score via noise: We corrupt the original image by adding noise to it, and since we know the noise we added, the opposite direction of that noise can become our score.6 We train the network to learn this denoising direction. This denoising process can be approached by either learning the randomly added scaled noise at each step (Diffusion7,8) or learning the velocity field, where the target is a straight line between the pure noise and the real image (Flow Matching9).
Hence, diffusion and EBMs are different forms of the same underlying concept, which is minimising scores to model the true distribution. Their varied forms bring in fundamentally different training and sampling methods, which have their own respective tradeoffs.
Diffusion is simply better for training
As you may have noticed already, the EBM training objective formulation involves the use of second derivatives of the network with respect to the input. This involves computing traces of Hessians, which explodes as we scale the input dimensions. Computing an exact trace of a Hessian matrix requires D separate backward passes, so for a image (), we would be doing nearly 200,000 backward passes for a single training step, which is not computationally feasible by a long shot. Hence, the implicit score matching objective by Hyvärinen is not approachable at all.5
Deep Langevin MCMC10 is the training method that is commonly used alongside EBMs. Inspired by Contrastive Divergence,11 the real images in the data space are given low energies, while the low energies occupied by random parts without real images are lifted up. These fake low-energy crevices are discovered using gradient descent. Generating each sample involves roughly 60-100 gradient steps, and each training step requires a batch of N fake samples. The process of gradient sampling is strictly sequential and an unparallelisable bottleneck in training. Moreover, when generating fake samples in higher data dimensions, the gradient steps get trapped in low-energy regions they were initialised closest to, which leaves other spurious low-energy sinkholes undiscovered. The instability and sheer amount of computation involved in training make training EBMs at scale a nightmare.12
Denoising score matching cleverly assumes scores to be the opposite direction of the noise added to the data. Diffusion models completely abandon the idea of assigning energies to real data and try to predict the noise from the noisy data. Vincent (2011) showed that the noise prediction objective implicitly models the scores of the smoothed data distribution.6 With the objective just being able to predict targeted scores/predict noise, the massive overhead of computing first- or second-order derivatives of EBMs does not occur in diffusion.8

Diffusion carries out the denoising objective at various noise scales. Each target step is a varying ratio between the image signal and the noise scale. The regression objective of predicting noise at varied noise scales gives very smooth estimates of scores across the data manifold. Spurious sinkholes around the off-manifold regions (far away from real data modes) are reached by high noise scales. If the real data modes are extremely small islands spread across the globe, the tides towards the islands occur not just around the shallow ocean coasts but also the deep ocean territories. This completely removes the overhead of sinkhole discovery via sampling, as the coverage across the manifold naturally occurs with the denoising objective.14,8
Why do we care about EBMs then?
Natural images follow a power law in their frequency spectrum.15 One can break down an image into its power-versus-frequency graph. Low-frequency components, which are broad gradients of colours across the image, dominate the power density across the image, while high-frequency components, which are textures and finer details, make up a very small part of the total power density. Gaussian noise contains all frequencies in equal measure, and increasing the intensity of Gaussian noise increases its power. Corruption of the image signal with Gaussian noise at early scales destroys high-frequency components. As the scale of the corruption increases, the Gaussian noise destroys lower frequencies until, finally, only pure Gaussian noise remains.16,17
During the reverse process, at higher noise levels, the network learns to resolve the global uncertainties about the data distribution, like the general scene, and as the noise level decreases, the network uses this general scene that is already set and adds finer details to it. Prediction at different hierarchies of image details is what Dieleman calls spectral autoregression.16 This enables direct comparison to the process of autoregression, but with softer implications between the consequent predictions. Hence, the diffusion process serves as a very strong prior for image generation and provides a strong structure for the networks to learn heirarchical scene generation of high-quality images.
Spatial frequencies describe how rapidly pixels change across an image. The hierarchies in the frequencies of an image do not necessarily encode particular objects or their relationships. Consider generating a chessboard with a valid game state. Diffusion can do an excellent job of reconstructing the board’s appearance and the textures of the individual pieces but will do a poor job of satisfying a valid configuration. The mechanism puts more pressure on the earlier selection of data modes (of low frequencies) to discover valid compositions, and the rest of the generation uses the earlier selections as a soft dependency, which may compound errors. Diffusion can compositionally generalise, but it is very dependent on the data it is trained on. Valid combinations are learnt if they show up in statistically similar contexts. The mechanism does not pressure the networks to learn them as global rules if they show up in varied local contexts across the dataset and requires substantially more data to learn them.18 The same inductive prior that helps with learning structural scene generation semantics in images does not favour the learning of valid composition of objects.
Contrastive EBM training introduces a discriminative learning pressure—the network must learn to distinguish real configurations from the ones it incorrectly considers plausible.10,12 As the model learns the generative semantics, i.e., learns how to generate real-looking objects, there might exist possible energy sinkholes that might follow the correct semantics for generation but will not follow a valid configuration of those objects. The sampler can discover these invalid configurations. This puts pressure on the network to learn relationships between objects rather than just focus on their appearance. But this network pressure depends a lot on the negative samples it encounters and does not provide a direct implicit pressure for such discovery. EBMs also possess an out-of-the-box ability to compare energies between out-of-distribution configurations. This easily translates to being able to perform downstream ranking/anomaly tasks without any extra training.19
The product of probabilities in EBMs is just equivalent to the sum of their energies.11,20 To represent a scene with multiple features, one can train multiple energy functions associated with objects, attributes or relationships. These functions can be directly combined without any special training to form a global energy landscape.20,21 Think about learning the colour, shape and position of a cube. A network can independently learn the different energies corresponding to these attributes. This makes the network capable of generating a combination of these attributes (a red cube at the top left) it has never seen before.20 Since the composition itself is an energy function, for a combination with a harder constraint, the network can allocate more compute to find a valid configuration satisfying individual conditions.22 EBMs don’t necessarily have an implicit incentive to discover compositional rules, but factorised EBMs can learn rules (even in an unsupervised manner) that can independently be reused to generate unseen data.23
The Resolution
The computational benefits of diffusion come from its construction of artificial targets with Gaussian noise. The structural benefits of EBMs come from their representation of data as energies. They are two different modelling decisions that are not mutually exclusive. There is no reason why an energy landscape cannot be learnt from a denoising objective. In fact, a denoising objective helps EBMs form a much smoother, more regular energy landscape. Methods like Diffusion Recovery Likelihood learn sequences of noise-conditioned energy landscapes.24 Du et al. (2023) take the opposite approach, where the score network of a diffusion model is a scalar energy function whose gradient provides the score.25 This makes the difference of energies between data points directly accessible during inference. Energy Matching teaches the energy network how to move towards the real data manifold (via flow matching), while contrastive supervision helps structure the valid configurations.26
Reasoning-based tasks seem to be a more natural fit for EBMs, as the sampling involves finding a configuration that satisfies a particular set of constraints. They can represent the compatibility between a problem and a solution. Using this representation, they can traverse the energy landscape to find better solutions. There are demonstrations of energy models generalising to harder Sudoku puzzles,22 crosswords and SAT problems.27 Molecular generation is another task EBMs fit naturally into. The likelihood of a stable molecular configuration is directly related to low physical energies. EBMol learns an atom-additive scalar energy function to find stable configs.28
Diffusion and flow matching models still remain the status quo of image modelling and various other modalities. While the scalability of energy models still remains a big question, certain of their modelling properties give us enough motivation to consider them. Furthermore, with initiatives like EBTs,29 surrounding architectures are developed to better suit the modelling objectives of energy functions.
References
- Hinton, G. E. & Salakhutdinov, R. R. (2006). Reducing the Dimensionality of Data with Neural Networks. Science, 313(5786), 504–507.
- Kingma, D. P. & Welling, M. (2014). Auto-Encoding Variational Bayes. ICLR.
- Outlier. Video explainer on score-based modelling (supplementary resource).
- Lyu, S. (2009). Interpretation and Generalization of Score Matching. UAI.
- Hyvärinen, A. (2005). Estimation of Non-Normalized Statistical Models by Score Matching. JMLR.
- Vincent, P. (2011). A Connection Between Score Matching and Denoising Autoencoders. Neural Computation.
- Sohl-Dickstein, J. et al. (2015). Deep Unsupervised Learning using Nonequilibrium Thermodynamics. ICML.
- Ho, J., Jain, A. & Abbeel, P. (2020). Denoising Diffusion Probabilistic Models. NeurIPS.
- Lipman, Y. et al. (2023). Flow Matching for Generative Modeling. ICLR.
- Du, Y. & Mordatch, I. (2019). Implicit Generation and Generalization in Energy-Based Models. NeurIPS.
- Hinton, G. E. (2002). Training Products of Experts by Minimizing Contrastive Divergence. Neural Computation.
- Du, Y. et al. (2021). Improved Contrastive Divergence Training of Energy-Based Models. ICML.
- Gladstone, A. GIF reference (supplementary visual resource).
- Song, Y. & Ermon, S. (2019). Generative Modeling by Estimating Gradients of the Data Distribution. NeurIPS.
- Field, D. J. (1987). Relations Between the Statistics of Natural Images and the Response Properties of Cortical Cells. JOSA A.
- Dieleman, S. (2024). Diffusion is Spectral Autoregression. Technical blog.
- Falck, F. et al. (2025). A Fourier Space Perspective on Diffusion Models.
- Favero, A. et al. (2025). How Compositional Generalization and Creativity Improve as Diffusion Models are Trained. ICML.
- Grathwohl, W. et al. (2020). Your Classifier is Secretly an Energy Based Model and You Should Treat it Like One. ICLR.
- Du, Y., Li, S. & Mordatch, I. (2020). Compositional Visual Generation with Energy Based Models. NeurIPS.
- Liu, N. et al. (2021). Learning to Compose Visual Relations. NeurIPS.
- Du, Y., Mao, J. & Tenenbaum, J. B. (2024). Learning Iterative Reasoning through Energy Diffusion. ICML.
- Du, Y. et al. (2021). Unsupervised Learning of Compositional Energy Concepts. NeurIPS.
- Gao, R. et al. (2021). Learning Energy-Based Models by Diffusion Recovery Likelihood. ICLR.
- Du, Y. et al. (2023). Reduce, Reuse, Recycle: Compositional Generation with Energy-Based Diffusion Models and MCMC. ICML.
- Balcerak, M. et al. (2025). Energy Matching: Unifying Flow Matching and Energy-Based Models for Generative Modeling. NeurIPS.
- Oarga, A. & Du, Y. (2025). Generalizable Reasoning through Compositional Energy Minimization. NeurIPS.
- Griesbacher, C. et al. (2026). Generating Physically Consistent Molecules with Energy-Based Models.
- Gladstone, A. et al. (2026). Energy-Based Transformers are Scalable Learners and Thinkers. ICLR.
Photographs from the scikit-image sample collection. Chelsea by Stéfan van der Walt and Eileen Collins by NASA.