KNN (K-Nearest Neighbors)
Overview
knn is a selection algorithm that uses K-Nearest Neighbors for example-based model selection. It finds the k most similar historical queries and votes on the best model based on their outcomes.
It aligns to config/fragments/algorithm/selection/knn.yaml.
Implementation: Rust via Linfa (linfa-nn) for high-performance nearest-neighbor search.
Key Advantages
- Interpretable: routing decisions can be traced back to similar historical examples.
- No training phase needed — just store and query examples.
- Works well when similar prompts should choose similar models.
- Quality-weighted voting considers the outcome quality of each neighbor.