Large Language Models have recently shown impressive capabilities in reasoning and code generation, making them promising tools for natural language interfaces to relational databases. However, existing approaches often fail to generalize in complex, real-world settings due to the highly database-specific nature of SQL reasoning, which requires deep familiarity with unique schemas, ambiguous semantics, and intricate join paths. To address this challenge, we introduce a novel two-stage LLM-based framework that decouples knowledge acquisition from query generation. In the Exploration Stage, the system autonomously constructs a database-specific knowledge base by navigating the schema with a Monte Carlo Tree Search-inspired strategy, generating triplets of schema fragments, executable queries, and natural language descriptions as usage examples. In the Deployment Stage, a dual-agent system leverages the collected knowledge as in-context examples to iteratively retrieve relevant information and generate accurate SQL queries in response to user questions. This design enables the agent to proactively familiarize itself with unseen databases and handle complex, multi-step reasoning. Extensive experiments on large-scale benchmarks demonstrate that our approach significantly improves accuracy over strong baselines, highlighting its effectiveness and generalizability.


翻译:大型语言模型近期在推理与代码生成方面展现出卓越能力,使其成为关系型数据库自然语言接口的有力工具。然而,现有方法在复杂的真实场景中往往难以泛化,这源于SQL推理高度依赖数据库特性的本质——需要对独特的模式结构、模糊的语义表达以及复杂的连接路径有深入理解。为解决这一挑战,我们提出一种新颖的两阶段基于大语言模型的框架,将知识获取与查询生成解耦。在探索阶段,系统通过受蒙特卡洛树搜索启发的策略自主导航数据库模式,构建特定于数据库的知识库,生成包含模式片段、可执行查询及自然语言描述的三元组作为使用示例。在部署阶段,双智能体系统利用已收集的知识作为上下文示例,迭代检索相关信息并根据用户问题生成准确的SQL查询。这一设计使智能体能够主动熟悉未见过的数据库,并处理复杂的多步推理问题。在大规模基准测试上的广泛实验表明,我们的方法相较于强基线模型显著提升了准确率,凸显了其有效性与泛化能力。

0
下载
关闭预览

相关内容

数据库( Database )或数据库管理系统( Database management systems )是按照数据结构来组织、存储和管理数据的仓库。目前数据管理不再仅仅是存储和管理数据,而转变成用户所需要的各种数据管理的方式。
数据驱动的具身学习探索
专知会员服务
16+阅读 · 2025年2月26日
RecInterpreter:架起大语言模型与传统推荐模型的桥梁
专知会员服务
54+阅读 · 2023年11月9日
「基于深度学习的 SQL 生成」2022研究综述
专知会员服务
28+阅读 · 2022年8月12日
搜狗开源机器阅读理解工具箱
专知
19+阅读 · 2019年5月16日
自然语言处理(NLP)知识结构总结
AI100
51+阅读 · 2018年8月17日
最全数据科学学习资源:Python、线性代数、机器学习...
人工智能头条
12+阅读 · 2018年5月14日
福利 | 当Python遇上大数据与机器学习,入门so easy!
如何系统地学习数据挖掘?
数据库开发
11+阅读 · 2017年10月22日
关于数据挖掘,有几本书推荐给你......
图灵教育
16+阅读 · 2017年10月11日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
25+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
13+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
25+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
13+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员