WorksMathematics
Congestion-Aware Adaptive Routing for LLM Classification
Abstract
Organizations use large language models (LLMs) to classify jobs that differ in uncertainty and the cost of errors. Querying additional models may improve accuracy, but it also incurs fees and increases congestion at shared servers. We study congestion-aware adaptive routing (CAAR) policies that adapt model selection and stopping decisions to observed outputs while accounting for the steady-state congestion they generate. The objective is to minimize the long-run average cost of misclassification penalties, query fees, and holding costs. We can represent CAAR policies as a mixture of decision trees, and derive exact holding costs for first-come-first-served servers with exponential service times and processor-sharing servers with general service times. We formulate a convex optimization problem with unique optimal model loads. Congestion prices capture the marginal system-wide holding costs of additional queries and guide routing and stopping decisions through a Bayesian dynamic program. We characterize optimal stopping decisions and identify models whose information does not justify their cost. A column-generation algorithm computes optimal CAAR policies and provides an explicit optimality-gap bound. We also bound the additional cost of limiting cascade depth relative to full-depth CAAR. Finally, under a common query-depth limit, cascades with a predetermined model order can be arbitrarily more costly than optimal CAAR, even when the order is randomized and stopping decisions adapt to observed outputs. Numerical experiments distinguish the benefits of adaptive model selection and congestion-aware design.