Hybrid Selection
Hybrid selection combines multiple selection methods (Elo, RouterDC, AutoMix, Cost) with configurable weights. This allows you to balance different factors like user feedback history, semantic matching, cost efficiency, and quality scores for optimal model selection.
Note on Hybrid LLM paper: The Hybrid LLM paper (Ding et al.) trains a BERT-based quality-gap predictor for binary routing between two models, achieving up to 40% fewer expensive model calls. Our implementation takes a different approach: a weighted ensemble that combines multiple signals (Elo ratings, semantic similarity, POMDP values, cost) rather than a trained binary classifier.
Algorithm Flow
Mathematical Foundation
Combined Score Formula
score(m, q) = w_elo × E(m) + w_dc × S(q,m) + w_mix × V(m,q) + w_cost × C(m)
Where:
E(m)= Normalized Elo ratingS(q, m)= Normalized RouterDC similarityV(m, q)= Normalized AutoMix valueC(m)= Normalized cost efficiency (1 - relative_cost)Σw_i = 1(weights must sum to 1)
Score Normalization
Each component is normalized to [0, 1]:
| Component | Normalization |
|---|---|
| Elo | E = (R - 1000) / 1000 (clamped) |
| RouterDC | Already in [0, 1] (cosine similarity) |
| AutoMix | V = (V - V_min) / (V_max - V_min) |
| Cost | C = 1 - (cost / max_cost) |
Core Algorithm (Go)
// Select using weighted combination of methods
func (s *HybridSelector) Select(ctx context.Context, selCtx *SelectionContext) (*SelectionResult, error) {
var bestModel string
var bestScore float64 = -1
for _, candidate := range selCtx.CandidateModels {
eloScore := s.normalizeElo(s.eloSelector.GetRating(candidate.Model))
dcScore := s.routerDCSelector.GetSimilarity(selCtx.Query, candidate.Model)
mixScore := s.normalizePOMDP(s.autoMixSelector.GetValue(candidate.Model, selCtx.Query))
costScore := s.normalizeCost(s.getCost(candidate.Model))
combined := s.eloWeight*eloScore +
s.routerDCWeight*dcScore +
s.autoMixWeight*mixScore +
s.costWeight*costScore
if combined > bestScore {
bestScore = combined
bestModel = candidate.Model
}
}
return &SelectionResult{
SelectedModel: bestModel,
Score: bestScore,
Method: MethodHybrid,
}, nil
}
How It Works
The combined score is calculated as:
combined = w1 × elo + w2 × similarity + w3 × pomdp + w4 × cost_efficiency