让大模型像侦探一样探索数据,解决复杂数据库的语义模糊问题。
APEX-SQL: Talking to the data via Agentic Exploration for Text-to-SQL
- 采用假设验证循环,结合真实数据动态验证列角色与逻辑关系。
- 在BIRD数据集上达到70.65%执行准确率,优于现有基线。
- 适合需要高精度、复杂数据库交互的企业级应用开发者。
基于大语言模型的文本转SQL系统在学术基准上表现优异,但在复杂的企事业单位环境中仍面临挑战。主要瓶颈在于依赖静态模式表示,难以处理语义歧义且难以扩展至大规模复杂数据库。为此,我们提出APEX-SQL,一种以代理式探索为核心的文本转SQL框架,将被动翻译转变为主动探索。该框架通过假设-验证循环,使模型推理基于真实数据。在模式链接阶段,采用逻辑规划生成假设,双路径剪枝缩小搜索空间,并行数据剖析验证列角色,全局合成确保拓扑连通性。在SQL生成阶段,引入确定性机制检索探索指令,使代理能有效探索数据分布,修正假设,生成语义准确的SQL。在BIRD(70.65%执行准确率)和Spider 2.0-Snow(51.01%执行准确率)上的实验表明,APEX-SQL优于现有基线,且消耗更少令牌。进一步分析显示,代理探索显著提升基础模型在企业场景下的推理潜力。消融实验证实各组件对鲁棒性和准确性至关重要。代码已开源:https://github.com/Tencent/APEX-SQL-Project。
原文摘要 · Abstract (English)
Text-to-SQL systems powered by Large Language Models have excelled on academic benchmarks but struggle in complex enterprise environments. The primary limitation lies in their reliance on static schema representations, which fails to resolve semantic ambiguity and scale effectively to large, complex databases. To address this, we propose APEX-SQL, an Agentic Text-to-SQL Framework that shifts the paradigm from passive translation to agentic exploration. Our framework employs a hypothesis-verification loop to ground model reasoning in real data. In the schema linking phase, we use logical planning to verbalize hypotheses, dual-pathway pruning to reduce the search space, and parallel data profiling to validate column roles against real data, followed by global synthesis to ensure topological connectivity. For SQL generation, we introduce a deterministic mechanism to retrieve exploration directives, allowing the agent to effectively explore data distributions, refine hypotheses, and generate semantically accurate SQLs. Experiments on BIRD (70.65% execution accuracy) and Spider 2.0-Snow (51.01% execution accuracy) demonstrate that APEX-SQL outperforms competitive baselines with reduced token consumption. Further analysis reveals that agentic exploration acts as a performance multiplier, unlocking the latent reasoning potential of foundation models in enterprise settings. Ablation studies confirm the critical contributions of each component in ensuring robust and accurate data analysis. Our code is released at https://github.com/Tencent/APEX-SQL-Project.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。