Sbi
sbi is a Python package for simulation-based inference, designed to meet the needs of both researchers and practitioners. Whether you need fine-grained control or an easy-to-use interface, sbi has you covered.
Install / Use
/learn @sbi-dev/SbiREADME
sbi: Simulation-Based Inference
Getting Started | Documentation | Discord Server
sbi is a Python package for simulation-based inference, designed to meet the needs of
both researchers and practitioners. Whether you need fine-grained control or an
easy-to-use interface, sbi has you covered.
With sbi, you can perform parameter inference using Bayesian inference: Given a
simulator that models a real-world process, SBI estimates the full posterior
distribution over the simulator’s parameters based on observed data. This distribution
indicates the most likely parameter values while additionally quantifying uncertainty
and revealing potential interactions between parameters.
Key Features of sbi
sbi offers a blend of flexibility and ease of use:
- Low-Level Interfaces: For those who require maximum control over the inference
process,
sbiprovides low-level interfaces that allow you to fine-tune many aspects of your workflow. - High-Level Interfaces: If you prefer simplicity and efficiency,
sbialso offers high-level interfaces that enable quick and easy implementation of complex inference tasks.
In addition, sbi supports a wide range of state-of-the-art inference algorithms (see
below for a list of implemented methods):
- Amortized Methods: These methods enable the reuse of posterior estimators across multiple observations without the need to retrain.
- Sequential Methods: These methods focus on individual observations, optimizing the number of simulations required.
Beyond inference, sbi also provides:
- Validation Tools: Built-in methods to validate and verify the accuracy of your inferred posteriors.
- Plotting and Analysis Tools: Comprehensive functions for visualizing and analyzing results, helping you interpret the posterior distributions with ease.
Getting started with sbi is straightforward, requiring only a few lines of code:
from sbi.inference import NPE
# Given: parameters theta and corresponding simulations x
inference = NPE(prior=prior)
inference.append_simulations(theta, x).train()
posterior = inference.build_posterior()
Installation
sbi requires Python 3.10 or higher. While a GPU isn't necessary, it can improve
performance in some cases. We recommend using a virtual environment with
conda for an easy setup.
If conda is installed on the system, an environment for installing sbi can be created as follows:
conda create -n sbi_env python=3.10 && conda activate sbi_env
From PyPI
To install sbi from PyPI run
python -m pip install sbi
From conda-forge
To install and add sbi to a project with pixi, from the project directory run
pixi add sbi
and to install into a particular conda environment with conda, in the activated environment run
conda install --channel conda-forge sbi
If uv is installed on the system, an environment for installing sbi can be created as follows:
uv venv -p 3.10
Then activate the virtual enviroment by running:
-
For
macOSorLinuxuserssource .venv/bin/activate -
For
Windowsusers.venv\Scripts\activate
To install sbi run
uv add sbi
Testing the installation
Open a Python prompt and run
from sbi.examples.minimal import simple
posterior = simple()
print(posterior)
Tutorials
If you're new to sbi, we recommend starting with our Getting
Started tutorial.
You can also access and run these tutorials directly in your browser by opening
Codespace. To do so, click the green
“Code” button on the GitHub repository and select “Open with Codespaces.” This provides
a fully functional environment where you can explore sbi through Jupyter notebooks.
You might also find this tutorial paper useful: Deistler, M., Boelts, J., Steinbach, P., Moss, G., Moreau, T., Gloeckler, M., ... & Macke, J. H. (2025). Simulation-based inference: A practical guide. arXiv preprint arXiv:2508.12939.. It describes the SBI workflow and offers practical guidelines and diagnostic tools for every stage of the process: from setting up the simulator and prior, choosing and training inference networks, to performing inference and validating the results. It also includes several worked examples.
Inference Algorithms
The following inference algorithms are currently available. You can find instructions on how to run each of these methods here.
Neural Posterior Estimation: amortized (NPE) and sequential (SNPE)
-
(S)NPE_A(including amortized single-roundNPE) from Papamakarios G and Murray I Fast ε-free Inference of Simulation Models with Bayesian Conditional Density Estimation (NeurIPS 2016). -
(S)NPE_Bfrom Lueckmann JM, Goncalves P, Bassetto G, Öcal K, Nonnenmacher M, and Macke J Flexible statistical inference for mechanistic models of neural dynamics (NeurIPS 2017). -
(S)NPE_CorAPTfrom Greenberg D, Nonnenmacher M, and Macke J Automatic Posterior Transformation for likelihood-free inference (ICML 2019). -
TSNPEfrom Deistler M, Goncalves P, and Macke J Truncated proposals for scalable and hassle-free simulation-based inference (NeurIPS 2022). -
FMPEfrom Wildberger, J., Dax, M., Buchholz, S., Green, S., Macke, J. H., & Schölkopf, B. Flow matching for scalable simulation-based inference. (NeurIPS 2023). -
NPSEfrom Geffner, T., Papamakarios, G., & Mnih, A. Compositional score modeling for simulation-based inference. (ICML 2023)
Neural Likelihood Estimation: amortized (NLE) and sequential (SNLE)
(S)NLEor justSNLfrom Papamakarios G, Sterrat DC and Murray I Sequential Neural Likelihood (AISTATS 2019).
Neural Ratio Estimation: amortized (NRE) and sequential (SNRE)
-
(S)NRE_AorAALRfrom Hermans J, Begy V, and Louppe G. Likelihood-free Inference with Amortized Approximate Likelihood Ratios (ICML 2020). -
(S)NRE_BorSREfrom Durkan C, Murray I, and Papamakarios G. On Contrastive Learning for Likelihood-free Inference (ICML 2020). -
(S)NRE_CorNRE-Cfrom Miller BK, Weniger C, Forré P. Contrastive Neural Ratio Estimation (NeurIPS 2022). -
BNREfrom Delaunoy A, Hermans J, Rozet F, Wehenkel A, and Louppe G. Towards Reliable Simulation-Based Inference with Balanced Neural Ratio Estimation (NeurIPS 2022).
Neural Variational Inference, amortized (NVI) and sequential (SNVI)
SNVIfrom Glöckler M, Deistler M, Macke J, Variational methods for simulation-based inference (ICLR 2022).
Mixed Neural Likelihood Estimation (MNLE)
MNLEfrom Boelts J, Lueckmann JM, Gao R, Macke J, [_Flexible and efficient simulation-based inferen
