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.
翻译:基于大语言模型的文本到SQL系统在学术基准测试中表现出色,但在复杂的企业环境中却面临挑战。其主要局限在于对静态模式表示的依赖,这无法有效解决语义模糊性,也难以扩展到庞大而复杂的数据库。为此,我们提出APEX-SQL,一种智能体驱动的文本到SQL框架,它将范式从被动翻译转变为智能体探索。我们的框架采用假设-验证循环,将模型推理建立在真实数据之上。在模式链接阶段,我们使用逻辑规划来表述假设,通过双路径剪枝来缩小搜索空间,并利用并行数据剖析根据真实数据验证列的角色,随后进行全局综合以确保拓扑连通性。对于SQL生成,我们引入一种确定性机制来检索探索指令,使智能体能够有效探索数据分布、优化假设并生成语义准确的SQL。在BIRD(70.65%执行准确率)和Spider 2.0-Snow(51.01%执行准确率)上的实验表明,APEX-SQL在减少令牌消耗的同时,性能优于现有基线方法。进一步分析揭示,智能体探索起到了性能倍增器的作用,释放了基础模型在企业环境中的潜在推理能力。消融研究证实了每个组件在确保稳健且准确的数据分析方面的关键贡献。