Sorbonne's Enformer Beats Diffusion Models at 82% Less Training Time
A new Transformer forecasting framework injects noise into inputs and trains on an energy score loss to produce calibrated probabilistic multivariate predictions without parametric assumptions.
ProTakeaways
- Enformer and GEnformer combine Transformers with engression for probabilistic multivariate and spatiotemporal forecasting.
- Inputs are duplicated M times and perturbed with Gaussian or Uniform noise, then trained with an energy score loss.
- Wins CRPS-sum on 4 of 6 temporal benchmarks and 4 of 5 epidemic datasets against TimeGrad, TACTiS, and diffusion baselines.
- Training is 36.9% faster than Transformer-MAF and 82.1% faster than TimeGrad on the Traffic dataset.
- Probabilistic capability adds only a constant-factor asymptotic overhead over a deterministic Transformer.
- Open-source code and package at github.com/yuvrajiro/genformer.
Probabilistic forecasting has a persistent awkwardness. Transformers are great at capturing long-range dependencies across many correlated series, but the moment you ask them for a proper predictive distribution instead of a point estimate, you end up bolting on Gaussian likelihoods, quantile heads, normalizing flows, or heavy diffusion machinery. A team from Sorbonne University Abu Dhabi and IIT Guwahati has proposed a cleaner route in a new paper, introducing Enformer and its spatiotemporal cousin GEnformer, which turn a vanilla Transformer into a generative forecaster by doing something surprisingly simple: adding noise to the inputs and swapping the loss function.
The parametric likelihood trap
The work integrates engression, a stochastic learning paradigm for modeling conditional distributions, with the expressive sequence modeling capabilities of Transformers, injecting stochastic noise into the model representation and optimizing an energy-based scoring objective to directly learn the conditional predictive distribution without imposing parametric assumptions. That last part is the key. Most existing probabilistic forecasters commit to a shape ahead of time, whether that is a Gaussian output head like DeepAR, a quantile objective like Temporal Fusion Transformer, or a fixed copula structure. When the true joint distribution across hundreds of correlated series is messy, that commitment costs you calibration.
Diffusion-based approaches such as TimeGrad avoid the parametric assumption but pay for it in compute. On the Traffic dataset, TimeGrad requires about 30 seconds per training epoch versus 5.38 seconds for Enformer, which the authors report as an 82.1% reduction in training time. The gap grows even wider at inference.
Engression, in plain terms
Enformer builds on engression, a technique introduced by Shen and Meinshausen for learning full conditional distributions rather than conditional means. The idea is to model Y as f(X, epsilon), where epsilon is a random noise vector from a fixed distribution and f is a neural network trained using the energy score, a strictly proper scoring rule. The neural network never outputs distribution parameters. Instead, you sample noise, push it through the network, and treat the resulting outputs as samples from the predictive distribution.
The energy score loss has two competing pieces that together shape a sharp but well-spread distribution:
- A term that pulls each generated sample toward the ground truth in Euclidean distance, keeping the distribution centered.
- A pairwise term that pushes generated samples apart from each other, preventing the model from collapsing into a deterministic point forecaster.
How the forward pass actually works
The architecture is a fairly standard encoder-decoder Transformer with one twist. For each mini-batch of historical windows, the input is replicated M times along the batch dimension, then independent noise is added to every copy before the linear projection. A single forward pass then produces M distinct forecast trajectories that collectively approximate the predictive distribution.
The noise is sampled from either a Gaussian or Uniform distribution, with the choice being data dependent and empirically determined through validation. The pseudocode reduces to something along these lines:
X = concat([Y_history, covariates], dim=-1) # (B, p, D + D_cov)
X = repeat_interleave(X, M, dim=0) # (M*B, p, D + D_cov)
eps = sample_noise(shape=X.shape, sigma=sigma) # Gaussian or Uniform
H = transformer_encoder(X + eps)
Y_pred = transformer_decoder(H) # (M*B, q, D)
loss = energy_score(Y_pred.view(M, B, q, D), Y_true)
Because the M replicas are batched together, the multi-head attention still scales linearly in M. The only quadratic-in-M cost lives in the pairwise term of the energy score, which operates on the small output tensor rather than on attention maps. The authors show that the probabilistic upgrade costs only a constant-factor asymptotic overhead compared to a deterministic Transformer of identical shape.
Spatiotemporal extension via graph convolution
GEnformer adds a graph convolutional front end for problems where the series correspond to physical locations. A static adjacency matrix is built from Haversine distances using a thresholded Gaussian kernel, then a GCN produces spatially aware embeddings that are handed off to the Enformer core. This is the module used for epidemic forecasting, where transmission dynamics link neighbouring regions.
Results across six temporal and five epidemic datasets
The evaluation covers Solar, Electricity, Traffic, KDD-cup, Taxi, and Wikipedia for multivariate temporal forecasting, plus tuberculosis in Japan, influenza-like illness in the USA, COVID-19 in Belgium, dengue in Colombia, and chickenpox in Hungary for spatiotemporal work. Performance is measured with CRPS-sum (a strictly proper scoring rule for probabilistic forecasts, lower is better).
On the temporal benchmarks, Enformer posts the best CRPS-sum on Solar (0.2421), Electricity (0.0216), KDD-cup (0.2468), and Taxi (0.1190), beating diffusion-based TimeGrad, Transformer-MAF, TACTiS, and the newer NsDiff and HDT baselines. It loses to TimeGrad on Traffic and to it on Wikipedia by narrow margins. For spatiotemporal epidemic forecasting, GEnformer wins on four of five datasets, including a large margin on tuberculosis (5.26 vs 6.58 for the next best) and ILI (75.25 vs 102.91 for NHiTS).
The Probability Integral Transform Q-Q plots show near-diagonal alignment for Electricity, KDD-cup, Taxi, and Wikipedia, meaning the predicted quantiles match empirical frequencies closely. Solar and Traffic show minor deviations, so calibration is not uniform across domains.
What the sensitivity analysis reveals
The training ensemble size M turns out to matter more than expected. Prior engression-style work typically fixes M at 2, but the authors treat it as a tunable hyperparameter and find that:
- Training time scales linearly with M, as the complexity analysis predicts.
- CRPS-sum is highly non-linear in M, usually reaching its minimum somewhere between M=2 and M=5.
- Pushing M to 7 or 8 does not consistently help and often hurts, so blindly cranking up the ensemble wastes compute.
When to use it, and what to watch for
Enformer is a good fit when you need coherent multivariate trajectories with uncertainty, such as electricity load across hundreds of clients, traffic occupancy across a sensor network, or joint epidemic case counts across regions. Its lightweight nature makes it particularly appealing when diffusion-based alternatives are too slow for the deployment budget.
The limitations are worth naming. The calibration wobbles on Solar and Traffic suggest post-hoc recalibration may still be needed for some domains. The energy score's pairwise term is O(M squared) in the output size, so extremely long horizons combined with large M could shift the compute bottleneck. And because the noise is injected pre-projection, the effective noise geometry depends on the learned input projection, which can make the sigma hyperparameter finicky to tune.
Code and package
The implementation ships as an open-source repo at github.com/yuvrajiro/genformer, with a pip-installable Python package and documentation on Read the Docs. Hyperparameter search uses Optuna, and training runs were done on a single NVIDIA Tesla P100 with 16GB of memory, so reproduction does not require a large cluster.