Text-to-SQL simplifies database interactions by enabling non-experts to convert their natural language (NL) questions into Structured Query Language (SQL) queries. While recent advances in large language models (LLMs) have improved the zero-shot text-to-SQL paradigm, existing methods face scalability challenges when dealing with massive, dynamically changing databases. This paper introduces DBCopilot, a framework that addresses these challenges by employing a compact and flexible copilot model for routing across massive databases. Specifically, DBCopilot decouples the text-to-SQL process into schema routing and SQL generation, leveraging a lightweight sequence-to-sequence neural network-based router to formulate database connections and navigate natural language questions through databases and tables. The routed schemas and questions are then fed into LLMs for efficient SQL generation. Furthermore, DBCopilot also introduced a reverse schema-to-question generation paradigm, which can learn and adapt the router over massive databases automatically without requiring manual intervention. Experimental results demonstrate that DBCopilot is a scalable and effective solution for real-world text-to-SQL tasks, providing a significant advancement in handling large-scale schemas.
翻译:文本转SQL通过使非专业用户将自然语言问题转换为结构化查询语言(SQL)查询,简化了数据库交互。尽管近期大型语言模型(LLM)的进展改进了一阶段(zero-shot)文本转SQL范式,但现有方法在处理大规模、动态变化的数据库时面临可扩展性挑战。本文提出DBCopilot框架,通过采用紧凑且灵活的协同模型(copilot model)进行大规模数据库路由来应对这些挑战。具体而言,DBCopilot将文本转SQL过程解耦为模式路由(schema routing)和SQL生成,利用轻量级序列到序列神经网络路由器建立数据库连接,并引导自然语言问题穿过数据库和数据表。路由后的模式与问题随后被输入LLM以高效生成SQL。此外,DBCopilot还引入了逆向模式到问题生成范式,可在大规模数据库上自动学习并适配路由器,无需人工干预。实验结果表明,DBCopilot是面向真实场景文本转SQL任务的可扩展且有效的解决方案,为处理大规模模式带来了显著进展。