让大模型动态组合SQL生成步骤,比固定流程更准更稳
Beyond Static Pipelines: Learning Dynamic Workflows for Text-to-SQL
- 用强化学习让模型自适应构建SQL生成流程
- 在复杂和陌生查询上比最优静态流程提升12.3%准确率
- 适合需要应对多变真实场景的智能数据库系统
Text-to-SQL 近期取得显著进展,但在真实场景中仍难有效应用。这源于对单一静态工作流的依赖,从根本上限制了其在分布外和长尾场景下的可扩展性。我们不依赖用户通过大量实验选择方法,而是让系统在推理时自适应构建工作流。通过理论与实证分析,我们证明最优动态策略始终优于最佳静态工作流,性能提升根本源于候选工作流间的异质性。受此启发,我们提出 SquRL,一个增强大模型推理能力的强化学习框架,用于自适应工作流构建。我们设计基于规则的奖励函数,并引入两种有效训练机制:动态演员掩码以促进更广探索,伪奖励以提升训练效率。在广泛使用的 Text-to-SQL 基准上的实验表明,动态工作流构建持续优于最佳静态工作流方法,尤其在复杂和分布外查询上表现尤为突出。代码已开源。
原文摘要 · Abstract (English)
Text-to-SQL has recently achieved impressive progress, yet remains difficult to apply effectively in real-world scenarios. This gap stems from the reliance on single static workflows, fundamentally limiting scalability to out-of-distribution and long-tail scenarios. Instead of requiring users to select suitable methods through extensive experimentation, we attempt to enable systems to adaptively construct workflows at inference time. Through theoretical and empirical analysis, we demonstrate that optimal dynamic policies consistently outperform the best static workflow, with performance gains fundamentally driven by heterogeneity across candidate workflows. Motivated by this, we propose SquRL, a reinforcement learning framework that enhances LLMs' reasoning capability in adaptive workflow construction. We design a rule-based reward function and introduce two effective training mechanisms: dynamic actor masking to encourage broader exploration, and pseudo rewards to improve training efficiency. Experiments on widely-used Text-to-SQL benchmarks demonstrate that dynamic workflow construction consistently outperforms the best static workflow methods, with especially pronounced gains on complex and out-of-distribution queries. The codes are available at https://github.com/Satissss/SquRL
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。