Transformers Can Do Bayesian Inference

Samuel Müller, Noah Hollmann, Sebastian Pineda Arango, Josif Grabocka, Frank Hutter
12/20/2021
cs.LGstat.ML
transformer-attentionbayesian

Official code: automl/TransformersCanDoBayesianInference (281 stars, Python, Apache-2.0, last commit 2024-10-24).

Abstract

Currently, it is hard to reap the benefits of deep learning for Bayesian methods, which allow the explicit specification of prior knowledge and accurately capture model uncertainty. We present Prior-Data Fitted Networks (PFNs).

Show full abstract

PFNs leverage in-context learning in large-scale machine learning techniques to approximate a large set of posteriors. The only requirement for PFNs to work is the ability to sample from a prior distribution over supervised learning tasks (or functions). Our method restates the objective of posterior approximation as a supervised classification problem with a set-valued input: it repeatedly draws a task (or function) from the prior, draws a set of data points and their labels from it, masks one of the labels and learns to make probabilistic predictions for it based on the set-valued input of the rest of the data points. Presented with a set of samples from a new supervised learning task as input, PFNs make probabilistic predictions for arbitrary other data points in a single forward propagation, having learned to approximate Bayesian inference. We demonstrate that PFNs can near-perfectly mimic Gaussian processes and also enable efficient Bayesian inference for intractable problems, with over 200-fold speedups in multiple setups compared to current methods. We obtain strong results in very diverse areas such as Gaussian process regression, Bayesian neural networks, classification for small tabular data sets, and few-shot image classification, demonstrating the generality of PFNs. Code and trained PFNs are released at https://github.com/automl/TransformersCanDoBayesianInference.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Official Implementation of "Transformers Can Do Bayesian Inference", the PFN paper

28141Python, Jupyter NotebookDec 14, 20212 years agoApache-2.0

Similar Papers

Cite this paper

@article{mller2021transformers,
  title  = {Transformers Can Do Bayesian Inference},
  author = {Samuel Müller and Noah Hollmann and Sebastian Pineda Arango and Josif Grabocka and Frank Hutter},
  year   = {2021},
  eprint = {2112.10510},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2112.10510}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2112.10510.svg)](https://codeofpaper.com/paper/2112.10510)

Discussion