Algorithm
Overview
Latest algorithm tutorials mirror the fragment catalog under config/algorithm/.
Algorithms only matter after a decision matches and exposes multiple candidate models in modelRefs. The router then uses decision.algorithm to choose or coordinate those candidates.
Key Advantages
- Separates route eligibility from model selection policy.
- Lets one decision keep several candidate models without inlining ranking logic.
- Supports both one-model ranking and multi-model orchestration.
- Mirrors the repo fragment tree exactly: one tutorial page per algorithm under
config/algorithm/selection/andconfig/algorithm/looper/.
What Problem Does It Solve?
Once a route matches, the router still needs a principled way to choose among candidate models. Without an algorithm layer, teams either hard-code one winner or duplicate ranking logic across routes.
Algorithms solve that by making the post-match selection policy explicit and reusable.
When to Use
Use algorithm/ when:
modelRefscontains more than one candidate- route policy depends on latency, feedback, semantic fit, or online exploration
- one decision should orchestrate several models instead of choosing exactly one
- you want model choice to evolve without changing the decision rule itself
Configuration
In canonical v0.3 YAML, algorithms live inside each matched decision:
routing:
decisions:
- name: computer-science-reasoning
rules:
operator: AND
conditions:
- type: domain
name: "computer science"
modelRefs:
- model: qwen2.5:7b
- model: qwen3:14b
algorithm:
type: router_dc
router_dc:
temperature: 0.07
The repo now keeps one tutorial page per algorithm.
Algorithm Comparison
Selection Algorithms (single model from candidates)
| Algorithm | Type | Feedback | Personalization | Key Paper | Best For |
|---|---|---|---|---|---|
| Static | Fixed | No | No | — | Simplest possible selection, curated ordering |
| Elo | Feedback-driven | Yes | Per-category | RouteLLM (2406.18665) | Online learning from pairwise comparisons |
| Router DC | Semantic | Yes | No | Dual Contrastive (2409.19886) | Query-to-model semantic matching |
| AutoMix | POMDP | Via logprob | No | AutoMix (2310.12963) | Cost-quality cascaded routing |
| Hybrid | Composite | Yes (3 sub) | No | Hybrid LLM (2404.14618) | Blending multiple ranking signals |
| RL Driven | RL | Yes | Per-user | Router-R1 (2506.09033) | Exploration + personalization |
| GMT Router | GNN | Yes | Per-user | GMTRouter (2511.08590) | Multi-turn personalized routing |
| KNN | ML (Rust) | No (offline) | No | — | Interpretable example-based routing |
| KMeans | ML (Rust) | No (offline) | No | — | Cluster-based routing |
| SVM | ML (Rust) | No (offline) | No | — | Decision boundary classification |
| MLP | ML (GPU) | No (offline) | No | — | Non-linear neural network routing |
| Latency Aware | Metrics | No | No | — | Fastest model selection by TPOT/TTFT |
Looper Algorithms (multi-model orchestration)
| Algorithm | Description | Key Feature |
|---|---|---|
| Confidence | Small-to-large escalation | Logprob-based confidence evaluation |
| Ratings | Bounded concurrent execution | Concurrency cap + rating aggregation |
| ReMoM | Multi-round parallel reasoning | Breadth schedule + intelligent synthesis |