RACER: Risk-Aware Calibrated Efficient Routing for Large Language Models
Authors: Sai Hao, Hao Zeng, Hongxin Wei, Bingyi Jing
Organizations: Southern University of Science and Technology, China · The Chinese University of Hong Kong, Shenzhen, China · Shenzhen Loop Area Institute, China
Efficiently routing queries to the optimal large language model (LLM) is crucial for optimizing the cost-performance trade-off in multi-model systems. However, most existing routers rely on single-model selection, making them susceptible to misrouting. In this work, we formulate LLM routing as the α-VOR problem to minimize expected set size while controlling the misrouting risk, and propose a novel method -- RACER, extending base routers to output model sets that can be subsequently aggregated for improved output. In particular, RACER constructs nested model sets via augmented scoring and utilizes finite-sample concentration bounds to calibrate a threshold that allows for both variable set sizes and abstention. We theoretically prove that RACER achieves rigorous distribution-free risk control on unseen test data in a post-hoc and model-agnostic manner. Extensive experiments verify our theoretical guarantees and demonstrate that RACER consistently enhances downstream accuracy across a wide range of benchmarks.
Figures & tables
Figure 1: Overview of the RACER paradigm. RACER operates in two phases. Risk Calibration (Left): The calibration module uses a labeled dataset Dcal and a user-specified risk level α . It augments the standard model space M with a null model m∅ to construct augmented ground truth set G′ . The threshold λ^ is then computed to guarantee risk control. Model Routing (Right): During inference, the paradigm applies the calibrated λ^ to the augmented scores of a test query x . This generates a prediction set Cλ^(x) . If the set contains only the null model, the system triggers abstention; otherwise, it proceeds to Response Aggregation , where the outputs of the selected standard LLMs are combined via majority voting or weighted aggregation to produce the final prediction y^ .
Figure 2: Distributions of risk and size for RACER on CMMLU over 100 independent trials with a target risk level α=0.1 . Left : The distribution of risk , where the black dashed line represents the user-specified risk level. Results demonstrate that RACER consistently maintains the risk below the target α for all base routers and non-conformity scores. Right : The distribution of prediction set size . The green and orange boxes represent the router score-gap and inverse irobability non-conformity scores, respectively.
Method
GSM8K
MMLU
C-MMLU
ARC-C
Average
Candidate Models
Chinese-Mistral-7B-v0.1
42.7 ± 1.4
57.5 ± 0.8
49.1 ± 1.0
45.3 ± 2.4
48.7
Dolphin-2.6-Mistral-7b
54.7 ± 1.5
60.7 ± 0.8
44.2 ± 0.9
53.7 ± 2.1
53.3
Dolphin-2.9-Llama3-8b
75.0 ± 1.2
59.6 ± 0.8
43.9 ± 0.9
49.8 ± 2.2
57.1
Meta-Llama-3-8B
47.1 ± 1.5
64.6 ± 0.8
51.2 ± 0.9
50.5 ± 2.2
53.4
MetaMath-Mistral-7B
75.1 ± 1.2
59.9 ± 0.8
44.4 ± 1.0
48.7 ± 2.3
57.0
Table 1: Performance comparison on diverse benchmarks. We report the mean and standard deviation ( ± std) of accuracy across 100 independent trials . The “Average” column represents the average accuracy across all four benchmarks. “Base” refers to the base routers, while “+ RACER” indicates our proposed paradigm with aggregation (w/ Agg.). RACER-G and RACER-P denote two RACER variants with different non-conformity score definitions, based on the router score-gap and inverse irobability , respectively. The best results in each column are bolded , and the second best are underlined .
Figure 3: Trade-off between computational efficiency and performance. The scatter plot illustrates the reduction in inference overhead (Model Calls Saved) versus the absolute improvement in test accuracy (Accuracy Gain) for RACER relative to the full model ensemble. The concentration of data points in the upper-right region indicates that RACER effectively filters noise to achieve significant savings (up to 58.6%) while simultaneously improving accuracy (up to +4.49%) across various dataset-router configurations.
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 4: The prompt template used for extracting model confidence. The placeholders {question} and {answer} are replaced by the input query xn+1 and the model’s generated response am , respectively.
Figure 5: Distributions of empirical Risk and Size over 100 independent trials with a target risk level α=0.1 . The top row displays the risk distribution, where the vertical black dashed line indicates the target risk level α . The bottom row illustrates the distribution of prediction set sizes. The green bars represent the router score-gap non-conformity score, while the orange bars represent the inverse probability non-conformity score. The results empirically demonstrate that RACER strictly controls the risk around the target level across different base routers and benchmarks.
Figure 6: Heatmap of optimal hyperparameters selected on the validation set. The figure displays the grid-search results for the target risk level α (indicated by the cell value and color intensity) and the aggregation method (text annotation) that achieved the highest accuracy on the validation set. The left panel shows configurations for RACER-G (router score-gap), and the right panel for RACER-P (inverse probability). These optimal configurations were applied to the test set to produce the main results in Table 1 .
Figure 7: Performance evaluation of RACER versus full model aggregation. The figure presents the comparison of RACER-G/P (w/ Agg.) against the full model aggregation baseline across varying dataset-router pairs. RACER-P demonstrates superior performance in 10/12 cases, and RACER-G in 8/12 cases, thereby confirming that effectively filtering noisy models leads to more robust predictions than simply aggregating all available models.
Dataset
Method
α
0.01
0.05
0.10
0.15
0.20
0.30
0.40
0.50
GSM8K
KNNR+RACER-G
0.010
0.048
0.098
0.147
0.197
0.297
0.394
0.495
KNNR+RACER-P
0.009
0.048
0.098
0.147
0.196
0.296
0.395
0.495
MLPR+RACER-G
0.010
0.048
0.096
0.145
0.195
0.297
0.396
0.497
MLPR+RACER-P
0.010
0.048
0.096
0.145
0.195
0.296
0.396
0.497
RouterDC+RACER-G
0.009
0.048
0.099
0.146
0.195
0.296
0.394
0.493
Appendix
Table 2: Risk across varying target risk levels ( α ). We report the empirical risk achieved by different RACER configurations (combining three base routers with two non-conformity scores) over 100 independent trials. The results span four benchmarks (GSM8K, MMLU, CMMLU, ARC-Challenge) and a range of user-specified risk level α∈[0.01,0.50] . The close alignment between the risk (values in the table) and the target α (column headers) confirms the validity of the RACER calibration procedure across a wide range of risk levels.
Figure 8: Evolution of average selected model set size with respect to the target risk level α . The plots display the mean set size computed over 100 independent trials across four diverse benchmarks (GSM8K, MMLU, CMMLU, and ARC-Challenge) as the user-specified risk level varies within the range α∈[0.01,0.3] . Different colors distinguish the base routers: Blue for KNNR, Orange for MLPR, and Green for RouterDC. Line styles differentiate the non-conformity scores: solid lines correspond to RACER-G (router score-gap) and dashed lines to RACER-P (inverse probability). Shaded regions indicate the standard deviation. The plots illustrate a monotonic trade-off where higher risk allows for more compact prediction sets, with RouterDC consistently demonstrating superior efficiency (smallest sizes) across a wide range of risk levels.
Large language models (LLMs) achieve impressive performance across multiple domains, but using the most capable model for every query is prohibitive at scale. LLM routing exploits diversity in model capability and cost by assigning each query to a suitable model to balance utility and budget. Current methods have two limitations: (i) they either use heuristics that do not always enforce the budget constraint or impose a fixed per-query budget that cannot adapt across the workload and leads to suboptimal performance; (ii) they require supervised learning on a dense dataset with statistics for every query-model pair, which is expensive to collect. To address these challenges, we formulate LLM routing as a constrained contextual multi-armed bandit problem and introduce WISERouter (WR for short), a framework that supports offline learning from historical interactions as well as online learning with exploration. We further prove that WR-Online achieves a sublinear regret bound of O(T) over a time horizon T. Empirical results on RouterBench and SWE-Bench demonstrate that (i) WR-Offline surpasses existing baselines in performance under a fixed budget and adheres more closely to budget constraints, and (ii) WR-Online achieves comparable performance to the baselines, while using substantially less exploration data.
No single large language model (LLM) is optimal across all queries and budget constraints, making model routing essential for cost-effective deployment. Existing routers adopt diverse formulations and implementations, making fair comparison and extension difficult. We present a unified formulation of LLM routing as a sequential decision process characterized by five components: context encoders, model encoders, scoring functions, decision rules, and learning signals, covering single-turn, multi-turn, and personalized routing. Based on this formulation, we develop an automated pipeline for constructing routing supervision and evaluating routers jointly on response quality and inference cost. The resulting benchmark, xRouteBench, spans generic LLM, memory-augmented, vision, time-series, and personalized routing tasks. We further introduce LLMRouter, an open-source modular infrastructure with more than 16 representative routers. Our empirical study shows that learned routers outperform the strongest fixed-model baseline by 14.6% relatively, lightweight routers become more competitive under tight cost constraints, and user-conditioned routing consistently improves personalization.
Tao Feng, Fangxu Yu, Haozhen Zhang +9
University of Illinois Urbana-Champaign · University of Maryland, College Park · 3Nanyang Technological University +2
Large language models are increasingly used in practical systems, making efficient model selection important for reducing deployment cost. LLM routing has emerged as a practical solution for allocating each input query to an appropriate model under a desired cost-performance trade-off. Existing routing methods often estimate model suitability from the surface semantics or embedding similarity of the input query. However, such methods may ignore the underlying difficulty of a query, leading to suboptimal routing decisions. To address the challenge, we propose VDAR-Router, a difficulty-aware retrieval-based routing framework. For each input query, VDAR-Router first generates an explicit difficulty analysis. It then retrieves historical examples with similar difficulty profiles. Based on the retrieved records, it estimates candidate model suitability and selects the model using a reward function that considers both performance and cost. Experiments on three datasets show that VDAR-Router consistently achieves better cost-performance trade-offs than existing baselines. These results demonstrate the effectiveness of difficulty-aware retrieval for training-free LLM routing. Case studies further show that explicit query analysis helps retrieve more relevant examples and supports more reliable routing decisions.
Yu-Chien Tang, Jun-Chen Hung, Wen-Chih Peng +1
National Yang Ming Chiao Tung University · Department of Computer Science Hsinchu, Taiwan