Calibrating Transformers via Sparse Gaussian Processes

Wenlong Chen, Yingzhen Li
3/1/2023
23 citations
transformer-attentionbayesian

Official code: chenw20/SGPA (26 stars, Python, last commit 2025-09-15).

Abstract

Transformer models have achieved profound success in prediction tasks in a wide range of applications in natural language processing, speech recognition and computer vision. Extending Transformer's success to safety-critical domains requires calibrated uncertainty estimation which remains under-explored.

Show full abstract

To address this, we propose Sparse Gaussian Process attention (SGPA), which performs Bayesian inference directly in the output space of multi-head attention blocks (MHAs) in transformer to calibrate its uncertainty. It replaces the scaled dot-product operation with a valid symmetric kernel and uses sparse Gaussian processes (SGP) techniques to approximate the posterior processes of MHA outputs. Empirically, on a suite of prediction tasks on text, images and graphs, SGPA-based Transformers achieve competitive predictive accuracy, while noticeably improving both in-distribution calibration and out-of-distribution robustness and detection.

View on arXivView PDF

Code Implementations(1)

chenw20/SGPAOfficial100%

Example code of Sparse Gaussian Process Attention (ICLR 2023)

264PythonFeb 25, 20231 years ago

Similar Papers

Cite this paper

@article{chen2023calibrating,
  title  = {Calibrating Transformers via Sparse Gaussian Processes},
  author = {Wenlong Chen and Yingzhen Li},
  year   = {2023},
  eprint = {2303.02444},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2303.02444},
  journal = {ICLR 2023 2023}
}

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/2303.02444.svg)](https://codeofpaper.com/paper/2303.02444)

Discussion