ZeroRouter's framework consists of three core modules: Latent Parameter Calibration, Lightweight Profiling, and Policy-Driven Routing.
Universal Latent Space for Lightweight Profiling
This module establishes a model-agnostic representation of query difficulty and model ability.
- Model Inference Accuracy Estimation: The interaction between a model u and a prompt i is modeled using a Probabilistic Model, specifically a multidimensional 2-Parameter Logistic (2PL) IRT model. The probability of a correct response Xui = 1 is given by:
P(Xui = 1|θu, ai, bi) = 1 / (1+e-ai (θu-bi))
where θu is the model's ability vector, and ai, bi are the prompt's discrimination and difficulty vectors in a D-dimensional latent space.
- Information-Theoretic Anchor Selection: To efficiently estimate model capabilities with a minimal yet highly informative anchor set A, the task is formalized as an optimal experimental design problem. The objective is to maximize the log-determinant of the Fisher Information Matrix, simplified to rely on prompt discrimination vectors ai:
A* = arg max log det (Σ ai aiT)
ACP, |A|=N
A greedy forward selection algorithm is used to construct set A.
- Lightweight Profiling for New Models: Once the anchor set A is established, the ability θunew of a new model is estimated by minimizing the binary cross-entropy (BCE) loss between ground-truth scores and predicted probabilities for anchor prompts.
Model Inference Cost Estimation
- Total Inference Cost: For API-based LLM services, the total inference cost for routing a query q to a model u is a function of its input and output token lengths:
Cuq = λinlin + λoutlout
where λin and λout are per-token API prices, and lin and lout are input and output token lengths.
- Input Token Estimation: The input token length lin is deterministically obtained using the model-specific tokenizer:
lin = |Tu(q)|
- Output Token Estimation: A novel method leverages the universal latent space to estimate output token length lout. Task-aware difficulty sq is derived from predicted latent IRT parameter vectors:
sq = aqbq
During a one-time calibration, complexity scores are discretized into K bins. For each model u and bin Bk, a mean output token length lout is pre-computed and stored. For an unseen query q', its latent vectors are predicted, its complexity score sq' is computed, and the corresponding bin Bk is identified to retrieve the pre-calibrated average length.
Model Inference Latency Estimation
Latency for each model u is modeled via two pre-calibrated parameters: Time to First Token (TTTFT) and Time per Output Token (POT). The final latency for a query q is predicted by:
Tuq = TTTFT + loutPOT
Context-Aware Latent Space Coordinate Prediction
A lightweight unified predictor bridges a query's textual properties with its multi-dimensional IRT parameter vectors (discrimination vector a and difficulty vector b).
- Hybrid Feature Representation: Queries are encoded into Semantic Embedding (ese) using a fine-tuned DistilBERT model and Structural Features (est) using a function that computes 11 linguistic metrics.
- Unified Prediction Model: A multi-task learning model with a shared backbone learns a high-level representation (hshared) of the query. This is followed by two independent prediction heads:
- Difficulty Head (Residual Prediction): Predicts a residual vector Δbq, which is added to a data-driven mean b to construct the final predicted difficulty vector bq:
bq = b + Δbq = b + fdiff(hshared)
- Discrimination Head (Multi-Head Experts): Partitions the D dimensions into C distinct clusters. For each cluster, a dedicated expert head (fdisc,c, an MLP) predicts the subset of dimensions within its assigned group. The final discrimination vector aq is constructed by concatenating these outputs:
aq = ⨁c=1C aq,c = ⨁c=1C fdisc,c(hshared)
LLM Routing Strategies
- Multi-Objective Optimization: The routing task is formulated as an Integer Linear Programming (ILP) problem that maximizes a weighted utility function, unifying accuracy, cost, and latency. For a set of queries Q and models M, the goal is to determine the optimal assignment Xuq ∈ {0,1} guided by user-specified weights (wp, wc, wt) that sum to 1:
maximize Σu∈M Σq∈Q (wpPuq - wcCuq - wtTuq) · Xuq
subject to the constraint that each query is assigned to exactly one model (Σu∈M Xuq = 1, ∀q∈Q) and optional global constraints on total cost, latency, and average accuracy.