用关键词提示提升大模型生成准确SQL的能力
KeyInst: Keyword Instruction for Improving SQL Formulation in Text-to-SQL
- 通过预提供关键SQL关键词引导大模型生成
- 在多个基准上显著优于现有提示方法
- 适合需要高精度SQL生成的数据库交互场景
文本到SQL解析旨在将自然语言查询(NLQ)转化为对应的SQL命令。该领域的主要挑战在于生成的SQL不仅语法正确,还需与自然语言输入语义一致。由于自然语言与SQL之间存在固有差异,这一任务尤为困难。本文提出关键词提示(KeyInst),一种利用大语言模型(LLMs)改进SQL生成的新方法。KeyInst通过提供可能出现在最终查询中的关键SQL关键词,引导模型更准确地生成查询。我们探索了两种集成策略:管道式(先生成关键词再提示)和单步式(联合生成关键词与SQL)。为此,我们构建了专门用于评估SQL生成能力的基准数据集StrucQL。大量实验表明,KeyInst显著优于现有的文本到SQL提示技术。
原文摘要 · Abstract (English)
Text-to-SQL parsing involves the translation of natural language queries (NLQs) into their corresponding SQL commands. A principal challenge within this domain is the formulation of SQL queries that are not only syntactically correct but also semantically aligned with the natural language input. However, the intrinsic disparity between the NLQ and the SQL poses a significant challenge. In this research, we introduce Keyword Instruction (KeyInst), a novel method designed to enhance SQL formulation by Large Language Models (LLMs). KeyInst essentially provides guidance on pivotal SQL keywords likely to be part of the final query, thus facilitates a smoother SQL query formulation process. We explore two strategies for integrating KeyInst into Text-to-SQL parsing: a pipeline strategy and a single-pass strategy. The former first generates KeyInst for question, which are then used to prompt LLMs. The latter employs a fine-tuned model to concurrently generate KeyInst and SQL in one step. We developed StrucQL, a benchmark specifically designed for the evaluation of SQL formulation. Extensive experiments on StrucQL and other benchmarks demonstrate that KeyInst significantly improves upon the existing Text-to-SQL prompting techniques.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。