用历史查询生成提示,让大模型更准更快写复杂SQL
HI-SQL: Optimizing Text-to-SQL Systems through Dynamic Hint Integration
- 通过分析历史查询生成上下文提示,指导复杂SQL生成
- 在多个数据集上提升准确率,同时减少LLM调用次数和延迟
- 适合需要高效生成多表关联、嵌套条件查询的场景
文本到SQL生成使用户无需掌握SQL即可查询数据库。尽管大语言模型(LLMs)已显著推动该领域发展,但在处理涉及多表连接、嵌套条件和复杂操作的复杂查询时仍存在挑战。现有方法多采用多步流水线,计算成本高、延迟大且易产生错误传播。为此,我们提出HI-SQL,通过利用历史查询日志生成新颖的上下文提示,引导SQL生成。该方法分析过往查询,生成聚焦于多表与嵌套操作的提示信息,并无缝融入生成过程,避免了昂贵的多步流程,降低对人工提示的依赖。在多个基准数据集上的实验表明,该方法显著提升了LLM生成查询的准确性,同时在LLM调用次数和延迟方面保持高效,为增强Text-to-SQL系统提供了一种鲁棒且实用的解决方案。
原文摘要 · Abstract (English)
Text-to-SQL generation bridges the gap between natural language and databases, enabling users to query data without requiring SQL expertise. While large language models (LLMs) have significantly advanced the field, challenges remain in handling complex queries that involve multi-table joins, nested conditions, and intricate operations. Existing methods often rely on multi-step pipelines that incur high computational costs, increase latency, and are prone to error propagation. To address these limitations, we propose HI-SQL, a pipeline that incorporates a novel hint generation mechanism utilizing historical query logs to guide SQL generation. By analyzing prior queries, our method generates contextual hints that focus on handling the complexities of multi-table and nested operations. These hints are seamlessly integrated into the SQL generation process, eliminating the need for costly multi-step approaches and reducing reliance on human-crafted prompts. Experimental evaluations on multiple benchmark datasets demonstrate that our approach significantly improves query accuracy of LLM-generated queries while ensuring efficiency in terms of LLM calls and latency, offering a robust and practical solution for enhancing Text-to-SQL systems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。