用语义奖励模型提升大模型生成SQL的准确性。
GradeSQL: Test-Time Inference with Outcome Reward Models for Text-to-SQL Generation from Large Language Models
- 引入语义奖励模型作为测试时筛选机制,替代传统语法或频率选择。
- 在BIRD和Spider数据集上,准确率分别比基线高4.33%和2.10%。
- 对已对齐的模型微调后效果更优,适合复杂查询场景。
文本转SQL任务借助大语言模型(LLMs)取得显著进展,使更多用户能便捷访问数据库。尽管生成有效SQL的能力大幅提升,现有模型在处理复杂查询时仍存不足。当前常用测试时策略如Best-of-N(BoN)和多数投票(Maj),依赖表面启发式方法,通过执行结果选择语法正确查询(ex-BoN)或高频输出(Maj)。近期出现的成果奖励模型(ORMs)基于语义正确性为生成结果打分,成为提升模型对齐的有前景强化学习方法。本文提出针对文本转SQL任务的统一ORM训练框架,并评估其作为BoN策略中测试时启发式的有效性。在BIRD和Spider数据集上对比ORMs、ex-BoN与Maj,微调Qwen2、Granite3、Llama3系列多个开源模型。结果表明,ORMs优于ex-BoN和Maj,执行准确率分别提升+4.33%(BIRD)和+2.10%(Spider)(相对ex-BoN),以及+2.91%(BIRD)和+0.93%(Spider)(相对Maj)。进一步发现,对已对齐的模型如OmniSQL进行微调可获得更优的ORM性能。此外,ORMs在简单查询上表现良好,且随候选数量增加受益更明显,优于ex-BoN和Maj。
原文摘要 · Abstract (English)
Text-to-SQL, the task of translating natural language questions into SQL queries, has significantly advanced with the introduction of Large Language Models (LLMs), broadening database accessibility for a wide range of users. Despite substantial progress in generating valid SQL, current LLMs still struggle with complex queries. To address this limitation, test-time strategies such as Best-of-N (BoN) and Majority Voting (Maj) are often employed, based on the assumption that LLMs can produce correct answers after multiple attempts. However, these methods rely on surface-level heuristics, selecting the syntactically correct query through execution-based BoN (ex-BoN) or the most frequently generated one through Majority Voting. Recently, Outcome Reward Models (ORMs), which assign utility scores to generated outputs based on semantic correctness, have emerged as a promising reinforcement learning approach for improving model alignment. We argue that ORMs could serve as an effective new test-time heuristic, although their application in this context remains largely underexplored. In this work, we propose a unified framework for training ORMs tailored to the Text-to-SQL task and assess their effectiveness as a test-time heuristic within the BoN strategy. We benchmark ORMs against ex-BoN and Maj across the BIRD and Spider datasets, fine-tuning diverse open-source LLMs from the Qwen2, Granite3, and Llama3 families. Results show that ORMs outperform ex-BoN and Maj, achieving execution accuracy gains of +4.33% (BIRD) and +2.10% (Spider) over ex-BoN, and +2.91% (BIRD) and +0.93% (Spider) over Maj. We further demonstrate that finetuning models already aligned with SQL generation, such as OmniSQL, yields superior ORM performance. Additionally, we observe that ORMs achieve competitive results on simple queries and benefit more from an increased number of candidates compared to ex-BoN and Maj.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。