[Paper Review] BayesFormer: Transformer with Uncertainty Estimation
BayesFormer introduces a theoretically grounded uncertainty estimation method for Transformers using approximate variational inference with a novel dropout mechanism. By applying dropout in attention and feed-forward layers with Bayesian regularization, it improves predictive uncertainty calibration, reducing overfitting and boosting performance across NLP tasks, including active learning and long-context modeling.
Transformer has become ubiquitous due to its dominant performance in various NLP and image processing tasks. However, it lacks understanding of how to generate mathematically grounded uncertainty estimates for transformer architectures. Models equipped with such uncertainty estimates can typically improve predictive performance, make networks robust, avoid over-fitting and used as acquisition function in active learning. In this paper, we introduce BayesFormer, a Transformer model with dropouts designed by Bayesian theory. We proposed a new theoretical framework to extend the approximate variational inference-based dropout to Transformer-based architectures. Through extensive experiments, we validate the proposed architecture in four paradigms and show improvements across the board: language modeling and classification, long-sequence understanding, machine translation and acquisition function for active learning.
Motivation & Objective
- Address the lack of mathematically grounded uncertainty quantification in Transformer models, especially in small-data or high-stakes scenarios.
- Improve model robustness, reduce overfitting, and enhance reliability in prediction confidence estimation for real-world deployment.
- Enable better active learning performance by providing more accurate uncertainty estimates for sample selection.
- Develop a theoretically justified dropout-based uncertainty estimation framework tailored for Transformer architectures.
- Demonstrate generalization across diverse NLP paradigms, including fine-tuning, long-context understanding, and machine translation.
Proposed method
- Apply approximate variational inference to derive a posterior distribution over Transformer weights, using a Gaussian prior on weights.
- Introduce a new dropout structure where dropout is applied in both attention and feed-forward sublayers, with a separate dropout rate of 0.05.
- Use Monte Carlo dropout (MCDropout) with 11 forward passes to estimate predictive uncertainty and epistemic uncertainty via the BALD acquisition function.
- Train BayesFormer using the evidence lower bound (ELBO) objective, minimizing KL divergence between the approximate posterior and true posterior.
- Maintain standard Transformer architecture while adding Bayesian dropout only to attention and feed-forward layers, without modifying existing dropout rates.
- Use label smoothing and LabelSmoothedCrossEntropyCriterion for training to improve generalization and uncertainty calibration.
Experimental results
Research questions
- RQ1Can approximate variational inference be effectively extended to Transformer architectures to provide mathematically grounded uncertainty estimates?
- RQ2How does the proposed BayesFormer dropout mechanism improve uncertainty calibration compared to standard MCDropout in standard Transformers?
- RQ3Does the uncertainty estimation from BayesFormer lead to better performance in active learning, especially under low-label budgets?
- RQ4To what extent does BayesFormer reduce overfitting during fine-tuning on small datasets compared to standard RoBERTa?
- RQ5Can the uncertainty estimates from BayesFormer generalize across diverse NLP tasks, including sequence modeling, translation, and zero-shot transfer?
Key findings
- BayesFormer achieves a 32.1 MCC on the CoLA dev set, significantly outperforming RoBERTa base (21.3), demonstrating improved generalization and uncertainty calibration.
- On the GLUE benchmark, BayesFormer achieves 91.3% accuracy on SST-2, 90.9% F1 on MRPC, and 83.3% accuracy on MNLI, surpassing RoBERTa base in multiple tasks.
- In active learning, BayesFormer achieves a dev set MCC of 62.8—4 points higher than RoBERTa and 3.6 points higher than random sampling—when using only 10% of the data.
- The best model performance was achieved by discarding some labeled data, indicating that BayesFormer's uncertainty estimates help avoid overfitting to noisy or ambiguous examples.
- BayesFormer improves test BLEU scores in machine translation by 0.5–1.0 BLEU points over the baseline Transformer, with higher validation BLEU, indicating better generalization.
- The model maintains performance gains across all evaluated tasks, including long-context understanding and few-shot learning, with no additional hyperparameter tuning beyond the new dropout rate.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.