Bayesian Transformer for Probabilistic Load Forecasting in Smart Grids
Organizations: O&M Analytics, AES Clean Energ; The AES Corporation; Louisville, CO 80027, USA · Department of Information and Communication Engineering; Pabna University of Science and Technology; Rajapur, Pabna, Bangladesh
Abstract
The reliable operation of modern power grids requires probabilistic load forecasts with well-calibrated uncertainty estimates. However, existing deep learning models produce overconfident point predictions that fail catastrophically under extreme weather distributional shifts. This study proposes a Bayesian Transformer (BT) framework that integrates three complementary uncertainty mechanisms into a PatchTST backbone: Monte Carlo Dropout for epistemic parameter uncertainty, variational feed-forward layers with log-uniform weight priors, and stochastic attention with learnable Gaussian noise perturbations on pre-softmax logits, representing, to the best of our knowledge, the first application of Bayesian attention to probabilistic load forecasting. A seven-level multi-quantile pinball-loss prediction head and post-training isotonic regression calibration produce sharp, near-nominally covered prediction intervals. Evaluation of five grid datasets (PJM, ERCOT, ENTSO-E Germany, France, and Great Britain) augmented with NOAA covariates across 24, 48, and 168-hour horizons demonstrates state-of-the-art performance. On the primary benchmark (PJM, H=24h), BT achieves a CRPS of 0.0289, improving 7.4% over Deep Ensembles and 29.9% over the deterministic LSTM, with 90.4% PICP at the 90% nominal level and the narrowest prediction intervals (4,960 MW) among all probabilistic baselines. During heat-wave and cold snap events, BT maintained 89.6% and 90.1% PICP respectively, versus 64.7% and 67.2% for the deterministic LSTM, confirming that Bayesian epistemic uncertainty naturally widens intervals for out-of-distribution inputs. Calibration remained stable across all horizons (89.8-90.4% PICP), while ablation confirmed that each component contributed a distinct value. The calibrated outputs directly support risk-based reserve sizing, stochastic unit commitment, and demand response activation.
Figures & tables
| Dataset | Territory | Period | Obs. (hrs) | Peak Demand | Renew. Share |
|---|---|---|---|---|---|
| PJM | Mid-Atlantic & Midwest US | 2015–2023 | 78,840 | 165 GW | 12% |
| ERCOT | Texas, US | 2015–2023 | 78,840 | 85 GW | 32% |
| ENTSO-E (DE) | Germany | 2015–2023 | 78,840 | 83 GW | 52% |
| ENTSO-E (FR) | France | 2015–2023 | 78,840 | 97 GW | 28% |
| ENTSO-E (GB) | Great Britain | 2015–2023 | 78,840 | 62 GW | 40% |
| Partition | Period | Purpose | Proportion |
|---|---|---|---|
| Training | Jan 2015 – Dec 2020 | Model parameter optimization | 67% |
| Validation (calibration fit) | Jan 2021 – Jun 2021 | Calibration pipeline fitting, early stopping | 8% |
| Validation (calibration eval) | Jul 2021 – Dec 2021 | Post-calibration performance verification | 8% |
| Test | Jan 2022 – Dec 2023 | Final held-out evaluation | 22% |
| Hyperparameter | Value | Selection Criterion |
|---|---|---|
| Transformer layers ( ) | 6 | Validation CRPS grid search |
| Attention heads | 8 | Standard for |
| Model dimension ( ) | 512 | Validation CRPS grid search |
| Feed-forward dimension | 2048 | model dimension convention |
| Patch size ( ) | 16 hrs | Captures intraday ramp patterns |
| Lookback window ( ) | 168 hrs | Full weekly periodicity coverage |
| Model | MAE (MW) | RMSE (MW) | CRPS | PICP 90% | MPIW (MW) | Winkler |
|---|---|---|---|---|---|---|
| Det. LSTM | 1,842 | 2,531 | 0.0412 | 81.3% | 7,210 | 0.0891 |
| Standard Transformer | 1,621 | 2,218 | 0.0387 | 83.1% | 6,870 | 0.0823 |
| Quantile LSTM | 1,698 | 2,344 | 0.0351 | 87.6% | 5,940 | 0.0714 |
| Deep Ensemble (5 ) | 1,589 | 2,176 | 0.0312 | 89.2% | 5,480 | 0.0643 |
| CQR (PatchTST) | 1,634 | 2,257 | 0.0328 | 90.1% | 6,120 | 0.0671 |
| BT (Ours) | 1,573 | 2,143 | 0.0289 | 90.4% | 4,960 | 0.0598 |
| Dataset | Det. LSTM | Std. Transformer | Quant. LSTM | Deep Ensemble | CQR | BT (Ours) |
|---|---|---|---|---|---|---|
| PJM-CRPS | 0.0412 | 0.0387 | 0.0351 | 0.0312 | 0.0328 | 0.0289 |
| PJM-PICP 90% | 81.3% | 83.1% | 87.6% | 89.2% | 90.1% | 90.4% |
| ERCOT-CRPS | 0.0448 | 0.0421 | 0.0382 | 0.0334 | 0.0357 | 0.0311 |
| ERCOT-PICP 90% | 79.8% | 81.4% | 86.1% | 88.4% | 90.0% | 90.2% |
| ENTSO-E DE-CRPS | 0.0391 | 0.0363 | 0.0328 | 0.0297 | 0.0311 | 0.0274 |
| ENTSO-E DE-PICP 90% | 82.1% | 83.8% | 88.2% | 89.6% | 90.3% | 90.5% |
| Model | HW MAE (MW) | HW PICP 90% | CS MAE (MW) | CS PICP 90% |
|---|---|---|---|---|
| Det. LSTM | 3,241 | 64.7% | 3,089 | 67.2% |
| Standard Transformer | 2,987 | 66.8% | 2,874 | 68.9% |
| Quantile LSTM | 2,634 | 76.3% | 2,512 | 78.1% |
| Deep Ensemble (5 ) | 2,318 | 85.1% | 2,201 | 86.4% |
| CQR (PatchTST) | 2,541 | 88.7% | 2,389 | 89.1% |
| BT (Ours) | 2,104 | 89.6% | 1,987 | 90.1% |
| Nominal Level | Quantile LSTM | Deep Ensemble | CQR | BT (Ours) | Target |
|---|---|---|---|---|---|
| 5th percentile | 3.1% | 4.2% | 5.1% | 5.0% | 5.0% |
| 10th percentile | 7.4% | 8.9% | 10.0% | 9.9% | 10.0% |
| 25th percentile | 20.1% | 23.4% | 24.8% | 24.9% | 25.0% |
| 50th percentile | 47.8% | 49.1% | 50.0% | 50.0% | 50.0% |
| 75th percentile | 70.3% | 73.2% | 74.9% | 75.1% | 75.0% |
| 90th percentile | 85.9% | 88.6% | 90.1% | 90.4% | 90.0% |
| Configuration | MAE (MW) | RMSE (MW) | CRPS | PICP 90% | MPIW (MW) |
|---|---|---|---|---|---|
| (A) Base PatchTST (deterministic) | 1,621 | 2,218 | 0.0387 | 83.1% | — |
| (B) A + MC Dropout | 1,598 | 2,189 | 0.0334 | 87.4% | 5,820 |
| (C) B + Variational FF layers | 1,584 | 2,162 | 0.0311 | 88.9% | 5,490 |
| (D) C + Stochastic Attention | 1,577 | 2,153 | 0.0296 | 89.8% | 5,180 |
| (E) D + Quantile head (pinball) | 1,574 | 2,148 | 0.0293 | 89.9% | 5,040 |
| (F) E + Post-training Calibration (Full) | 1,573 | 2,143 | 0.0289 | 90.4% | 4,960 |
| Model | Params (M) | Train Time / Epoch | Inference Latency | MC Passes |
|---|---|---|---|---|
| Det. LSTM | 18.4 | 1.2 min | 0.018 s | 1 |
| Standard Transformer | 42.1 | 2.1 min | 0.031 s | 1 |
| Quantile LSTM | 18.4 | 1.4 min | 0.019 s | 1 |
| Deep Ensemble (5 ) | 210.5 | 10.5 min | 0.155 s | 5 |
| CQR (PatchTST) | 42.1 | 2.1 min | 0.033 s | 1 |
| BT (Ours) | 44.3 | 2.8 min | 1.84 s | 100 |