All-in-one simulation-based inference

Manuel Gloeckler, Michael Deistler, Christian Dietrich Weilbach, Frank Wood, Jakob H. Macke

Introduction

In scientific disciplines ranging from neuroscience to epidemiology, researchers rely on complex numerical simulators to model real-world phenomena. A fundamental challenge in these fields is Simulation-Based Inference (SBI): the process of identifying the input parameters ($\theta$) that likely produced a specific set of observed data ($x$). Because these simulators are often "black boxes" with intractable likelihood functions, traditional statistical methods frequently fail.

Current "amortized" methods—which train neural networks to perform inference instantly—suffer from three primary limitations: they are often inflexible (locked into predicting either the posterior or the likelihood), simulation-hungry (requiring massive datasets), and rigid (struggling with missing values or irregularly sampled data). To address these challenges, we introduce the Simformer, an "all-in-one" tool that combines transformer architectures with probabilistic diffusion models to provide a flexible, efficient, and robust solution for SBI.

The Simformer Architecture

The Simformer redefines SBI as a generative modeling problem over the joint distribution of parameters and data, $p(\theta, x)$. By learning the joint distribution, the model becomes a universal inference engine capable of querying any conditional distribution—whether it be the posterior $p(\theta|x)$, the likelihood $p(x|\theta)$, or predictive distributions for missing data.

Key Technical Components

  • Diffusion Models: Rather than directly regressing a distribution, the Simformer utilizes a diffusion process to learn how to "denoise" samples. This approach allows the model to capture complex, multi-modal distributions that standard normalizing flows often struggle to represent.
  • Transformer Backbone: The use of a transformer architecture enables the model to process sequences of arbitrary length. This is particularly advantageous for handling varying numbers of observations or irregularly sampled time series.
  • Specialized Tokenization: Every variable—whether a parameter or a data point—is converted into a "token." Each token encodes the variable's identity, its numerical value, and a "condition state" that indicates whether the variable is observed or latent.
  • Attention Masking: This represents the "secret sauce" of the Simformer. By applying specific masks to the transformer's attention mechanism, researchers can embed domain knowledge (such as the structure of a graphical model) directly into the network. This forces the model to respect known dependencies, significantly reducing the search space and the amount of data required for training.

Flexibility and Guided Diffusion

Because the Simformer learns the joint distribution, it can be adapted to various tasks post-training without the need for retraining. For instance, in scenarios involving "interval" constraints—such as finding parameters where energy consumption remains below a certain threshold—the model employs guided diffusion. This technique steers the sampling process to satisfy specific constraints, providing a level of control that traditional SBI methods lack.

Experimental Evaluation

The Simformer was evaluated across a diverse suite of benchmarks, including standard SBI tasks (Linear Gaussian, Two Moons, SLCP) and complex scientific simulators:

  1. Lotka-Volterra: A classic predator-prey ecology model used to test the model's ability to handle unstructured observations where the timing and number of data points vary.
  2. SIRD Model: An epidemiological model (Susceptible-Infected-Recovered-Deceased) used to demonstrate inference on "infinite-dimensional" parameters (functions of time).
  3. Hodgkin-Huxley: A biophysical neuron model used to test inference under specific observation and energy-efficiency constraints.

Key Results

  • Simulation Efficiency: The Simformer demonstrated remarkable efficiency, reaching the same accuracy as state-of-the-art methods (such as Neural Posterior Estimation) using 10x fewer simulations on average.
  • Structural Advantage: Incorporating dependency structures via attention masking proved to be a massive performance booster, allowing the model to ignore irrelevant correlations and focus on causal pathways.
  • Robustness to "Messy" Data: The transformer backbone naturally handled irregularly sampled data and missing values, outperforming methods that require fixed-size vector inputs.

Discussion and Limitations

While the Simformer represents a significant leap forward in SBI, it is not without trade-offs. The primary limitation is sampling speed; because diffusion models are iterative, generating samples is slower than the single-pass approach used by Normalizing Flows. Additionally, the transformer's quadratic computational cost relative to token count may pose a bottleneck for extremely high-dimensional data, such as large-scale imagery.

Furthermore, calculating exact log-probabilities—essential for certain statistical tests—requires solving a computationally intensive Ordinary Differential Equation (ODE). Future research may explore "flow-matching" techniques to accelerate sampling or more efficient transformer variants to scale the framework to even larger datasets.

Conclusion

The Simformer offers a unified, flexible, and highly efficient approach to simulation-based inference. By treating parameters and data as a joint sequence and leveraging the power of diffusion and transformers, it provides scientists with a robust tool capable of handling the complexities and irregularities of real-world data.

Summary updated

BibTeX
@inproceedings{gloeckler2024all,
  author = {Manuel Gloeckler and Michael Deistler and Christian Dietrich Weilbach and Frank Wood and Jakob H. Macke},
  title = {{All-in-one simulation-based inference}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=DL79HYCFFq},
}
Figure