Variational Low-Rank Adaptation Using IVON

Bai Cong, Nico Daheim, Yuesong Shen, Daniel Cremers, Rio Yokota, Mohammad Emtiyaz Khan, Thomas Möllenhoff

TL;DR

By swapping out the standard AdamW optimizer for the Improved Variational Online Newton (IVON) algorithm, researchers can turn standard LoRA fine-tuning into a variational Bayesian method with virtually zero extra overhead (~1% training time). When fine-tuning Llama-2 (7B), IVON boosts downstream accuracy by 2.8% and reduces expected calibration error by 4.6% (and up to 11.2% with test-time ensembling), outperforming much costlier Bayesian alternatives.

What Problem Does This Paper Address?

Fine-tuning Large Language Models (LLMs) on small downstream datasets often leads to poor model calibration (overconfident, uncalibrated probabilities) and overfitting. While Bayesian deep learning techniques can mitigate these issues by estimating parameter uncertainty, existing Bayesian adaptations for Low-Rank Adaptation (LoRA) carry heavy computational penalties. For instance:

  • Laplace-LoRA requires an expensive extra pass over the training data to calculate Hessian or Fisher information matrices.
  • SWAG-LoRA requires running additional collection steps to build posterior approximations.
  • Deep LoRA ensembles require training multiple independent adapters.

The authors ask: Can we obtain the calibration and generalization benefits of Bayesian learning in LoRA without extra training passes, multiple models, or substantial compute overhead?

Methods

The authors propose IVON-LoRA, which directly replaces AdamW with the Improved Variational Online Newton (IVON) optimizer to optimize the LoRA adapter weights ($A$ and $B$).

  • Variational Objective: Instead of standard empirical risk minimization, IVON optimizes a variational objective: $$\min_{q(\theta)} \mathbb{E}_{q(\theta)}[\ell(\theta)] + \frac{1}{\lambda} D_{\text{KL}}[q(\theta) \parallel p(\theta)]$$ where $q(\theta) = \mathcal{N}(m, \text{diag}(v))$ is a Gaussian variational posterior with mean $m$ and diagonal variance $v$.

  • Free Uncertainty Estimates: Crucially, IVON's second-order learning rate adaptation vector automatically doubles as the estimate of posterior variance ($v$). Evaluating the objective requires only a single Monte Carlo sample per iteration during training.

  • Inference Options: At test time, users can either:
  • Evaluate deterministically at the posterior mean (IVON@mean), which requires no extra inference cost.
  • Average predictions over an ensemble of parameter samples drawn from $\mathcal{N}(m, \text{diag}(\tau v))$ (IVON), where $\tau \in [0, 1]$ allows smoothly interpolating between maximum accuracy ($\tau=0$) and improved calibration ($\tau=1$).

Datasets

The authors evaluated their method on six standard commonsense reasoning multiple-choice and true/false QA benchmarks:

  • WinoGrande-Small (WG-S) and WinoGrande-Medium (WG-M)
  • ARC-Challenge (ARC-C) and ARC-Easy (ARC-E)
  • OpenBookQA (OBQA)
  • BoolQ

Note: No new benchmarks were introduced; all tests used existing standard datasets and prompt templates.

Key Insights and Ideas

  • Posterior Variance for Free: Because IVON naturally maintains a second-order scale vector, variance estimation adds almost no computational cost—sampling and optimization overhead took only 2.8 ms out of 316.3 ms per step (<1% overhead).
  • Flatter Minima Aid Small-Data Regime: Evaluating strictly at the mean (IVON@mean) produced significant generalization gains over AdamW across all datasets. The authors hypothesize that IVON’s variational objective naturally penalizes sharp minima, preventing overfitting when fine-tuning on relatively small datasets.
  • A Tunable Calibration Dial: The variance scaling factor $\tau$ acts as a practical lever. Practitioners needing maximum raw accuracy can use $\tau=0$, while safety-critical applications requiring calibrated probabilistic predictions can increase $\tau \to 1$ to improve Negative Log-Likelihood (NLL) and Brier scores.

Key Results

Experiments fine-tuned a quantized (8-bit base, 16-bit LoRA) Llama-2 7B model on a single NVIDIA RTX 6000 Ada GPU:

  • Accuracy:
  • Standard AdamW achieved an average test accuracy of 76.1%.
  • IVON@mean reached 78.9% (+2.8%), outperforming AdamW, Monte Carlo Dropout (76.3%), SWA (77.2%), SWAG (77.2%), and Laplace Approximation (75.7%).
  • Calibration (ECE $\times 100$):
  • AdamW baseline suffered an Expected Calibration Error of 21.8%.
  • IVON@mean cut ECE down to 17.2% (-4.6%).
  • With a 10-sample test ensemble (IVON), ECE plummeted to 10.6% (a relative decrease of 11.2 percentage points vs. AdamW), matching or beating heavier methods like Laplace Approximation (KFAC: 7.3%, diag: 15.3%) and SWAG (8.1%).
  • Computational Cost: Training speed curves for IVON and AdamW were virtually identical.

Limitations and Future Work

  • Hyperparameter Sensitivity: IVON introduces two extra hyperparameters: the prior weight $\lambda$ and initial posterior variance $v_0$. Currently, selecting these relies on empirical heuristics rather than automated tuning.
  • Gaussian Assumption in LoRA: Standard LoRA parameterizes weight updates as a matrix product $\Delta W = B A$. If $A$ and $B$ are Gaussian distributed, their product is non-Gaussian. Modeling the parameter distribution directly as a Gaussian posterior is an approximation.
  • Inference Overhead for Ensembles: While IVON@mean requires no extra inference time, achieving the lowest ECE and NLL values requires drawing multiple posterior samples (10 forward passes at test time).

Summary updated

BibTeX
@inproceedings{cong2024variational,
  author = {Bai Cong and Nico Daheim and Yuesong Shen and Daniel Cremers and Rio Yokota and Mohammad Emtiyaz Khan and Thomas Möllenhoff},
  title = {{Variational Low-Rank Adaptation Using IVON}},
  booktitle = {FITML @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=nRD5uZa2fe},
}
Figure