Skip to content

Tutorials

This section is a hands-on companion to the Jupyter notebooks in the main branch:

The goal is to help you reproduce the notebook workflows and translate them into repeatable CLI runs.

  1. Run (or reuse) data preparation outputs: Data preparation
  2. Pick a router family and train it (if needed): start with KNNRouter
  3. Do route-only inference first, then full inference if you have API access
  4. Batch runs and output schemas: Data formats

Running notebooks locally

Most notebooks assume you cloned the repo (so configs/ and data/ exist).

git clone https://github.com/ulab-uiuc/LLMRouter.git
cd LLMRouter
python -m pip install -U pip
python -m pip install -e .
python -m pip install jupyter

Then open a notebook, for example:

jupyter notebook notebooks/data_preparation/01_data_preparation.ipynb

Tip

If you only want to validate routing decisions (no API calls), use --route-only in the CLI and skip API key setup.

Router comparison (high-level)

This table is a rough guide for choosing a starting point. For exact availability in your environment, run llmrouter list-routers.

Router Type Training GPU Best for
KNNRouter classification yes no simple baseline, fast iteration
SVMRouter classification yes no high-dimensional embeddings
MLPRouter neural network yes no non-linear decision boundary
MFRouter matrix factorization yes no preference-style routing signals
DCRouter transformer router yes recommended stronger accuracy (more compute)
GraphRouter GNN router yes recommended relational patterns / graph structure
CausalLMRouter finetuned LLM yes required complex queries (heavier training)
AutoMixRouter mixing / policy yes no cost-aware routing
HybridLLMRouter hybrid classifier yes no two-stage / binary routing settings
GMTRouter multi-turn / personalized yes recommended personalized multi-turn routing
EloRouter rating-based optional no simple rating baseline
SmallestLLM baseline no no cost-efficiency baseline
LargestLLM baseline no no upper bound baseline
RouterR1 agentic no required complex reasoning (special runtime)
KNNMultiRoundRouter multi-round KNN yes no multi-step queries with training
LLMMultiRoundRouter multi-round LLM no optional zero-shot multi-round (API-driven)

Next

Start with Data preparation.