How to Migrate LLM Routing to a Fine-Tuned Decision Model: Outcome Labels, Calibration and Canary
A fine-tuned router is a small model trained on which LLM actually succeeded. RouteLLM and Red Hat show that it can be trained cheaply. Only a shadow test and a canary show whether it should replace the router you have.
To migrate LLM routing to a fine-tuned decision model, train a small scorer on the observed outcomes of sampled requests and calibrate its threshold on held-out traffic. Then prove it in shadow and canary stages before it carries production traffic. The RouteLLM paper and repo show that a router trained on preference data can need less than half the strong-model calls of random routing on some benchmarks. A June 2026 Red Hat experiment shows that fine-tuning a 23-million-parameter encoder can lift routing-tier accuracy from 80.39% to 98.53%, but only on 204 synthetic test examples. Neither result proves that downstream task success holds on your traffic, so the migration succeeds only when cost per successful task falls and quality by task category does not.
This guide covers choosing which LLM answers each request, not choosing tools or teams
A router of this kind receives one request and a list of LLMs that could answer it, and it picks one. The decision has two inputs. The first is the request and its state, such as the conversation so far. The second is the set of eligible model options. The output is one model, or a calibrated probability of success for each model.
This is a different task from replacing an LLM that selects a tool, an action or a support team. Some decision models were built for that second task, which is ranking the next action from a list of allowed actions in front of an assistant. The open-source open-jev repository uses ticket routing to billing or shipping teams as its main example. The same training tools can be used for LLM routing, but the labels and the costs are different. In LLM routing, a wrong choice costs either money, if a strong model was not needed, or quality, if a weak model fails.
Deterministic eligibility filters must run before any learned score
A learned score should only choose among models that can actually serve the request. Hard requirements belong in code that runs first, because a scorer can make mistakes while a context-length limit is fixed. Microsoft's documentation for its Foundry model router, dated November 18, 2026, follows the same order. It removes models that lack support for function tools, JSON schema output or image input before any ranking happens.
The filter should remove a model when any of these conditions holds:
- The request carries an input modality, such as images or audio, that the model does not accept.
- The prompt plus the expected output exceeds the model's context limit.
- The request needs tool calls or structured output that the model does not support.
- A deployment constraint, such as region, data residency or an approved-model list, rules the model out.
If one model remains, no scorer is needed. If none remains, the request goes to the existing router or fails with a clear error. Microsoft's router also sets the effective context window to the smallest one among the models that it can route to, which is a useful warning for any pool that mixes short-context and long-context models.
Training labels must come from observed outcomes, not from the old router's choices
The most tempting training set is the log of which model the current router picked. Training on it teaches the new model to copy the old policy, including its mistakes. The label that matters is whether each candidate model succeeded on the request, at what cost and how quickly.
Each training row should record the request, the model revisions and every sampled candidate output with its assessment. The following schema is a minimal version:
{
"request_id": "string",
"group_id": "customer or conversation id",
"timestamp": "ISO 8601",
"task_category": "string",
"input_tokens": "int",
"eligible_models": ["model id after filters"],
"incumbent_choice": "model id",
"sampled_for_all_candidates": "bool",
"candidates": [
{
"model": "model id",
"model_revision": "provider snapshot id",
"output_ref": "pointer to stored output",
"success": "0 or 1",
"assessor": "human | judge model id",
"rubric_version": "string",
"cost_usd": "float",
"latency_ms": "int"
}
]
}
The label for a request is then the cheapest eligible model that succeeded. When no model succeeded, the label is the strongest eligible model, or the request is kept for evaluation only.
Two sources of bias need direct handling:
- Production logs show outcomes only for the model that was chosen, so the data never shows whether a cheaper model would have worked. The fix is to send a random sample of representative requests through every eligible candidate and score all the outputs.
- A judge model makes errors of its own. The RouteLLM authors labelled about 120,000 samples with a GPT-4 judge for around $700, and they also used about 1,500 MMLU validation questions with known answers. A practical migration should score a few hundred rows by hand as well, and it should measure how often the judge agrees with people before trusting the judge's labels.
The data should then be split by group and by time. Requests from one customer or one conversation should all fall in the same split, so that the test set does not contain near-copies of training examples. The open-jev SDK's build_dataset already splits by group into train, validation, calibration and test sets, and it drops duplicate inputs. A final test set drawn from the most recent weeks of traffic shows whether the router still works when the traffic mix moves.
A small fine-tuned encoder is the first model to try, but it must beat simple baselines
The RouteLLM paper, last revised on February 23, 2025, studies this design. Its authors trained routers on about 65,000 Chatbot Arena comparisons. Each router predicts the probability that a strong model's answer beats a weak model's answer, and a threshold turns that probability into a choice. On MT Bench, their matrix factorization router recovered 80% of the quality gap between the two models with 31.31% of calls going to the strong model. A random router needed 78.08%.
The authors also state the limits plainly. Real traffic "may have distributions that differ substantially from these benchmarks," and the study covers only two-model routing. Their larger BERT and causal-LLM routers performed near random when trained on Arena data alone, which they attribute to too little data.
Red Hat's experiment, published June 2, 2026 by Christopher Nuland, tested a compact encoder. The team fine-tuned all-MiniLM-L6-v2, an Apache-2.0 sentence encoder, to sort requests into four tiers for the vLLM Semantic Router. Training took under two hours on a CPU. Accuracy rose from 80.39% to 98.53% on a held-out set. That set held 204 examples that were generated from 48 handwritten seeds, and the article reports no production traffic, no latency and no calibration figures. It shows that the training method works, not what a production router will achieve.
A runnable path with a pinned, licensed encoder looks like this with the MIT-licensed open-jev SDK. Its --method encoder option fine-tunes any Hugging Face encoder with a head for each candidate, and the result can be served on CPU:
from openjev.tod import Candidate, DecisionSpec, Episode, Kind, build_dataset
MODELS = {"gpt-6-luna": "lower-cost model", "gpt-6-sol": "stronger model"}
def options(state):
return [Candidate(k, v, payload=k)
for k, v in MODELS.items() if k in state["eligible"]]
spec = DecisionSpec("llm_routing", [Kind(
"model", "Which is the cheapest model that will succeed?",
options, version="1")])
episodes = [Episode(r["request_id"], (spec.decision(
r["request_id"], "model",
{"message": r["text"], "eligible": r["eligible"]},
choice=r["label"]),)) for r in rows]
build_dataset(spec, episodes).write("runs/llm-routing")
openjev tod train runs/llm-routing --method encoder \
--model answerdotai/ModernBERT-base --out runs/router-v1
openjev tod evaluate runs/router-v1 runs/llm-routing
ModernBERT-base is Apache 2.0 and reads up to 8,192 tokens, while all-MiniLM-L6-v2 truncates input at 256 word pieces. That difference matters for long prompts. The open-jev README pins no library versions, so the lockfile should pin openjev-sdk, PyTorch and transformers, and the run should record the encoder's Hugging Face revision. Red Hat's article gives a model for this record: sentence-transformers 5.4.1, PyTorch 2.11.0, transformers 5.6.2, datasets 4.8.4 and scikit-learn 1.8.0.
The same SDK can instead fine-tune TOD with --method tod, which trains LoRA adapters on Gemma 4 12B and needs an NVIDIA GPU with at least 40 GB of memory. Parsec offers TOD as a hosted decision model at $0.30 per 1,000 decisions, a fee that is charged on top of the cost of the LLMs being routed. Parsec's own repo measurement gives a median of 542 ms for up to 16 options on an A100-40G at batch size 1, and no independent re-run of that figure has been published. On its TOD page, Parsec also reports that the tuned model scored below its untuned base on the public JevBench set. Parsec has published no result for LLM routing migration, so TOD here is a candidate to test, not a measured improvement.
Every candidate must be compared against the same five baselines on the same test set:
- Keeping the incumbent router unchanged shows what the migration must beat.
- Applying simple rules, such as sending long or tool-heavy requests to the strong model, shows how much a model adds over code.
- Running RouteLLM, where the problem is a choice between two models, gives a published and maintained reference.
- Scoring with an untuned scorer, such as the base encoder before fine-tuning, shows whether fine-tuning helps at all.
- Sending every request to the strong model, or always-strong routing, sets the quality ceiling and the cost ceiling.
A fine-tuned or larger model is worth adopting only if it beats all five on the acceptance criteria.
Calibration and cost per successful task decide the threshold, not routing accuracy
Routing accuracy measures agreement with labels. It does not measure whether users got correct answers. A router can match 98% of labels and still lose quality if its rare errors fall on the hardest requests. The evaluation should therefore report five things before anyone claims an improvement:
- A calibration curve shows whether a predicted 0.8 chance of success means 80% observed success. The open-jev evaluation reports 10-bin expected calibration error, and it fits a temperature on the calibration split.
- A quality-versus-cost frontier shows task success at each threshold, which is how RouteLLM's
calibrate_thresholdcommand sets its operating point. - Quality by task category reveals categories that lose quality while the average holds.
- p95 latency, measured on the serving hardware, shows the delay that the router adds in the worst cases.
- Cost per successful task is total cost divided by the number of tasks that succeeded.
Total cost must include the routed LLM calls, router inference, any embedding calls, fallback calls, router hosting and the training cost spread over the router's expected life. Latency measured on a compact encoder must never be used as an estimate for a 12B adapter. In the RouteLLM paper, the authors report throughput of 155 requests per second for their matrix factorization router on one L4 GPU. That figure applies to a very small model and cannot be used for a Gemma-based scorer.
On list prices, the router itself is cheap and the routed calls dominate. At 1,000 input and 300 output tokens per request, OpenAI's pricing page puts a gpt-6-sol call at $0.005 and a gpt-6-luna call at $0.00025. For one million requests a month, all-strong routing costs $5,000. A router that sends 30% of requests to the strong model, close to RouteLLM's MT Bench result, costs $1,675 in LLM calls. One L4 VM running all month at the $0.80 hourly rate in the RouteLLM paper adds $576. That VM is far larger than this load needs, because the paper measured 155 requests per second on it, so an encoder served on CPU could cost less. Labelling 5,000 sampled requests on both models costs about $26, and judging them with gpt-6-sol costs about $21. Whether a 30% strong share keeps quality on any real workload has not been measured.
The new router must keep the old interface and fall back within a fixed time budget
The safest adapter changes nothing for the caller. It takes the same request, returns the same model identifier and falls back to the incumbent router whenever the scorer is slow, fails or receives a request that it cannot handle:
from concurrent.futures import ThreadPoolExecutor
POOL = ThreadPoolExecutor(max_workers=8)
VERSION = "router-v1+cal-v1" # model and calibrator artifact ids
def eligible(request, catalog):
ok = [m for m in catalog
if request.modalities <= m.modalities
and request.total_tokens <= m.context_limit
and (not request.needs_tools or m.supports_tools)
and request.region in m.regions and m.available]
return sorted(ok, key=lambda m: m.cost_for(request))
def route(request, catalog, scorer, incumbent, target, budget_s):
options = eligible(request, catalog) # cheapest first
if not options:
return incumbent(request), "no_eligible_model"
if len(options) == 1:
return options[0], "single_option"
job = POOL.submit(scorer, request, options)
try:
p_success = job.result(timeout=budget_s)
except Exception: # timeout, scorer error, bad input
return incumbent(request), "fallback"
for model, p in zip(options, p_success):
if p >= target:
return model, VERSION
return options[-1], VERSION
The target value and budget_s are workload choices, not service guarantees. They should come from the frontier and the p95 latency measured in evaluation. Every response should log the returned reason or version, so that fallback rates and calibrator versions can be traced later. The model weights and the fitted calibrator should be stored as one versioned artifact, because a calibrator fitted to one model is wrong for the next.
A shadow stage and a small canary with a rollback come before full traffic
A shadow stage runs the new router on live traffic and logs its choice without acting on it. The incumbent still serves every request. Shadow logs show agreement rates, fallback rates and latency, and a sampled slice can be sent through the new router's choice to measure task success.
The rollout should follow these steps:
- Write the acceptance criteria before the shadow stage starts. One example is no drop in task success larger than one point in any major category, a lower cost per successful task and a p95 routing delay below a set budget. The exact limits are choices for each workload.
- Run the router in shadow for long enough to cover the normal weekly mix of traffic.
- Send a small canary, such as 1% to 5% of traffic, through the new router, with sticky assignment per user or conversation.
- Keep a one-switch rollback to the incumbent router, and roll back automatically when a criterion is breached.
- Expand traffic in steps only after each step meets the same criteria.
The router must be re-tested whenever traffic or the candidate models change
A trained router is fitted to one set of models and one traffic mix. When a provider updates a model snapshot, adds a model or retires one, the labels that the router learned may no longer hold. Microsoft's documentation shows how often this happens in a managed pool. As of November 18, 2026, its router pool held 45 models, and deployments on the full pool receive new models automatically.
RouteLLM's authors found that their routers kept much of their benefit when the model pair was swapped, needing about half the strong calls of a random router. That finding is encouraging, but it was measured on benchmarks, and it does not remove the need to re-test. A practical policy re-runs the held-out evaluation whenever a candidate model changes, re-samples outcome labels on a schedule and watches the share of requests that the scorer marks as low confidence. A rising share of low-confidence or fallback requests is the clearest early sign of out-of-distribution traffic. An outage of a candidate model should remove it in the eligibility filter, so that the scorer never chooses an unavailable model.
Teams that publish an improvement should release the permitted evaluation examples, the scripts and the measured conditions, including hardware, model revisions and dates. They should also keep the reported findings of RouteLLM and Red Hat separate from their own results, because benchmark results and synthetic test results do not carry over to a production workload.
Sources
- RouteLLM: Learning to Route LLMs with Preference Data (arXiv 2406.18665): https://arxiv.org/abs/2406.18665
- RouteLLM paper, HTML version v4: https://arxiv.org/html/2406.18665v4
- lm-sys/RouteLLM repository: https://github.com/lm-sys/RouteLLM
- Red Hat Developer, Improve vLLM Semantic Router accuracy with fine-tuning: https://developers.redhat.com/articles/2026/06/02/improve-vllm-semantic-router-accuracy-fine-tuning
- Microsoft Learn, How model router works in Microsoft Foundry: https://learn.microsoft.com/en-us/azure/foundry/openai/concepts/model-router-how-it-works
- Hugging Face, sentence-transformers/all-MiniLM-L6-v2: https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
- Hugging Face, answerdotai/ModernBERT-base: https://huggingface.co/answerdotai/ModernBERT-base
- open-jev repository: https://github.com/daseinlabs/open-jev
- open-jev TOD SDK documentation: https://github.com/daseinlabs/open-jev/blob/main/docs/tod-sdk.md
- TOD repository: https://github.com/daseinlabs/tod
- Parsec, TOD: https://parseclab.ai/tod/
- OpenAI API pricing: https://developers.openai.com/api/docs/pricing