- Notifications
You must be signed in to change notification settings - Fork194
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.
License
sbi-dev/sbi
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Getting Started |Documentation |Discord Server
sbi
is a Python package for simulation-based inference, designed to meet the needs ofboth researchers and practitioners. Whether you need fine-grained control or aneasy-to-use interface,sbi
has you covered.
Withsbi
, you can perform parameter inference using Bayesian inference: Given asimulator that models a real-world process, SBI estimates the full posteriordistribution over the simulator’s parameters based on observed data. This distributionindicates the most likely parameter values while additionally quantifying uncertaintyand revealing potential interactions between parameters.
sbi
offers a blend of flexibility and ease of use:
- Low-Level Interfaces: For those who require maximum control over the inferenceprocess,
sbi
provides low-level interfaces that allow you to fine-tune many aspectsof your workflow. - High-Level Interfaces: If you prefer simplicity and efficiency,
sbi
also offershigh-level interfaces that enable quick and easy implementation of complex inferencetasks.
In addition,sbi
supports a wide range of state-of-the-art inference algorithms (seebelow for a list of implemented methods):
- Amortized Methods: These methods enable the reuse of posterior estimators acrossmultiple observations without the need to retrain.
- Sequential Methods: These methods focus on individual observations, optimizing thenumber of simulations required.
Beyond inference,sbi
also provides:
- Validation Tools: Built-in methods to validate and verify the accuracy of yourinferred posteriors.
- Plotting and Analysis Tools: Comprehensive functions for visualizing and analyzingresults, helping you interpret the posterior distributions with ease.
Getting started withsbi
is straightforward, requiring only a few lines of code:
fromsbi.inferenceimportNPE# Given: parameters theta and corresponding simulations xinference=NPE(prior=prior)inference.append_simulations(theta,x).train()posterior=inference.build_posterior()
sbi
requires Python 3.10 or higher. While a GPU isn't necessary, it can improveperformance in some cases. We recommend using a virtual environment withconda
for an easy setup.
Ifconda
is installed on the system, an environment for installingsbi
can be created as follows:
conda create -n sbi_env python=3.10&& conda activate sbi_env
To installsbi
from PyPI run
python -m pip install sbi
To install and addsbi
to a project withpixi
, from the project directory run
pixi add sbi
and to install into a particular conda environment withconda
, in the activated environment run
conda install --channel conda-forge sbi
Ifuv
is installed on the system, an environment for installingsbi
can be created as follows:
uv venv -p 3.10
Then activate the virtual enviroment by running:
For
macOS
orLinux
userssource .venv/bin/activate
For
Windows
users.venv\Scripts\activate
To installsbi
run
uv add sbi
Open a Python prompt and run
fromsbi.examples.minimalimportsimpleposterior=simple()print(posterior)
If you're new tosbi
, we recommend starting with ourGettingStarted tutorial.
You can also access and run these tutorials directly in your browser by openingCodespace. To do so, click the green“Code” button on the GitHub repository and select “Open with Codespaces.” This providesa fully functional environment where you can exploresbi
through Jupyter notebooks.
The following inference algorithms are currently available. You can find instructions onhow to run each of these methodshere.
(S)NPE_A
(including amortized single-roundNPE
) from Papamakarios G and Murray IFastε-free Inference of Simulation Models with Bayesian Conditional DensityEstimation(NeurIPS 2016).(S)NPE_B
from Lueckmann JM, Goncalves P, Bassetto G, Öcal K, Nonnenmacher M, and Macke JFlexiblestatistical inference for mechanistic models of neural dynamics(NeurIPS 2017).(S)NPE_C
orAPT
from Greenberg D, Nonnenmacher M, and Macke JAutomatic PosteriorTransformation for likelihood-free inference (ICML2019).TSNPE
from Deistler M, Goncalves P, and Macke JTruncated proposals for scalableand hassle-free simulation-based inference(NeurIPS 2022).FMPE
from Wildberger, J., Dax, M., Buchholz, S., Green, S., Macke, J. H., & Schölkopf, B.Flow matching for scalable simulation-basedinference.(NeurIPS 2023).NPSE
fromGeffner, T., Papamakarios, G., & Mnih, A.Compositional score modeling forsimulation-based inference.(ICML 2023)
(S)NLE
or justSNL
from Papamakarios G, Sterrat DC and Murray ISequential NeuralLikelihood (AISTATS 2019).
(S)NRE_A
orAALR
from Hermans J, Begy V, and Louppe G.Likelihood-free Inference withAmortized Approximate Likelihood Ratios (ICML2020).(S)NRE_B
orSRE
from Durkan C, Murray I, and Papamakarios G.On Contrastive Learning forLikelihood-free Inference (ICML 2020).(S)NRE_C
orNRE-C
from Miller BK, Weniger C, Forré P.Contrastive Neural RatioEstimation (NeurIPS 2022).BNRE
fromDelaunoy A, Hermans J, Rozet F, Wehenkel A, and Louppe G.Towards ReliableSimulation-Based Inference with Balanced Neural RatioEstimation (NeurIPS 2022).
SNVI
from Glöckler M, Deistler M, Macke J,Variational methods for simulation-basedinference (ICLR 2022).
MNLE
fromBoelts J, Lueckmann JM, Gao R, Macke J,Flexible and efficient simulation-basedinference for models of decision-making(eLife 2022).
We welcome any feedback on howsbi
is working for your inference problems (seeDiscussions) and are happy to receive bugreports, pull requests, and other feedback (seecontribute). We wish to maintain apositive and respectful community; please read ourCode ofConduct.
sbi
is the successor (using PyTorch) of thedelfi
package. It started as a fork of Conor M.Durkan'slfi
.sbi
runs as a community project. See alsocredits.
sbi
has been supported by the German Federal Ministry of Education and Research (BMBF)through project ADIMEM (FKZ 01IS18052 A-D), project SiMaLeSAM (FKZ 01IS21055A) and theTübingen AI Center (FKZ 01IS18039A). Since 2024,sbi
is supported by the appliedAIInstitute for Europe, and by NumFOCUS.
Apache License Version 2.0 (Apache-2.0)
Thesbi
package has grown and improved significantly since its initial release, withcontributions from a large and diverse community. To reflect these developments and theexpanded functionality, we published anupdated JOSSpaper. We encourage you to cite thisnewer version as the primary reference:
@article{BoeltsDeistler_sbi_2025, doi = {10.21105/joss.07754}, url = {https://doi.org/10.21105/joss.07754}, year = {2025}, publisher = {The Open Journal}, volume = {10}, number = {108}, pages = {7754}, author = {Jan Boelts and Michael Deistler and Manuel Gloeckler and Álvaro Tejero-Cantero and Jan-Matthis Lueckmann and Guy Moss and Peter Steinbach and Thomas Moreau and Fabio Muratore and Julia Linhart and Conor Durkan and Julius Vetter and Benjamin Kurt Miller and Maternus Herold and Abolfazl Ziaeemehr and Matthijs Pals and Theo Gruner and Sebastian Bischoff and Nastya Krouglova and Richard Gao and Janne K. Lappalainen and Bálint Mucsányi and Felix Pei and Auguste Schulz and Zinovia Stefanidi and Pedro Rodrigues and Cornelius Schröder and Faried Abu Zaid and Jonas Beck and Jaivardhan Kapoor and David S. Greenberg and Pedro J. Gonçalves and Jakob H. Macke}, title = {sbi reloaded: a toolkit for simulation-based inference workflows}, journal = {Journal of Open Source Software}}
This updated paper, with its expanded author list, reflects the broader communitycontributions and the package's enhanced capabilities in releases0.23.0 and later.
If you are using a version ofsbi
prior to 0.23.0, please cite the original sbisoftware paper:
@article{tejero-cantero2020sbi, doi = {10.21105/joss.02505}, url = {https://doi.org/10.21105/joss.02505}, year = {2020}, publisher = {The Open Journal}, volume = {5}, number = {52}, pages = {2505}, author = {Alvaro Tejero-Cantero and Jan Boelts and Michael Deistler and Jan-Matthis Lueckmann and Conor Durkan and Pedro J. Gonçalves and David S. Greenberg and Jakob H. Macke}, title = {sbi: A toolkit for simulation-based inference}, journal = {Journal of Open Source Software}}
Regardless of which software paper you cite, please also remember to cite the originalresearch articles describing the specific sbi-algorithm(s) you are using.
Specific releases ofsbi
are also citable viaZenodo, where we generate a new software DOI foreach release.
About
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.
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.