Large Language Models (LLMs) provide exceptional capabilities, but routing every request to a powerful cloud model increases inference cost, latency, and token consumption. Our project addresses this challenge by introducing an intelligent hybrid routing agent that automatically selects the most appropriate model—either a local LLM or a remote cloud model—based on the complexity of each user prompt. The system begins by extracting rich prompt features, including technical depth, reasoning complexity, mathematical content, constraint density, ambiguity, and expected output size. These features are combined into an explainable complexity report and a continuous risk score, enabling the predictive router to make transparent, data-driven routing decisions. To ensure reliability, the project includes a language-aware evaluation framework that validates responses according to their actual programming language rather than assuming every coding task is Python. The evaluation pipeline distinguishes evaluator errors from model failures, providing accurate benchmark metrics and robust diagnostics. The router is benchmark-driven and continuously optimized using Oracle routing analysis. Comprehensive diagnostics—including feature contributions, risk components, routing explanations, and benchmark reports—make every routing decision explainable and easy to analyze. The architecture also supports automatic threshold calibration and configurable routing parameters, allowing the system to improve over time without requiring changes to the core routing logic. In our benchmark evaluation, the predictive router achieved over 96% response accuracy while reducing inference costs by approximately 82% and token usage by around 45% compared to always using a remote model. These results demonstrate that intelligent, explainable routing can significantly improve the efficiency of LLM-powered applications without sacrificing response quality.
Category tags: