Training Router Models
Semantic Router uses small, task-specific models to understand a request before it chooses a generative model. These router-owned models are different from the LLMs in the provider pool: they classify, embed, score, or verify a request; they do not produce the final answer.
This page helps you choose the right training workflow and explains what a reproducible result should contain. Each workflow has its own README beside the training code for exact commands and input formats.
Choose a workflow
| Goal | Training area | Typical output |
|---|---|---|
| Classify domain, intent, feedback, modality, PII, or jailbreak risk | model_classifier | A classifier or LoRA adapter used by a signal |
| Adapt embeddings for cache or retrieval | model_embeddings | An embedding model and evaluation report |
| Learn which provider model should answer a request | model_selection | KNN, KMeans, SVM, MLP, or reinforcement-learning selector artifacts |
| Compare provider models or produce routing scores | model_eval | Per-model and per-category evaluation data |
| Explore research ideas that are not part of the supported runtime contract | model_experiment | Experimental code and local artifacts |
If your goal is to route among several generative models, start with ML-Based Model Selection. If you need to measure the models in an existing pool, start with Model Performance Evaluation.
The training lifecycle
1. Define the routing decision
Write down what the model must distinguish and how its output changes routing. For example, a domain classifier may choose a decision, while a PII signal may trigger a policy rule. A label is useful only when it maps to an observable router behavior.
Decide before training:
- the label or score contract
- the languages and request types in scope
- acceptable false-positive and false-negative costs
- the latency and memory budget for online inference
- what happens when the model is unavailable or uncertain