stNCE

NeurIPS 2026

Learning Energy-Based Models from Stochastic Interpolants using Spatiotemporal Differences

Hanlin Yu1, RuiKang OuYang2, Partha Kaushik3, Arto Klami1, Michael U. Gutmann4, Omar Chehab3

1 University of Helsinki · 2 University of Cambridge · 3 Carnegie Mellon University · 4 University of Edinburgh

Successive density curves show one noise peak gradually splitting into two data peaks.
A stochastic interpolant from Gaussian noise to a two-mode data distribution.

Method

Learning across space and time

A stochastic interpolant connects noise to data. At each time t, it defines a density over locations x. How should we train Energy-based Models by constructing contrastive comparisons between two points?

Spatial comparisons hold the noise level fixed. When modes are far apart, local comparisons struggle to recover the global mode weights, leading to pathologies under multimodality. Temporal comparisons hold the location fixed and vary the time, and suffer when the data has high density in low density region of the noise, i.e. support mismatch. Spatiotemporal comparisons vary both location and noise level in the same comparison and avoid both pathologies.

Density diagram and three heatmaps. Temporal error grows with support mismatch, spatial error grows with mode separation, and spatiotemporal error stays near zero in this experiment.
In a one-dimensional Gaussian mixture, the two axes independently vary multimodality and support mismatch. Darker red indicates higher estimation error.

A shared logistic loss

A clean sample x1∼p1x_1\sim p_1 and a noise sample x0∼p0x_0\sim p_0 give the stochastic interpolant xt=(1−t)x0+tx1x_t=(1-t)x_0+t x_1. Drawing tt from the chosen time density p(t)p(t) between 0 and 1 gives the joint density pd(x,t)=p(t)pd(x∣t)p_d(x,t)=p(t)p_d(x\mid t). The Energy-based Model (EBM) represents the conditional density as

pθ(x∣t)=exp⁡(−Eθ(x,t)−logZt).p_\theta(x\mid t)=\exp\!\left(-E_\theta(x,t)-\log Z_t\right).

Class AA and class BB present a pair in reversed order against each other. With equally likely classes, sigmoid(F(x))\mathrm{sigmoid}(F(x)) estimates the probability that the observation belongs to class AA. The population-optimal logit is F*(u)=log⁡pA(u)−log⁡pB(u)F^*(u)=\log p_A(u)-\log p_B(u).

ℒlogistic(F)=−𝔼u∼pA[logsigmoid(F(u))]−𝔼u∼pB[log(1−sigmoid(F(u)))].\begin{aligned} \mathcal{L}_{\mathrm{logistic}}(F) &=-\mathbb{E}_{u\sim p_A}\left[\log\mathrm{sigmoid}(F(u))\right]\\ &\quad-\mathbb{E}_{u\sim p_B}\left[\log\left(1-\mathrm{sigmoid}(F(u))\right)\right]. \end{aligned}

For each method below, substitute its model logit FθF_\theta for FF and minimize ℒlogistic(Fθ)\mathcal{L}_{\mathrm{logistic}}(F_\theta) over θ\theta.

Temporal, spatial, and joint comparisons

tNCE changes time at a fixed location

For tNCE, u=(x,t,t′)u=(x,t,t'). Draw (x,t)(x,t) from the interpolant and propose t′t' given tt. Swapping the times keeps the position xx fixed.

pA(x,t,t′)=pd(x,t)pn(t′∣t),pB(x,t,t′)=pd(x,t′)pn(t∣t′).\begin{aligned} p_A(x,t,t') &= p_d(x,t)\,p_n(t'\mid t),\\ p_B(x,t,t') &= p_d(x,t')\,p_n(t\mid t'). \end{aligned}

Fθ(x,t,t′)=log⁡pθ(x∣t)−log⁡pθ(x∣t′)+c(t,t′),c(t,t′)=log⁡p(t)+log⁡pn(t′∣t)−log⁡p(t′)−log⁡pn(t∣t′).\begin{aligned} F_\theta(x,t,t') &= \log p_\theta(x\mid t)-\log p_\theta(x\mid t')+c(t,t'),\\ c(t,t') &= \log p(t)+\log p_n(t'\mid t)-\log p(t')-\log p_n(t\mid t'). \end{aligned}

Both normalizers enter the comparison through −log⁡Z(t)+log⁡Z(t′)-\log Z(t)+\log Z(t'). If xx is common at one time and rare at the other, few samples inform the density ratio there.

tCNCE changes location at a fixed time

For tCNCE, u=(x,x′,t)u=(x,x',t). Draw (x,t)(x,t) from the interpolant and propose x′x' given xx. Swapping the locations and keeping the sampled time fixed:

pA(x,x′,t)=pd(x,t)pn(x′∣x),pB(x,x′,t)=pd(x′,t)pn(x∣x′).\begin{aligned} p_A(x,x',t) &= p_d(x,t)\,p_n(x'\mid x),\\ p_B(x,x',t) &= p_d(x',t)\,p_n(x\mid x'). \end{aligned}

The shared normalizer Z(t)Z(t) cancels from the logit.

Fθ(x,x′,t)=log⁡pθ(x∣t)−log⁡pθ(x′∣t)+c(x,x′),c(x,x′)=log⁡pn(x′∣x)−log⁡pn(x∣x′).\begin{aligned} F_\theta(x,x',t) &= \log p_\theta(x\mid t)-\log p_\theta(x'\mid t)+c(x,x'),\\ c(x,x') &= \log p_n(x'\mid x)-\log p_n(x\mid x'). \end{aligned}

At a given time, local comparisons within well-separated modes can reveal each mode’s shape while providing little information about their relative masses.

stNCE compares both endpoints

stNCE asks which endpoint came from the interpolant. Draw (x,t)(x,t) from pd(x,t)p_d(x,t), then perturb it to (x′,t′)(x',t') using pn(x′,t′∣x,t)p_n(x',t'\mid x,t).

pA(x,t,x′,t′)=pd(x,t)pn(x′,t′∣x,t),pB(x,t,x′,t′)=pd(x′,t′)pn(x,t∣x′,t′).\begin{aligned} p_A(x,t,x',t') &= p_d(x,t)\,p_n(x',t'\mid x,t),\\ p_B(x,t,x',t') &= p_d(x',t')\,p_n(x,t\mid x',t'). \end{aligned}

For a fixed kernel, cc collects the known time prior and perturbation terms:

Fθ(x,t,x′,t′)=log⁡pθ(x∣t)−log⁡pθ(x′∣t′)+c(x,t,x′,t′),c(x,t,x′,t′)=log⁡pn(x′,t′∣x,t)−log⁡pn(x,t∣x′,t′)+log⁡p(t)−log⁡p(t′).\begin{aligned} F_\theta(x,t,x',t') &= \log p_\theta(x\mid t)-\log p_\theta(x'\mid t')+c(x,t,x',t'),\\ c(x,t,x',t') &= \log p_n(x',t'\mid x,t)-\log p_n(x,t\mid x',t')\\ &\quad +\log p(t)-\log p(t'). \end{aligned}

The log-density ratio contains both Eθ(x′,t′)−Eθ(x,t)E_\theta(x',t')-E_\theta(x,t) and log⁡Z(t′)−log⁡Z(t)\log Z(t')-\log Z(t).

Temporal and spatial comparisons necessarily traverse low density region under certain scenarios. Spatiotemporal comparisons could instead remain within high density region.
Temporal and spatial comparisons necessarily traverse low density region under certain scenarios. Spatiotemporal comparisons could instead remain within high density region.

Choosing a perturbation kernel

The kernel determines which energy differences the classifier sees. A meaningful proposal places the second endpoint in a region with high density at the proposed time.

Mixture (stNCE-m)

Change time as in tNCE or change location as in tCNCE with equal probabilities. δx(x′)\delta_x(x') keeps the location fixed and δt(t′)\delta_t(t') keeps time fixed.

pn(x′,t′∣x,t)=12pn(t′∣t)δx(x′)+12pn(x′∣x)δt(t′)p_n(x',t'\mid x,t) = \tfrac{1}{2}\, p_n(t'\mid t)\,\delta_{x}(x') + \tfrac{1}{2}\, p_n(x'\mid x)\,\delta_{t}(t')

White noise (stNCE-w)

Perturb the location with isotropic Gaussian noise of standard deviation σ\sigma and draw a new time based on Gaussian perturbation.

pn(x′,t′∣x,t)=𝒩(x′∣x,σ2I)p(t′|t)p_n(x',t'\mid x,t) = \mathcal{N}(x'\mid x,\sigma^2 I)\,p(t'|t)

Forward–reverse (stNCE-o and stNCE-s)

First propose t′t', then choose the spatial transition according to the direction of the time step:

pn(x′,t′∣x,t)=pn(x′∣x,t,t′)pn(t′|t)p_n(x',t'\mid x,t) = p_n(x'\mid x,t,t')\,p_{n}(t'|t)

A Gaussian perturbation leaves the blue high-density band. A forward–reverse step follows the band to the proposed time.
The blue band marks high density in space and time. The forward–reverse kernel uses the interpolant dynamics to guide the proposal along it.

Noising, t′<tt'<t. For the linear interpolant with standard Gaussian reference noise, moving toward t=0t=0 scales the current sample and adds Gaussian noise. For t>0t>0 the exact transition is

pn(x′∣x,t,t′)=𝒩(x′|(t′/t)x,((1−t′)2−t′2(1−t)2/t2)I)p_n(x'\mid x,t,t') = \mathcal{N}\!\left(x'\middle| (t'/t)x,\; \left((1-t')^2 - t'^2(1-t)^2/t^2\right) I \right)

Denoising, t′>tt'>t. Moving toward the clean-data endpoint requires the reverse transition. Its ideal form is the Bayes inverse of noising. For t>0t>0, we use the following Gaussian approximation for the reverse SDE, whose mean depends on the space score ∇xlog⁡pt(x)\nabla_x\log p_t(x):

pn(x′∣x,t,t′)=𝒩(x′|(t′/t)x+2(1−t)(t′−t)tsg(∇xlogpt(x)),(t′−t)(t+t′−2tt′)t2I)p_n(x'\mid x,t,t') = \mathcal{N}\!\left( x'\middle| (t'/t)x + \tfrac{2(1-t)(t'-t)}{t}\,\text{sg}\left(\nabla_x \log p_t(x)\right),\; \tfrac{(t'-t)(t+t'-2tt')}{t^2} I \right)

Oracle and self scores. stNCE-o uses the true space score when available. stNCE-s uses the current model’s score ∇xlog⁡pθ(x∣t)=−∇xEθ(x,t)\nabla_x\log p_\theta(x\mid t)=-\nabla_x E_\theta(x,t). The stop-gradient operator sg\mathrm{sg} holds the score in the kernel fixed during each gradient update. The next step uses the refreshed score.

Experiments

Image likelihoods and molecular energies

MNIST Gaussian mixture

How accurately can a model learn the density of well-separated digits? Each of 100 MNIST images, ten per digit class, is the center of a Gaussian in 784 dimensions. The mixture’s exact density is known, so we can measure the error in the model’s log density directly.

Switching from white noise to the forward–reverse kernel reduces mean LogMSE from 9.96 to 4.80. Dual score matching achieves the lowest error among the methods shown, while stNCE-s takes about half as long per training step.

LogMSE is the log of the mean squared error between model and true log densities, reported as mean ± standard deviation. Time is the average time per training step. Lower is better for both. Full results in the paper.
Method LogMSE Seconds/step
tNCE (temporal) 12.37 ± 0.02 0.39
CTSM (temporal) 12.44 ± 0.45 0.68
tCNCE (spatial) 12.28 ± 0.26 0.40
DSM (spatial) 16.39 ± 0.07 0.70
stNCE-w (white noise) 9.96 ± 0.05 0.40
stNCE-s (forward–reverse) 4.80 ± 0.10 0.36
Dual score matching 3.73 ± 0.18 0.70

ImageNet64

Combining stNCE-s with denoising score matching (DSM) gives an estimated test negative log likelihood of 2.94 bits per dimension in a single network evaluation. Dual score matching gives 3.36.

Two grids of ImageNet64 test images ranked by model density.
Test images assigned the highest densities (left) and lowest densities (right).

Molecular configurations

We compare samples from learned energy models with equilibrium configurations of Alanine Dipeptide (ALDP) and Chignolin. On Chignolin, stNCE-s with DSM achieves comparable Potential-of-Mean-Force (PMF) accuracy to FPE at roughly half the training cost.

Plots of potential-of-mean-force error versus training time for diffusion and Langevin sampling on two molecular datasets.
Potential-of-Mean-Force (PMF) error versus training time. Lower values on both axes are preferable.

Citation

Download BibTeX
@inproceedings{yu2026learning,
  title = {Learning {Energy}-{Based} {Models} from {Stochastic} {Interpolants} using {Spatiotemporal} {Differences}},
  url = {https://openreview.net/forum?id=QnHvCvmOn6},
  booktitle = {The {Fortieth} {Annual} {Conference} on {Neural} {Information} {Processing} {Systems}},
  author = {Yu, Hanlin and OuYang, RuiKang and Kaushik, Partha and Klami, Arto and Gutmann, Michael U. and Chehab, Omar},
  year = {2026},
}