Genformer

Deep generative Transformers for probabilistic time series and spatiotemporal forecasting - uncertainty-aware, robust, and lightweight.

PyPI Python License
See it in action GitHub

Genformer combines the attention mechanism of Transformers with the engression paradigm of distributional regression. Rather than point forecasts or restrictive parametric likelihoods, it injects stochastic noise into the inputs and optimises a strictly proper Energy Score, learning the full conditional predictive distribution and producing diverse, realistic trajectories.

The package ships two models: Enformer for temporal data and GEnformer for spatiotemporal data on a graph.

Installation#

Genformer requires Python 3.10+ and PyTorch 2.0+.

pip install genformer
git clone https://github.com/yuvrajiro/Genformer.git
cd Enformer
pip install -e .
pip install -e ".[docs]"

Tip

For GPU training, install the CUDA build of PyTorch that matches your driver before installing Genformer - see the PyTorch install matrix.

Verify it works:

from genformer import Enformer, GEnformer
print("Genformer is ready")

Explore#

Quickstart

The shortest path from a TimeSeries to a probabilistic forecast, for both models.

Quickstart
Enformer

The temporal model. Pre-additive noise on batch-expanded inputs, trained with the Energy Score for probabilistic multivariate forecasting.

Enformer
GEnformer

The spatiotemporal model. A graph convolution encodes spatial structure before the Transformer, with an optional calibration objective.

GEnformer
Usage

End-to-end, runnable notebooks for both models - from raw TimeSeries to a plotted probabilistic forecast.

Usage
Noise Modules

The pre-additive stochastic noise layers shared by both Enformer and GEnformer.

Noise Modules
Contributors

Meet the contributors and cite Genformer in your research.

Contributors