Text-to-SQL enables users to interact with databases through natural language, simplifying access to structured data. Although highly capable large language models (LLMs) achieve strong accuracy for complex queries, they incur unnecessary latency and dollar cost for simpler ones. In this paper, we introduce the first LLM routing approach for Text-to-SQL, which dynamically selects the most cost-effective LLM capable of generating accurate SQL for each query. We present two routing strategies (score- and classification-based) that achieve accuracy comparable to the most capable LLM while reducing costs. We design the routers for ease of training and efficient inference. In our experiments, we highlight a practical and explainable accuracy-cost trade-off on the BIRD dataset.
翻译:文本到SQL技术使用户能够通过自然语言与数据库交互,简化了对结构化数据的访问。尽管能力强大的大语言模型(LLM)在复杂查询上实现了很高的准确率,但对于较简单的查询,它们却带来了不必要的延迟和成本开销。本文提出了首个面向文本到SQL的LLM路由方法,该方法能动态地为每个查询选择最具成本效益且能生成准确SQL的LLM。我们提出了两种路由策略(基于评分和基于分类),在保持与最强LLM相当准确率的同时,有效降低了成本。我们设计的路由器易于训练且推理高效。在我们的实验中,我们在BIRD数据集上展示了一个实用且可解释的准确率-成本权衡。