normal-computing-oss/posteriors
Uncertainty quantification with PyTorch
What it solves
Deep learning models often give confident predictions even when they are wrong or uncertain. This library helps you measure and represent that uncertainty in PyTorch models, so you can make better decisions, detect out-of-distribution inputs, or improve model calibration.
How it works
posteriors is designed to be functional first: you define a log-posterior function that scores a set of model parameters against a batch of data. Then you plug that function into one of the built-in uncertainty algorithms (like variational inference, extended Kalman filter, Laplace approximation, or stochastic gradient MCMC). The library handles the optimization or sampling steps, returning a new state you feed into the next batch. It uses PyTorch's torch.func for functional model calls, and integrates with familiar tools like torchopt optimizers, Hugging Face transformers, and Lightning.
Who it's for
Researchers and engineers who want to add uncertainty quantification to PyTorch models without writing the underlying math from scratch. It's suited for anyone comfortable with PyTorch who wants to compare different Bayesian methods or scale them to larger models and datasets.
Highlights
- Composable: works with transformers, lightning, torchopt, torch.distributions, and pyro
- Extensible: add new methods or new models easily
- Functional: uses torch.func for easier testing and closer alignment with mathematical definitions
- Scalable: designed to handle big models and big data
- Swappable: change between algorithms with minimal code changes
Related
- Project
- Project
- Project
- Project