Team Ai
Modelpublic

adaptive-classifier/chayan

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
3likes21downloads
Model Card

Chayan: Multi-Model LLM Router

This model is a high-performance LLM router presented in the paper RouterArena: An Open Platform for Comprehensive Comparison of LLM Routers.

Chayan intelligently routes between 4 models (gpt-4o-mini, gemini-2.5-flash-lite, gemini-2.5-flash, and gpt-4o) to optimize the accuracy-cost tradeoff.

๐Ÿ† RouterArena Performance

Official Leaderboard Results (8,400 queries):

  • โ€”๐Ÿฅ‡ #1 Optimal Accuracy Score: 88.7% - SOTA! (Best routing decision quality)
  • โ€”๐Ÿฅˆ #2 Optimal Selection Score: 43.0% - Silver! (Second-best model selection)
  • โ€”#7 Overall (#5 open-source): 64.9% accuracy, 63.8 arena score
  • โ€”$0.60 per 1K queries - Cost-efficient routing

[image]

What do these metrics mean?

  • โ€”Optimal Accuracy: When Chayan routes to a model, that model gives the correct answer 88.7% of the time
  • โ€”Optimal Selection: Chayan selects the best available model 43% of the time

View full leaderboard: RouterArena | PR #24

Quick Start

bash
pip install adaptive-classifier
python
from adaptive_classifier import AdaptiveClassifier

# Load router
router = AdaptiveClassifier.load("adaptive-classifier/chayan")

# Get routing decision
query = "What is the capital of France?"
predictions = router.predict(query, k=4)

# Route to top model
selected_model = predictions[0][0]  # e.g., "openai/gpt-4o-mini"

Recommended: Use with Calibration

python
# Apply calibration factors for best performance
calibration = {
    "openai/gpt-4o-mini": 0.9,
    "google/gemini-2.5-flash-lite": 1.5,
    "google/gemini-2.5-flash": 1.8,
    "openai/gpt-4o": 1.5
}

predictions = router.predict(query, k=4)
calibrated_scores = {model: score * calibration[model] for model, score in predictions}
selected_model = max(calibrated_scores.items(), key=lambda x: x[1])[0]

Architecture

Core Components:

  • โ€”Base Model: BERT-base-uncased embeddings
  • โ€”Classifier: Adaptive K-NN with prototype memory (FAISS-backed)
  • โ€”Innovation: Calibrated confidence scores to correct training data imbalance

Supported Models:

ModelUse CaseCost/1M tokens
openai/gpt-4o-miniSimple queries$0.15
google/gemini-2.5-flash-liteMedium complexity$0.075
google/gemini-2.5-flashHigher complexity$0.30
openai/gpt-4oComplex queries$2.50

How It Works

Training

  • โ€”Dataset: RouterArena sub_10 (809 queries)
  • โ€”Oracle Labels: 4-model cascade strategy (select cheapest successful model)
  • โ€”Training Time: 19.2 minutes
  • โ€”Method: K-NN classifier with 3000 prototypes, temperature 0.4

The Calibration Breakthrough

The uncalibrated router achieved 61.76% accuracy but was biased toward gpt-4o-mini (83% routing). This happened because the training data had class imbalance:

  • โ€”57% gpt-4o-mini examples
  • โ€”27% gpt-4o examples
  • โ€”12% gemini-flash-lite examples
  • โ€”4% gemini-flash examples

Solution: Apply post-training calibration factors to correct the bias without retraining.

Result: +7.29pp improvement (61.76% โ†’ 69.05% on sub_10 benchmark)

Performance Benchmarks

Sub_10 Benchmark (809 queries):

RouterAccuracyCost/1K
All gpt-4o-mini (baseline)56.98%$0.088
2-model router61.43%$0.217
Chayan (uncalibrated)61.76%$0.269
Chayan (calibrated)69.05%$0.333
Perfect 2-model oracle69.84%$0.784

Key Insight: Chayan achieves 99% of perfect oracle performance at 57% lower cost.

Full Dataset (8,400 queries):

  • โ€”Optimal Accuracy: 88.7% (๐Ÿฅ‡ #1)
  • โ€”Optimal Selection: 43.0% (๐Ÿฅˆ #2)
  • โ€”Overall Accuracy: 64.9% (#7 overall, #5 open-source)
  • โ€”Cost: $0.60/1K queries

Advanced Usage

Feature Augmentation

Chayan was trained with query features prepended as tokens:

python
from adaptive_classifier.complexity_features import augment_query_with_features

query = "What is 2+2?"
augmented = augment_query_with_features(query)
# Returns: "[LEN:12][WORDS:3][MATH:1][SENT:1][MC:0] What is 2+2?"

predictions = router.predict(augmented, k=4)

Limitations

  • โ€”Calibration factors optimized on RouterArena sub_10; may require adjustment for other domains
  • โ€”Requires the 4 specific models to be available via API
  • โ€”Performance depends on query distribution similar to RouterArena benchmark
  • โ€”Cost estimates assume ~500 tokens per query

Citation

bibtex
@software{adaptive_classifier,
  title = {Adaptive Classifier: Dynamic Text Classification with Continuous Learning},
  author = {Sharma, Asankhaya},
  year = {2025},
  publisher = {GitHub},
  url = {https://github.com/codelion/adaptive-classifier}
}