Functional-level Uncertainty Quantification for Calibrated Fine-tuning on LLMs

## Abstract

Abstract From common-sense reasoning to domain-specific tasks, parameter-efficient fine tuning (PEFT) methods for large language models (LLMs) have showcased significant performance improvements on downstream tasks. However, fine-tuned LLMs often struggle with overconfidence in uncertain predictions, particularly due to sparse training data. This overconfidence reflects poor epistemic uncertainty calibration, which arises from limitations in the model’s ability to generalize with limited data. Existing PEFT uncertainty quantification methods for LLMs focus on the post fine-tuning stage and thus have limited capability in calibrating epistemic uncertainty. To address these limitations, we propose Functional-Level Uncertainty Quantification for Calibrated Fine-Tuning (UQ4CT), which captures and calibrates functional-level epistemic uncertainty during the fine-tuning stage via a mixture-of-expert framework. We show that UQ4CT reduces Expected Calibration Error (ECE) by more than 25 % percent 25 25\% 25 % while maintaining high accuracy across 5 5 5 5 benchmarks. Furthermore, UQ4CT maintains superior ECE performance with high accuracy under distribution shift, showcasing improved generalizability.

## 1 Introduction

Large Language Models (LLMs) have revolutionized various domains as general task solvers (Chang et al., ). To adapt LLMs for specific downstream tasks or create instruction-following models, fine-tuning have become increasingly important (Houlsby et al., ; Hu et al., ; Liu et al., ; Ding et al., , ). This involves additional training on pre-trained LLMs using a smaller dataset (Zhong et al., ; Ren et al., ). Through fine-tuning, the model parameters are updated to better adapt to the domain-specific knowledge (Peng et al., ). To reduce the computational cost for fine-tuning, Hu et al. () proposed Low-Rank Adaptation (LoRA), which effectively reduces the parameters required for fine-tuning by introducing low-rank trainable matrices at each layer of the transformer architecture instead of fine-tuning the full model parameters. Li et al. (); Wu et al. () proposed LoRA Mixture-of-Experts (MoE) models which grants better performance while maintaining parameter efficiency.

However, previous studies have shown that fine-tuned LLMs are often overconfident with their predictions (Xiao et al., ; He et al., ; Tian et al., ; OpenAI, ). This resembles poorly calibrated uncertainty (Zhou et al., ) due to the sparsity of fine-tuning data. Overconfidence is a crucial problem in safety-related decision making or in fields where data is very limited, such as experimental design, climate science and medical diagnosis (Singhal et al., ; Wu et al., ; Lampinen et al., ; Li et al., ). Thus, methods that enhance uncertainty quantification of fine-tuned LLMs is urgently needed to assure trustworthy predictions for better application.

Established uncertainty quantification methods have been studied in conjunction with the LoRA structure. Monte-Carlo dropout (Gal and Ghahramani, ) interprets dropout in neural networks as approximate Bayesian inference in deep Gaussian processes, allowing uncertainty estimates to be obtained from existing LoRA adapters without modifying them. Checkpoint ensemble (Chen et al., ) utilizes predictions from multiple LoRA checkpoints saved during a single fine-tuning process to calibrate uncertainty. Deep ensemble (Lakshminarayanan et al., ; Wang et al., ; Zhai et al., ) combines the predictions from multiple LoRA adapters for better uncertainty calibration. Laplace-LoRA (Yang et al., ) applies Bayesian inference via Laplace approximation to the LoRA parameters after fine-tuning, resulting in improved calibration and uncertainty estimates.
Although these methods have demonstrated improved uncertainty estimations, they all
utilize a fixed set of LoRA parameters fine-tuned over the entire downstream task dataset. The point estimates of parameters have very limited capabilities in capturing epistemic uncertainty, while direct calibration of epistemic uncertainty over the entire LoRA parameter space is an ideal but not practical approach.

Therefore, we propose Functional-Level Uncertainty Quantification for Calibrated Fine-Tuning (UQ4CT) to calibrate the functional-level epistemic uncertainty via the LoRA MoE architecture. We propose a functional perspective on LoRA parameters where we treat the LoRA experts as basis functions and consider the more complex, prompt dependent functions as mixtures of those basis functions.
On top of learning the parameters in the LoRA experts, UQ4CT also trains a prompt-dependent LoRA mixture to form a calibrated distribution over the functional space. The LoRA experts capture different functional relationships in the fine-tuning data throughout training, and the MoE routers dynamically select these functional bases conditioned on the input. The selection process models the functional level epistemic uncertainty, and consequently captures the uncertainty in the output space. We calibrate functional level epistemic uncertainty to align with predictive correctness during training time. This significantly improves uncertainty estimations of the model on its predictions without compromising the accuracy. To summarize, our contributions include:

- •
A novel epistemic uncertainty quantification approach with Mixture-of-Experts architecture during fine-tuning stage to model functional level epistemic uncertainty and align with predictive correctness, which mitigates overconfidence issue and improves generalizability.
- •
A novel training calibration loss function incorporating predictive correctness to calibrate the prompt-dependent LoRA mixture for better uncertainty estimation.
- •
More than $25\%$ Expected Calibration Error reduction on $4$ common-sense reasoning tasks and $1$ domain-specific question answering task, superior ECE performance under distribution shift scenarios on $2$ common-sense reasoning tasks and $4$ domain-specific question answering tasks without compromising accuracy.

## 2 Preliminaries

### 2.1 Low-rank Adaptation (LoRA)

LLMs have numerous large weight matrices to perform matrix multiplication, denoted as $\mathbf{W}_{0}\in\mathbb{R}^{n_{\text{out}}\times n_{\text{in}}}$ that maps inputs $\mathbf{x}$ to outputs $\mathbf{h}$. Hu et al. () proposes LoRA, which fixes $\mathbf{W}_{0}$ and introduces a low-rank perturbation $\Delta\mathbf{W}$ to the weight matrix:

$$ $\displaystyle\mathbf{h}$ $\displaystyle=\mathbf{W}_{0}\mathbf{x}+\Delta\mathbf{W}\mathbf{x}=\mathbf{W}_{ 0}\mathbf{x}+\mathbf{B}\mathbf{A}\mathbf{x}.$ (1) $$

Here, $\Delta\mathbf{W}$ is calculated as the product of two matrices, $\mathbf{B}\in\mathbb{R}^{n_{\text{out}}\times n_{\text{lr}}}$ and $\mathbf{A}\in\mathbb{R}^{n_{\text{lr}}\times n_{\text{in}}}$ where $n_{\text{lr}}$ is significantly smaller than $n_{\text{in}}$ or $n_{\text{out}}$. For example, we use $n_{\text{lr}}=32$ while $n_{\text{in}}=n_{\text{out}}=4096$ for the Llama2-7b model (Touvron et al., ). Therefore, the total number of LoRA parameters for this $\Delta\mathbf{W}$ is $n_{\text{lr}}(n_{\text{in}}+n_{\text{out}})$, which is far smaller than the parameter count of the full matrix, $n_{\text{in}}n_{\text{out}}$. One of the key motivations of incorporating LoRA to fine-tune LLMs is the vast amount of memory cost reduction compared with fine-tuning on the full model. For an LLM with $7$ billion parameters, maintaining the average gradient
and average squared gradients for optimization multiplies the memory required by a factor of $3$ compared to simply loading model weights. LoRA greatly mitigates this memory cost as the tripled memory consumption only applies to LoRA adapters.

### 2.2 Mixture of Experts (MoE)

LoRA Mixture-of-Experts (Li et al., ; Wu et al., ) is a efficient approach to scale the number of parameters while maintaining the same computational bounds. LoRA MoE utilizes the top-k router to assign each token to the LoRA experts (Lepikhin et al., ). The router is a linear layer that maps the input hidden state $\mathbf{h}$ to a probability distribution of candidate experts.

Let $\mathbf{h}^{\ell}_{i}\in\mathbb{R}^{1\times d}$ $(1\leq i\leq s,1\leq\ell\leq L)$ denote the output hidden state of the $i$-th token at the $\ell$-th layer of the LLM, where $L$ is the number of LLM layers and $d$ is the hidden dimension. With $\mathbf{W}_{r}^{\ell}$ as the trainable router weight at layer $\ell$, the top-k gate router chooses $k$ experts with highest probability given a hidden state $\mathbf{h}_{i}^{\ell}$:

$$ $R^{\ell}(\mathbf{h}^{\ell}_{i})=\text{KeepTop-k}(\text{Softmax}(\mathbf{W}^{ \ell}_{r}\cdot\mathbf{h}_{i}^{\ell})).$ (2) $$

Finally, we obtain the final MixLoRA prediction with:

$$ $\text{MixLoRA}(\mathbf{h}^{\ell})=\sum_{k=1}^{K}R^{\ell}(\mathbf{h}^{\ell})_{k }E^{\ell}_{k}(\mathbf{h}^{\ell}),\quad E^{\ell}_{k}(\mathbf{h}^{\ell})=\mathbf {W}^{\ell}\cdot\mathbf{h}^{\ell}+\mathbf{B}^{\ell}_{i}\mathbf{A}^{\ell}_{i} \cdot\mathbf{h}^{\ell}$ (3) $$

where $\mathbf{W}$ is the pretrained weights of the feed-forward network (FFN) layer and $\mathbf{B}^{\ell}_{i}\mathbf{A}^{\ell}_{i}$ is the i-th LoRA expert.

### 2.3 Aleatoric and Epistemic Uncertainties

In machine learning models, uncertainty can be categorized into aleatoric (data-wise) and epistemic (model-wise) uncertainty (Hora, ; Hüllermeier and Waegeman, ). For LLMs, aleatoric uncertainty arises from the inherently ambiguous and context dependent nature of natural languages where a single phrase or sentence can have multiple valid interpretations in different contexts. Epistemic uncertainty is introduced by the model’s lack of knowledge due to limited learning capabilities, suboptimal modeling or sparse training data.

Epistemic uncertainty is highly related to several well-known limitations of generative models. For example, it has been observed that when an LLM is pretrained on a diverse range of text data, it is generally well-calibrated, i.e. the predicted probability of the next token generally aligns with what is observed in real text. However, after fine-tuning or alignment with human preferences, the calibration error deteriorates (Zhao et al., ; Achiam et al., ). A related phenomenon is forgetting, where the performance of a fine-tuned LLM diminishes on tasks outside the scope of the target downstream task (Lin et al., ; Luo et al., ).

Motivated by these observations, we explore functional-level epistemic uncertainty in generative models and aim to develop metrics that assess model performance on specific problem instances to fine-tune the parameter mixture.

## 3 Methodology

The high level goal of UQ4CT is to balance the exploration and exploitation of different LoRA experts during fine-tuning. In particular, we incorporate the functional-level epistemic uncertainty (FEU) to calibrate the prompt-dependent parameter mixture with LoRA MoE.

Assume that our answer $a$ is generated via a mixture of mechanisms or models $M$, conditioning on the input prompt $x$. Assume that $e(a)$ is an embedding of $a$ so that least squares distance is a natural distance on the space of $e(a)$. For an expressive enough model class $\mathcal{M}$, and a calibrated distribution $P(M|x)$ over the model class, we can measure the deviation of the generated answer to the “ideal” one $a_{*}=f_{*}(x)$ as:

$$ $\displaystyle\mathbb{E}_{M\sim P(M|x)}\left[\mathbb{E}_{a\sim P(a|M,x)}\left[ \|e(a)-e(a_{*})\|^{2}\right]\right]$ $\displaystyle=\mathbb{E}_{P(M|x)}\underbrace{\left[\mathbb{E}_{P(a|M,x)}\left[ \|e(a)-\mathbb{E}_{P(a|M,x)}[e(a)]\|^{2}\right]\right]}_{\text{Aleatoric Uncertainty}}+\underbrace{\mathbb{E}_{P(M|x)}\left[\|\mathbb{E}_{P(a|M,x)}[e(a )]-e(a_{*})\|^{2}\right]}_{\text{Epistemic Uncertainty}}.$ (4) $$

Note that we hereby quantify uncertainty as a function of the input prompt $x$, since the distribution of model $M$ conditions on $x$.
We hence name the task “functional-level uncertainty quatification”.

### 3.1 Functional-level Epistemic Uncertainty

Figure: Figure 1: Mixture of Experts (MoE) architecture to capture and calibrate functional-level epistemic uncertainty. Experts $B_{1...N}A_{1...N}$ capture functional relationships in the data throughout fine-tuning, the weights $w_{1...N}|h$ quantify the uncertainty in selecting these functional bases conditioned on the input hidden state $h$, which is the semantic representation of the input token $x$. In the UQ4CT workflow, we align this uncertainty with predictive correctness. When the router makes a correct prediction, the loss reinforces this decision, thereby increasing the router confidence in its selection, which aligns with a lower epistemic uncertainty. Conversely, when the router makes an incorrect prediction, the loss penalizes this selection, potentially causing the router to distribute its probabilities more broadly across experts, which is indicative of higher epistemic uncertainty.
Refer to caption: x1.png

Motivated by the decomposition in Eq. (3) for least squares loss, we may consider a general distance $d$, and define epistemic uncertainty that characterizes the variation caused by model training procedure. Specifically, we focus on the variation introduced in the model fine-tuning
stage of LLMs. Mathematically, given prompt $x$, we consider the following definition of epistemic uncertainty:

$$ $\displaystyle\text{Epistemic Uncertainty}=\mathbb{E}_{M\sim P(M|x)}\mathbb{E}_ {M^{\prime}\sim P(M^{\prime}|x)}\left[\|\mathbb{E}_{P(a|M,x)}[e(a)]-\mathbb{E} _{P(a^{\prime}|M^{\prime},x)}[e(a^{\prime})]\|^{2})\right].$ (5) $$

### 3.2 Quantifying FEU with LoRA MoE Framework

We quantify the functional-level epistemic uncertainty (FEU) with the MoE architecture, which is represented by the embedding $e(a)$ in Eq. (5). As shown in Figure 1, the LoRA experts $B_{1...N}A_{1...N}$ capture important functional relationships in the data during fine-tuning.
We treat these functions represented by the LoRA experts as basis functions.
Conditional on the input prompts, the more complex functional relationships that recursively map inputs to outputs are represented as linear combinations (mixture of experts) of the basis functions.
Uncertainty quantification in this functional space reduces to quantifying the uncertainty of the weights over the basis functions.
In particular, the weights $w_{1...N}|h$ from the top-k router dynamically selects these basis functions conditioned on the input hidden state $h$. The top-k weights that produce the final output hidden state quantify the functional level epistemic uncertainty in the function selection.

In this mixture of LoRA experts architecture, we follow the routing mechanisms of the MoE layers as in Eq. (2) and (3).
Specifically, we employ top-2 gate routers, which chooses the $2$ experts with highest probability given a hidden state $\mathbf{h}_{i}^{\ell}$:

$$ $R^{\ell}(\mathbf{h}^{\ell}_{i})=\text{KeepTop-2}(\text{Softmax}(\mathbf{W}^{ \ell}_{r}\cdot\mathbf{h}_{i}^{\ell})).$ (6) $$

Given an input prompt $x$ with length $s$, we model functional-level epistemic uncertainty (FEU) by aggregating $R^{\ell}(\mathbf{h}^{\ell}_{i})$ over both layer dimension and sequence dimension:

$$ $\text{FEU}(x)=\frac{1}{s}\sum^{s}_{i=1}\left[\frac{1}{L}\sum^{L}_{\ell=1}R^{ \ell}(\mathbf{h}^{\ell}_{i})\right]$ (7) $$

### 3.3 Training Calibration Loss

We then calibrate the FEU model of the epistemic uncertainty against predictive accuracy.
Specifically for the MoE top-k routers, we design the following calibration loss for training:

$$ $\mathcal{L}_{\mathrm{cal}}=\left\|\mathbbm{1}{\{\text{MixLoRA}(x)=y^{*}\}}- \text{FEU}(x)\right\|^{2},$ (8) $$

where the first term is an indicator function of whether the model prediction matches the ground truth $y^{*}$ given the prompt $x$.
As shown in Figure 1, this term effectively promotes expert exploitation for correct predictions and expert exploration for incorrect predictions by directly calibrating the functional level epistemic uncertainty to align with the predictive correctness. Therefore, this calibrated training loss ensures that the router’s certainty aligns more closely with the actual confidence the model should have given the available data and its knowledge state. Thus, it effectively calibrates the router’s decisions in line with epistemic uncertainty.

Load balancing is a common technique to ensure even exploitation across experts with the MoE architecture (Fedus et al., ).
We follow the load balancing loss $\mathcal{L}_{b}$ proposed by (Li et al., ) and define our loss function as:

$$ $\mathcal{L}=\mathbf{CE}+\alpha\cdot\mathcal{L}_{b}+\beta\cdot\mathcal{L}_{ \mathrm{cal}},$ (9) $$

where $\mathbf{CE}$ represents cross entropy loss, $\alpha$ and $\beta$ are the hyperparameters of two auxiliary terms.

## 4 Related Work

### 4.1 Parameter-Efficient Fine Tuning for LLMs

Large Language Models (Brown et al., ; Chowdhery et al., ; Hoffmann et al., ; Touvron et al., , ) have shown impressive abilities in handling various natural language processing tasks. Building on these advances, instruction fine-tuning(Chung et al., ; Iyer et al., ; Zheng et al., ) has enhanced LLMs’ capacity to comprehend and follow human instructions, forming the core of modern conversational AI systems(Wu et al., ; Achiam et al., ). However, as LLMs increase in size, the fine-tuning process demands much more time and memory.

To address these challenges, several strategies have been proposed, including parameter-efficient fine-tuning (PEFT)(Mangrulkar et al., ), model distillation(Liu et al., ; Xiao et al., ), quantization(Frantar et al., ; Xiao et al., ), and pruning(Frantar and Alistarh, ; Ma et al., ). Among these, LoRA(Hu et al., ), which leverages low-rank matrix decomposition of linear layer weights, is a widely adopted PEFT technique that boosts model performance without adding computational costs during inference. For example, VeRA(Kopiczko et al., ) introduces learnable scaling vectors to modify shared pairs of frozen random matrices across layers, while FedPara(Hyeon-Woo et al., ) focuses on low-rank Hadamard products for federated learning settings. Tied-Lora(Renduchintala et al., ) applies weight tying to further minimize the number of trainable parameters. AdaLoRA(Zhang et al., ) uses Singular Value Decomposition (SVD) to prune less important singular values for efficient updates, and DoRA(Liu et al., ) separates pre-trained weights into magnitude and direction components, applying LoRA to update the directional component during fine-tuning, thus reducing the number of parameters to be trained.

### 4.2 Mixture of Experts

The Mixture-of-Experts concept(Jacobs et al., ), introduced as early as 1991, presented a novel supervised learning framework where multiple networks (experts) specialize in handling distinct subsets of training data. Modern MoE variants adapt this by modifying the traditional feed-forward sub-layer within transformer blocks, incorporating sparsely activated LoRA experts, which allows for significant expansion in model width without a proportional increase in computational overhead.

Different MoE architectures have since emerged, distinguished by their expert sampling and routing strategies. For example, LLaVA-MoLE(Chen et al., ) improves token routing to domain-specific experts within transformer layers, reducing data conflicts and consistently outperforming standard LoRA baselines. Other MoE-based approaches include MoRAL(Yang et al., ), which focuses on efficiently adapting LLMs to new domains and tasks for lifelong learning, and LoRAMoE(Dou et al., ), which incorporates LoRAs via a router network to mitigate the issue of world knowledge forgetting. PESC(Wu et al., ) transforms dense models into sparse ones through an MoE structure, lowering computational and GPU memory requirements. MoE-LoRA(Luo et al., ) introduces a new parameter-efficient MoE method using Layer-wise Expert Allocation (MoLA) for transformer models, while MoCLE(Gou et al., ) activates task-specific model parameters based on instruction clusters. MixLoRA (Li et al., ) implements a high-throughput framework for LoRA MoE training and inference process, constructing LoRAs as stochastic experts to reduce computational overhead while expanding model capacity.

Despite the performance improvements these architecture advancements have brought, the overconfidence problem of fine-tuned models is lacking attention (Xiao et al., ; He et al., ; Tian et al., ; OpenAI, ). Enhancing the uncertainty estimation capabilities of these models is fundamental toward more reliable, interpretable and trustworthy applications of LLMs.

### 4.3 Uncertainty Quantification in LLMs

Uncertainty quantification has garnered substantial attention in various tasks and domains within neural networks(Gal and Ghahramani, , ; Malinin and Gales, ; Ovadia et al., ; Malinin et al., ; Lin et al., ; Kuhn et al., ; Lin et al., ). This focus extends to LLMs, where the precise quantification of prediction uncertainty has become a critical area of research(Xiao et al., ; Lin et al., ; Mielke et al., ; Chen and Mueller, ; Duan et al., ; Huang et al., ). LLMs, particularly in generative tasks, pose unique challenges, especially when it comes to measuring the uncertainty of their outputs(Liu et al., ; Malinin and Gales, ; Kuhn et al., ; Lin et al., ). The distinction between aleatoric and epistemic uncertainty was recently examined in the context of LLMs(Hou et al., ), though this was approached by ensembling model inputs rather than model instances and did not address fine-tuning tasks specifically.

Existing works have investigated the application of ensembling in fine-tuning LLMs for uncertainty quantification. Gleave and Irving (); Sun et al. () focus on uncertainty estimation in full model fine-tuning, while this approach inherently incurs significant memory overhead. Wang et al. (); Zhai et al. (); Balabanov and Linander () explore the use of LoRA ensembles for uncertainty estimation in LLMs. Yang et al. () applies a post-hoc Laplace approximation Mackay () to model LoRA parameters after fine-tuning. BatchEnsemble(Wen et al., ), introduces component-specific rank-1 matrices as multiplicative modifications to a base model. Though this method has been applied to LLMs, it has been used in the pre-training phase rather than fine-tuning(Tran et al., ). None of these methods provide calibrations on epistemic uncertainty, which is crucial to mitigate overconfidence in the fine-tuning stage given the sparse dataset.

## 5 Experiments

### 5.1 Datasets

We include $5$ multiple-choice question answering benchmarks to evaluate UQ4CT: OpenBookQA (OBQA, Mihaylov et al. ()), ARC-Easy (ARC-E) and ARC-Challenge (ARC-C) from AI2 Reasoning Challenge (Clark et al., ), BOOLQ (Clark et al., ) and ClimateQA, an expert-annotated domain specific benchmark for climate science. We also use computer science, law, medication and engineering subsets from MMLU dataset(Hendrycks et al., ) to evaluate performance under distribution shift. We fine-tune on the publicly available training split and test on the validation split from these benchmarks to evaluate model performance.

**Table 1: Performance comparison of different methods fine-tuned with LlaMA2-7B across $4$ common sense reasoning tasks and a domain-specific task. UQ4CT shows significant ECE improvements while maintaining high accuracy.**
| Metrics | Methods | BoolQ | ARC-E | ARC-C | OBQA | ClimateQA |
| --- | --- | --- | --- | --- | --- | --- |
| ACC $\uparrow$ | LoRA | $69.5_{1.93}$ | $74.8_{1.39}$ | $53.8_{0.6}$ | $72.1_{0.87}$ | $59.9_{2.13}$ |
| MC Drop | $66.8_{3.66}$ | $76.8_{1.30}$ | $50.9_{2.01}$ | $74.8_{1.34}$ | $58.2_{2.11}$ |  |
| Ensemble | $66.2_{3.7}$ | $71.2_{1.0}$ | $47.5_{0.57}$ | $75.5_{1.4}$ | $59.6_{6.9}$ |  |
| LA | $68.7_{1.32}$ | $74.6_{2.11}$ | $51.4_{0.83}$ | $70.8_{1.24}$ | $55.2_{3.29}$ |  |
| MixLoRA | $71.5_{1.05}$ | $77.7_{2.27}$ | $54.3_{1.07}$ | $75.5_{2.91}$ | $61.6_{1.76}$ |  |
|  | UQ4CT | $73.5_{0.52}$ | $76.6_{1.30}$ | $52.8_{1.77}$ | $77.3_{1.36}$ | $63.3_{1.74}$ |
| ECE $\downarrow$ | LoRA | $11.9_{0.78}$ | $11.9_{2.04}$ | $19.4_{4.75}$ | $10.2_{1.07}$ | $14.3_{0.64}$ |
| MC Drop | $12.2_{0.85}$ | $11.9_{1.99}$ | $19.8_{4.85}$ | $10.9_{0.24}$ | $14.3_{0.56}$ |  |
| Ensemble | $7.28_{2.3}$ | $9.1_{1.49}$ | $10.23_{1.39}$ | $8.83_{2.35}$ | $13.5_{3.29}$ |  |
| LA | $17.1_{1.72}$ | $16.6_{3.7}$ | $18.1_{0.5}$ | $17.2_{1.2}$ | $12.6_{1.9}$ |  |
| MixLoRA | $7.88_{2.09}$ | $9.09_{0.81}$ | $10.74_{1.07}$ | $12.9_{1.99}$ | $12.5_{1.32}$ |  |
|  | UQ4CT | $\mathbf{2.3_{0.82}}$ | $\mathbf{6.0_{0.2}}$ | $\mathbf{6.1_{1.11}}$ | $\mathbf{5.0_{1.15}}$ | $\mathbf{8.1_{0.52}}$ |

### 5.2 Experiment Setup

We implement UQ4CT with PyTorch (Paszke et al., ), extending the MixLoRA repository in (Li et al., ) and compare the average performance in three random runs and report the mean and standard deviation with following baselines. We use the publicly available LLaMA-2-7B-hf (Touvron et al., ) as our base model. In particular, we apply MixLoRA to query, key, value and output layers, together with the feed-fowrward networks in LLaMA-2-7B-hf (gate layer, down layer and up layer). Details are provided in Appendix A.1

- •
LoRA(Hu et al., ). We use standard LoRA fine-tuning as lower performance bound.
- •
Monte Carlo (MC) Dropout(Gal and Ghahramani, ) keeps dropout on at both training and testing time. By performing multiple forward passes, MC dropout randomly shuts down a portion of model nodes, producing ensemble-alike predictions. To combine LoRA fine-tuning with MC dropout, we apply dropout on the input of the LoRA adapter, following the implementation of Mangrulkar et al. ().
- •
Deep Ensemble(Lakshminarayanan et al., ) averages the predictions from each ensemble member which have been trained with varying random initialization. We combine deep ensemble with LoRA by fine-tuning $3$ randomly initialized LoRAs together and ensembling their output as final predictions.
- •
Laplace-LoRA (LA)(Yang et al., ) applies a post-hoc Laplace approximation on fine-tuned LoRA parameters for better uncertainty estimation.
- •
MixLoRA(Li et al., ) incorporates LoRAs via a router network to reduce computational overhead while expanding model capacity. We add this as a baseline to resemble plain LoRA MoE model performance.

##### Evaluation Metrics.

We measure the prediction accuracy on the validation set for all $5$ tasks. For uncertainty calibration, we incorporate expected calibration error (ECE, Guo et al. ()) with bin size of $15$, which measures the alignment between predicted probabilities and empirical accuracy. We also investigate model performance under distribution shift to ensure the model has predictable behavior when given data from other domains as this is a crucial component for real-world applications. Specifically, we test models fine-tuned on OBQA dataset with $4$ domain-specific MMLU subtask ensembles focusing on different professionalities and ARC-E/C datasets to approximate larger and smaller distribution shifts. Metric details are provided in Appendix A.2.

### 5.3 Results

We assess the prediction accuracy and uncertainty calibration of models under both in-distribution and distribution shift scenarios. The in-distribution scenario examines the alignment of the fine-tuned model on the target downstream task, while the distribution shift scenario evaluates the generalizability of the model on novel tasks beyond the fine-tuned domain. These two scenarios combined provides a comprehensive assessment of model robustness in real-world applications where it is essential for the model to excel on its primary task while maintaining the ability to effectively handle unforeseen or out-of-distribution inputs.

**Table 2: Performance comparison of different methods fine-tuned on OBQA dataset with LlaMA2-7B across $2$ smaller distribution shift (DS) tasks and $4$ larger distribution shift tasks. UQ4CT shows significant ECE improvements while maintaining high accuracy.**
|  |  | ID | Smaller DS | Larger DS |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Metrics | Methods | OBQA | ARC-C | ARC-E | CS | Eng | Law | Health |
| ACC $\uparrow$ | LoRA | $72.1_{0.87}$ | $58.6_{1.93}$ | $66.5_{3.38}$ | $35.5_{2.35}$ | $30.8_{1.72}$ | $34.9_{1.41}$ | $39.1_{1.52}$ |
| MC Drop | $74.8_{1.34}$ | $58.7_{2.07}$ | $66.6_{3.30}$ | $36.0_{1.69}$ | $30.3_{2.25}$ | $35.1_{0.86}$ | $39.1_{1.35}$ |  |
| Ensemble | $75.5_{1.4}$ | $57.7_{0.78}$ | $69.1_{0.48}$ | $36.7_{2.18}$ | $30.3_{1.13}$ | $35.3_{1.02}$ | $39.9_{1.89}$ |  |
| LA | $70.8_{1.24}$ | $58.7_{0.58}$ | $67.9_{0.41}$ | $33.7_{1.22}$ | $29.6_{1.32}$ | $35.4_{0.75}$ | $38.5_{1.61}$ |  |
| MixLoRA | $75.5_{2.91}$ | $58.5_{1.44}$ | $69.2_{1.02}$ | $35.2_{2.92}$ | $30.3_{0.98}$ | $35.9_{0.43}$ | $40.6_{1.13}$ |  |
|  | UQ4CT | $77.3_{1.36}$ | $58.8_{1.06}$ | $65.8_{1.31}$ | $36.2_{1.24}$ | $34.1_{2.31}$ | $35.8_{1.01}$ | $40.0_{1.24}$ |
| ECE $\downarrow$ | LoRA | $10.2_{1.07}$ | $16.7_{2.28}$ | $13.3_{2.48}$ | $29.7_{2.69}$ | $32.3_{1.85}$ | $29.2_{3.08}$ | $31.0_{2.13}$ |
| MC Drop | $10.9_{0.24}$ | $16.7_{2.20}$ | $13.2_{2.21}$ | $23.2_{2.32}$ | $31.6_{1.64}$ | $28.0_{2.93}$ | $25.9_{2.27}$ |  |
| Ensemble | $8.83_{2.35}$ | $15.1_{1.09}$ | $11.1_{0.99}$ | $22.4_{1.32}$ | $28.5_{2.13}$ | $29.0_{1.37}$ | $24.5_{0.39}$ |  |
| LA | $17.2_{1.2}$ | $16.2_{0.5}$ | $24.4_{0.42}$ | $28.6_{2.61}$ | $30.5_{1.43}$ | $29.5_{1.83}$ | $30.7_{1.2}$ |  |
| MixLoRA | $12.9_{1.99}$ | $19.0_{1.88}$ | $14.5_{2.57}$ | $26.4_{3.25}$ | $33.7_{1.87}$ | $30.3_{2.27}$ | $28.3_{1.07}$ |  |
|  | UQ4CT | $\mathbf{5.0_{1.15}}$ | $\mathbf{8.9_{3.46}}$ | $\mathbf{6.5_{1.85}}$ | $\mathbf{19.6_{2.90}}$ | $\mathbf{23.1_{1.17}}$ | $\mathbf{25.9_{3.43}}$ | $\mathbf{21.9_{3.49}}$ |

#### 5.3.1 In-distribution Performance

We first evaluate UQ4CT and baseline models fine-tuned on the $4$ common sense reasoning tasks and the climate question answering task under the in-distribution scenario, where models are trained and evaluated on different splits of the same dataset. Note that one of the key advantages of UQ4CT is that uncertainty calibration happens during the fine-tuning stage with little computational overhead, while other UQ methods require repetitive sampling or other post-hoc complexities.

As shown in Table 1, UQ4CT demonstrates notable improvements in uncertainty calibration across a variety of tasks. Across all benchmarks, UQ4CT maintains competitive accuracy (ACC) compared to the baseline methods. For example, on the BoolQ and ClimateQA datasets, UQ4CT achieves accuracy rates of $73.5\%$ and $63.3\%$, respectively. This empirically demonstrates that UQ4CT is capable of maintaining high accuracy with uncertainty calibration, which assures the gain in UQ performance does not compromise accuracy.

The most significant performance improvement is observed in the reduction of Expected Calibration Error (ECE). UQ4CT consistently outperforms other methods, reducing ECE by more than $25\%$ on average across the evaluated benchmarks. Unlike other methods where the ECE performance is worsened on the more challenging ARC-C benchmark, UQ4CT achieves an ECE score of $6.1$, showcasing the effectiveness of the calibration. This improvement is critical in applications where the model’s confidence must align with its predictive accuracy given limited data, particularly in safety-critical and domain-specific tasks.

#### 5.3.2 Performance Under Distribution Shift

Due to the sparse nature of the fine-tuning data, real world deployment of LLMs often requires the model to be robust to out-of-distribution knowledge (Ouyang et al., ; Touvron et al., , ). Therefore, we evaluate the performance of UQ4CT along with other baseline models fine-tuned on the OBQA dataset under smaller and larger distribution shift scenarios. Similar to the dataset setup in (Yang et al., ), we use ARC-C and ARC-E dataset to simulate smaller distribution shift because the ARC dataset has similar domain focus on general science reasoning, but is generally more challenging and covers a broader range of scientific topics than OBQA. For larger distribution shift, we ensemble the domain-specific MMLU subtasks into $4$ benchmarks focusing on different professionalities: Computer Science (CS), Engineering (Eng), Law and Health. These tasks have very broad coverage of the domain task at various knowledge levels ranging from elementary school to professionals. This domain-specificity demonstrates larger distribution shift from OBQA, which is a general common sense reasoning task. Details of the ensemble is provided in Appendix. A.3.

The distribution shift evaluations are provided in Table 2. UQ4CT provides significant improvements in terms of ECE while maintains similar accuracy for both smaller and larger distribution shift scenarios. For smaller distribution shifts, UQ4CT shows comparable ECE performance as the in-distribution scenario. For the more challenging larger distribution shifts, UQ4CT still achieves the best ECE performance among all baseline models. Note that UQ4CT also achieves competitive prediction accuracy across all domain-specific tasks. This empirically shows that our proposed alignment of the functional epistemic uncertainty with predictive correctness improves generalizability and mitigating the overconfidence problem on the fine-tuned model.

### 5.4 Ablation Study

#### 5.4.1 Incremental Weighting on Calibration Term

Due to the random initialization of LoRA experts, the predictions during early fine-tuning stage are likely to be incorrect as the model has little knowledge on the functional relationships regarding the data. Thus, it is intuitive to incrementally increase the weight parameter $\beta$ over the calibration term $\mathcal{L}_{\mathrm{cal}}$ in the training loss for the LoRA experts to learn before calibration. We conduct this study by incrementally increase $\beta$ from 0 0 to $1$ within $50$ gradient steps during the early stage of fine-tuning:

$$ $\beta=\min\left\{1,\frac{\mathrm{current_grad_step}}{50}\right\}.$ (10) $$

We choose $50$ gradient steps from our observation that training loss generally stabilizes after $50$ gradient steps, indicating the LoRA experts have learned some functional relationships from data.

As shown in Table 3, the incremental loss has significantly worse ECE performance across all tasks. This demonstrates the advantage of uncertainty calibration even in the early stage. In the beginning, the lack of functional relationships on the training data in LoRA experts lead to high epistemic uncertainty. Thus, UQ4CT encourages exploration over all LoRA experts while UQ4CT_Incremental lacks it due to the small weighting in the beginning.

**Table 3: Performance comparison of UQ4CT with and without incremental weighting. Incremental weighting has worse ECE performance while maintains similar accuracy.**
| Metrics | Methods | BoolQ | ARC-E | ARC-C | OBQA | ClimateQA |
| --- | --- | --- | --- | --- | --- | --- |
| ACC $\uparrow$ | UQ4CT | $73.5_{0.52}$ | $76.6_{1.30}$ | $52.8_{1.77}$ | $77.3_{1.36}$ | $63.3_{1.74}$ |
|  | UQ4CT_Incremental | $72.0_{0.19}$ | $75.4_{0.81}$ | $54.6_{0.95}$ | $77.6_{0.43}$ | $60.2_{3.17}$ |
| ECE $\downarrow$ | UQ4CT | $\mathbf{2.3_{0.82}}$ | $\mathbf{6.0_{0.2}}$ | $\mathbf{6.1_{1.11}}$ | $\mathbf{5.0_{1.15}}$ | $\mathbf{8.1_{0.52}}$ |
|  | UQ4CT_Incremental | $4.0_{0.16}$ | $9.8_{1.51}$ | $13.8_{2.08}$ | $10.3_{1.73}$ | $12.2_{0.88}$ |

## 6 Discussion & Conclusion

In this work, we propose Functional-Level Uncertainty Quantification for Calibrated Fine-Tuning (UQ4CT), which addresses the overconfidence issues commonly encountered during fine-tuning of large language models. We present a functional perspective on quantifying epistemic uncertainty in LLMs and utilize it for uncertainty-calibrated fine-tuning. By incorporating functional-level epistemic uncertainty quantification with a mixture-of-experts framework, our proposed uncertainty-calibrated training loss effectively addresses the challenge of overconfidence in fine-tuned LLMs by significantly improving uncertainty calibration while maintaining high accuracy. Our evaluations demonstrate that UQ4CT reduces the Expected Calibration Error by more than 25% without compromising accuracy across a variety of downstream tasks, including common-sense and domain-specific reasoning, under in-distribution and out-of-distribution scenarios.

The limitation of UQ4CT lies in its dependency on predictive correctness. For general language modeling tasks such as chat completion, there lacks a clear metric on whether the response is correct or not. This limits the application of UQ4CT as naively token matching is a poor indicator of semantic correctness due to the ambiguous nature of language. For future work, we plan to continue exploring ways to adapt UQ4CT on open-ended problems that lacks a definitive metric.

#### Reproducibility Statement

We share our experimental details in Appendix A.1, and also provide the code and model weights for running experiments in the supplementary materials to reproduce our model performance results.

## Acknowledgement

This work was supported in part by U. S. Army Research Office
under Army-ECASE award W911NF-07-R-0003-03, the U.S. Department Of Energy, Office of Science, IARPA HAYSTAC Program, and NSF Grants #2205093, #2146343, #2134274, CDC-RFA-FT-23-0069, DARPA AIE FoundSci and DARPA YFA.

## Appendix A Appendix

### A.1 Training Details

We train our model with total of $8$ LoRA experts, and select $2$ experts with the highest probability. For each expert, we use $rank=16$ and $alpha=32$. We use batch size of $16$ to train our model. For climate task, we set the learning rate to $5e-4$ and dropout rate to $0.1$ to incorporate the small dataset size. For other tasks, we use $2e-4$ as our learning rate with dropout $0.05$. We use AdamW as our optimizer and a cutoff length of $512$ for prompts during training.

The experimental setup for single LoRA based models is similar with LoRA ranks set to $80$ to accommodate the MoE model size. For the ensemble baseline, we use an ensemble size of $8$ with $rank=16$. For Laplace-LoRA, we follow the Laplace hyperparameters in [this Github Repository](https://github.com/MaximeRobeyns/bayesian_lora).

### A.2 Expected Calibration Error

Expected calibration error (ECE) is a commonly used metric to asses uncertainty quantification performance. ECE measures the alignment between prediction accuracy and model confidence through regrouping the predicted probabilities into $m$ bins. This method then computes the weighted average of the difference between average accuracy and confidence in each bin:

$$ $\displaystyle\text{ECE}=\sum_{m=1}^{M}\frac{|B_{m}|}{N}|\text{acc}(B_{m})- \text{conf}(B_{m})|,$ (11) $$

where $|B_{m}|$ is the number of evaluated datapoints in bin $m$, acc and conf is calculated as following:

$$ $\displaystyle\text{acc}(B_{m})=\frac{1}{|B_{m}|}\sum_{i\in B_{m}}\mathbf{1}( \hat{y}_{i}=y_{i}),$ (12) $$

$$ $\displaystyle\text{conf}(B_{m})=\frac{1}{|B_{m}|}\sum_{i\in B_{m}}P(\hat{y}_{i }).$ (13) $$

### A.3 MMLU Distribution Shift Dataset Composition

- •
Computer Science (CS):
–
College Computer Science
–
Computer Security
–
High School Computer Science
–
Machine Learning
- •
Engineering (Eng):
–
Electrical Engineering
- •
Law:
–
International Law
–
Jurisprudence
–
Professional Law
- •
Health:
–
Anatomy
–
Clinical Knowledge
–
College Medicine
–
Human Aging
–
Nutrition
–
Professional Medicine
–
Virology

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 6
presentation: 3
questions: 1. Since UQ4CT’s calibration relies on binary correctness, how might this approach be adapted for tasks where “correctness” is less definitive, such as open-ended text generation or summarization? 
2. Could the authors elaborate on any experiments or initial explorations in applying UQ4CT to such tasks? 
3. Exploring approaches that rely on alternative correctness signals, such as soft scoring or feedback-based calibration, might broaden the applicability.
soundness: 3
strengths: The paper introduces a novel approach by integrating functional-level epistemic uncertainty directly into the fine-tuning process of LLMs, departing from conventional post hoc calibration. The unique combination of MoE with LoRA enables dynamic, prompt-dependent uncertainty modeling, addressing both parameter efficiency and overconfidence in fine-tuned models. The proposed calibration loss function further aligns model confidence with predictive accuracy, reducing overconfidence in a novel, functional manner.
The paper is validated with comprehensive experiments across multiple benchmarks, supported by baseline comparisons and ablation studies.
The paper is well-structured and accessible, with clear explanations and effective use of visual aids, making complex concepts understandable.
UQ4CT addresses a critical need for reliable uncertainty estimation in high-stakes applications by enhancing calibration and robustness under distribution shifts. This advancement strengthens the foundation for trustworthy AI, especially in domains where reliable predictions are essential despite sparse data.
summary: This paper introduces a novel method called Functional-Level Uncertainty Quantification for Calibrated Fine-Tuning (UQ4CT), aimed at addressing overconfidence in large language models (LLMs) during fine-tuning, especially in scenarios with limited or sparse data. Traditional parameter-efficient fine-tuning (PEFT) approaches often fail to accurately calibrate epistemic (model-related) uncertainty, leading to overly confident predictions. To overcome this, UQ4CT incorporates a Mixture-of-Experts (MoE) framework with LoRA (Low-Rank Adaptation), enabling dynamic, prompt-dependent expert selection that captures and calibrates functional-level uncertainty throughout the fine-tuning process. The paper’s main contributions are:
1. A new approach to quantify epistemic uncertainty at the functional level during fine-tuning, using MoE to dynamically adjust uncertainty based on input.
2. A calibration loss function that aligns uncertainty with predictive correctness, encouraging expert exploration for incorrect predictions and reinforcing correct predictions.
3. Empirical results showing that UQ4CT reduces Expected Calibration Error (ECE) by over 25% across multiple benchmarks while maintaining high accuracy, demonstrating robustness both within distribution and under distribution shifts.
weaknesses: UQ4CT’s calibration loss relies on clear correctness metrics, limiting its applicability to tasks with definitive right or wrong answers. This restricts its use in open-ended tasks, such as generative dialogue or summarization. To broaden applicability, future work could explore calibration methods based on human feedback scores or soft accuracy measures instead of binary correctness.
The use of MoE for dynamic expert selection, while effective, could lead to scalability issues with larger models or multi-task scenarios due to increased computational demands. Optimizing expert selection with pruning or adaptive sparsity methods could help make UQ4CT more efficient and feasible for resource-limited applications.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: Please refer to the weakness part. 
For example: 
1. Can the authors add some theoretical analysis?
2. Can more baseline methods be compared?
soundness: 3
strengths: 1. This paper introduces a unique uncertainty quantification (UQ) method for fine-tuning large language models (LLMs) using a Mixture-of-Experts (MoE) approach
2. In this paper, UQ4CT reportedly achieves a 25% reduction in Expected Calibration Error (ECE) across multiple benchmarks, which is a substantial improvement.
summary: This paper proposes a new approach called Functional-Level Uncertainty Quantification for Calibrated Fine-Tuning (UQ4CT) to calibrate the functional-level epistemic uncertainty via the LoRA MoE architecture.
weaknesses: 1. The novel calibration loss function is mentioned as one of the contributions. However, the paper lacks detailed theoretical analysis to illustrate why this specific design especially the loss is effective for uncertainty calibration.
2. Although the paper compares UQ4CT with other PEFT-based uncertainty quantification techniques, a more comprehensive comparison with non-PEFT-based methods might provide a clearer view of its advantages and limitations. 
3. The whole framework is built on LoRA, and can it be applied to more general settings?
4. There are a lot of hyper-parameters, such as the number of top gate routers (why use 2 in this paper), and N, s, L. How to set them in practice and is there any theoretical insight for these choices?

---

confidence: 3
contribution: 3
initial_rating: 8
presentation: 3
questions: - In Equation (5): What exactly do M’ and a’ refer to? I believe this is not explicitly specified anywhere
- Why did you place the “Related work” section after your methodology? I think it introduces important concepts to the reader who would thus benefit from reading this before your explanations in the “Methodology” section.
- L. 326: I personally think it’s not optimal to call something “significant” that you actually did not formally test with a statistical test. Maybe it’s better to use a formulation like “notable” or “substantial”?
- L 359: Just to be sure, what do you mean by “bin size of 15”? I think it is more common to communicate this in terms of “number of bins (of equal size usually”? 
- L. 447 More of a comment than a question, but I think a sole subsubsection (5.4.1) does not really make sense, probably you should rather just add this subsubheading to the heading of subsection 5.4.
soundness: 3
strengths: The experiments are outlined very clearly and explained and motivated comprehensively. This makes the paper easy to follow and understandable to the reader. The additional experiments (distribution shift and ablation) are well-motivated and contribute to the overall experimental setup.
- The problem tackled in this research is widely known and highly problematic, yet there is no definite and generally applicable solution to it. Hence this work, tackling it effectively for LoRA MoE architectures is an important contribution to the field in general.
- Not only do the authors introduce a method that can substantially improve the model calibration, but it also shows strong model performance in terms of accuracy.
summary: The authors propose a novel calibration method for LLMs that is applicable already during the fine-tuning stage of the model. This is achieved by leveraging the specific nature of the LoRA MoE architecture, using the weights of the Top-K router layers to quantify the functional epistemic uncertainty. The epistemic uncertainty calculated this way is used with the predictive accuracy in a specific loss function (as one part of a triple loss function for the overall loss). The authors claim to reduce ECE substantially while not impairing the predictive performance, but even resulting in better predictive performance and making it more robust to e.g. distribution shift. These findings are backed by two experiments: First, they show ECE decrease across 5 MCQA benchmarks while maintaining better (or at least on par) accuracy compared to the baselines. Second, they use a subset of the benchmarks to create distribution shift scenarios to prove the robustness of their approach.
weaknesses: - The ablation study/studies could be more elaborated, i.e. e.g. examining what the influence of the different terms in the loss is, or how sensitive performance is to the hyperparameters alpha and beta in the loss. I think such examinations are important to understand what’s going on and how brittle such triple losses are.
- The approach is specifically tailored to the nature of the LoRA MoE architecture as it critically depends on leveraging the weights of the Top-K Routing layers of the MoE. While this seems to work pretty well here, one might also consider this a limitation of the approach in general since it is not generally applicable.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 2
questions: 1. In equation (9), what is the term $\mathcal{L}_b$? I don't think this is a good practice to put it in the reference. It should be at least written in the appendix.

2. In table 1 and 2, what is the numeric values in the subscript?
soundness: 3
strengths: The pipeline and method developed in this paper appear well-founded, and the paper is generally well-written.
summary: This paper presents a method for epistemic uncertainty quantification in the context of LoRA fine-tuning, which is also compatible with a mixture-of-experts setup. The authors introduce a specialized training loss, designed to capture the difference between predictive accuracy and functional-level epistemic uncertainty. When applied to the Llama2 model, the proposed method shows improvements across a variety of datasets.
weaknesses: The biggest weakness of this paper is the limited experimental effort. Specifically, the experiments are conducted on only one LLM, and there is very little ablation or other study to investigate the additional properties of this UQ method. While I don’t consider the number of pages a deterministic measure of effort, the brevity of the experimental section does suggest a lack of thoroughness in the design of experiments.

Additionally, beyond the lack of comprehensiveness, the paper offers very little empirical or theoretical insight into why this approach is effective. I also find that the paper lacks depth overall.

Meta-review: This paper aims to improve the issue of overconfidence in fine-tuned LLMs, and proposes the functional-level uncertainty quantification for calibrated fine-tuning (UQ4CT), which captures and calibrates functional-level epistemic uncertainty during the fine-tuning stage via a mixture-of-expert framework. The reviewers have a mixed opinion, and the main concerns (Reviewers ydTf and cPCd) come from the fact that the empirical and theoretical insights on why the method works are not presented with good depth. I somewhat agree with these two reviewers, and therefore recommend the authors revise and resubmit to the next conference.

Decision: Reject