Laya Model Routing — 1000 rows @ 12 epochs (best calibrated, production pick)
Laya (421M) fine-tuned to classify a user query into one of six model-routing classes, so an application can pick the right class of free OpenRouter models (single forward pass, ~37 ms on T4):
| class | meaning |
|---|---|
fast_cheap |
greetings, basic lookups, formatting |
general_mid |
everyday reasoning, most chat/Q&A |
top_reasoning |
hard multi-step reasoning, math, planning |
code_specialist |
writing, debugging, reviewing code |
security_specialist |
vulnerabilities, secure coding, privacy, auth |
long_context |
long documents / many turns |
Results (held-out set: 100 disjoint queries, judge-labeled)
Full series on the same eval set (e12 rows measured on Kaggle T4/FP16):
| train rows | epochs | model | choice_accuracy | ECE ↓ |
|---|---|---|---|---|
| 0 | — | base Laya (zero-shot) | 0.630 | 0.169 |
| 200 | 12 | laya-model-routing | 0.820 | 0.125 |
| 500 | 8 | laya-model-routing-500 | 0.910 | 0.074 |
| 1000 | 6 | laya-model-routing-1000 | 0.870 | 0.087 |
| 500 | 12 | laya-model-routing-500e12 | 0.910 | 0.062 |
| 1000 | 12 | this checkpoint | 0.900 | 0.028 |
Majority-class baseline: 0.270 · random: 0.167.
Why this checkpoint: the original 1000-row run (0.870 @ 6 epochs) was
under-trained by the auto-epoch rule, not limited by its data — rerunning at
12 epochs recovered it to 0.900 accuracy with the best calibration of the
series (ECE 0.028) and a cleanly in-range temperature (4.31, no clamping).
Accuracy is within eval noise of the 500-row models (±1 row); the decisive
edge is trustworthy confidence, which is what a min_confidence routing gate
consumes. First model in the series to ever predict top_reasoning at all.
Per-class recall: security_specialist 1.000 · fast_cheap 0.926 ·
general_mid 0.920 · code_specialist 0.909 · long_context 0.667 ·
top_reasoning 0.000 (6 training rows — first in series to receive a
top_reasoning prediction, a false positive).
Training
- Data: 1000 queries from ai-mitra/llm-router-dataset (shuffled seed 42, rows 300–1299), labeled by glm-5.3 as judge via Z.AI
- Recipe: RLCD (policy gradient + proper scoring rule + cross-entropy),
DDP on 2× T4, 12 epochs (
EPOCHS_OVERRIDE=12), temperature calibration on a holdout slice (fitted choice T = 4.31) - Full pipeline and experiment log: github.com/lunakicks/laya-model-routing
Usage
import laya
agent = laya.load("thechristyjo/laya-model-routing-1000e12", device="cpu")
questions = {
"model_class": {
"type": "choice",
"instructions": "Which model class should handle this task?",
"criteria": {
"fast_cheap": "simple, short, low-stakes queries",
"general_mid": "everyday reasoning, most chat/Q&A",
"top_reasoning": "hard multi-step reasoning, math, planning",
"code_specialist": "writing, debugging, reviewing code",
"security_specialist": "security, privacy, auth tasks",
"long_context": "long documents or many turns",
},
}
}
print(agent.predict("Write a function to detect a linked-list cycle.", questions)
["answers"]["model_class"]["choice"])
Limitations
top_reasoninghas 6 training rows — recall 0.000; needs targeted augmentationlong_contextrecall 0.667 — trained on short one-liners about summarization, not actual long inputs- Accuracy statistically tied with the 500-row checkpoints (±1 row on this eval set)
- English-only; judge labels carry the judge's "cheapest competent class" policy