You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The repository is still under construction and only part of experiments/plots of the paper can be currently reproduced. See TODO section below.
Overview
CARROT is a lightweight, efficient, and theoretically optimal router designed for intelligently directing queries to Large Language Models (LLMs). With the rapid expansion of available LLMs, selecting the most cost-effective model capable of producing an adequate response is increasingly critical. CARROT selects models by balancing performance and cost, leveraging robust statistical estimates to ensure optimal routing decisions. It is computationally efficient and proven minimax rate-optimal, providing confidence in both cost savings and performance quality.
Key Features
Cost-Aware Selection: Routes queries to the cheapest capable LLM, optimizing for customizable cost-performance trade-offs.
Minimax Optimality: Theoretically established to achieve rate-optimal routing performance.
Smart Price-aware Routing (SPROUT) dataset and pre-trained router
To access our routing dataset, SPROUT, and our pre-trained router, please check CARROT's HuggingFace page.
Reproducing results from the paper
Insert your OPENAI API key on carrot/data_utils.py.
Generate data by running gen_open-llm-lb-v2.py and gen_sprout.py.
Train prediction models by running train_and_infer.py. You will have to specify which dataset you want to work with, e.g., python train_and_infer.py --dataset 'open-llm-lb-v2'.
Activate Jupyter Notebook and run carrot/plots.ipynb to generate plots.
TODOs
Include results for RouterBench.
Include rest of paper plots (e.g., choice of models).
Create demo for router training.
Citing
@article{somerstep2025carrot,
title={CARROT: A Cost Aware Rate Optimal Router},
author={Somerstep, Seamus and Maia Polo, Felipe and de Oliveira, Allysson Flavio Melo and Mangal, Prattyush and Silva, M{\'\i}rian and Bhardwaj, Onkar and Yurochkin, Mikhail and Maity, Subha},
journal={arXiv preprint arXiv:2502.03261},
year={2025}
}