提升文本转SQL的准确率,通过双向链接和自校正减少误漏。
RSL-SQL: Robust Schema Linking in Text-to-SQL Generation
- 双向剪枝+上下文增强,精准筛选数据库字段
- 严格召回率达94%,输入列数减少83%
- 适合追求高精度且成本敏感的Text-to-SQL应用
文本转SQL旨在将自然语言问题转化为SQL语句。基于大模型的Text-to-SQL普遍采用模式链接策略,仅选择相关模式元素输入模型,以降低噪声与计算开销。但该策略存在遗漏必要元素、破坏数据库结构完整性等风险。为此,本文提出RSL-SQL框架,结合双向模式链接、上下文信息增强、二元选择策略与多轮自校正机制。通过正向与反向剪枝提升模式链接召回率,实现94%的严格召回率,同时将输入列数减少83%。此外,通过全量模式与简化模式投票机制降低风险。在BIRD和Spider基准测试中,该方法在使用GPT-4o时分别取得67.2%和87.9%的执行准确率,超越现有开源方案。当采用更低成本的DeepSeek模型并保持相同提示时,仍优于多个GPT-4基线系统。大量分析与消融实验验证了各组件的有效性。代码已开源。
原文摘要 · Abstract (English)
Text-to-SQL generation aims to translate natural language questions into SQL statements. In Text-to-SQL based on large language models, schema linking is a widely adopted strategy to streamline the input for LLMs by selecting only relevant schema elements, therefore reducing noise and computational overhead. However, schema linking faces risks that require caution, including the potential omission of necessary elements and disruption of database structural integrity. To address these challenges, we propose a novel framework called RSL-SQL that combines bidirectional schema linking, contextual information augmentation, binary selection strategy, and multi-turn self-correction. We improve the recall of pattern linking using forward and backward pruning methods, achieving a strict recall of 94% while reducing the number of input columns by 83%. Furthermore, it hedges the risk by voting between a full mode and a simplified mode enhanced with contextual information. Experiments on the BIRD and Spider benchmarks demonstrate that our approach achieves SOTA execution accuracy among open-source solutions, with 67.2% on BIRD and 87.9% on Spider using GPT-4o. Furthermore, our approach outperforms a series of GPT-4 based Text-to-SQL systems when adopting DeepSeek (much cheaper) with same intact prompts. Extensive analysis and ablation studies confirm the effectiveness of each component in our framework. The codes are available at https://github.com/Laqcce-cao/RSL-SQL.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。