arXiv:2501.13594cs.DBcs.AI2025-01被引 7

用关键词搜索提升LLM生成复杂SQL的准确率

Text-to-SQL based on Large Language Models and Database Keyword Search

  • 结合动态示例与数据库关键词搜索优化Schema链接
  • 在真实数据库上达到比现有方法更高的准确率
  • 适合处理含复杂过滤和连接的自然语言查询

基于大语言模型(LLM)的Text-to-SQL提示策略在知名基准上表现优异,但在真实关系型数据库中性能显著下降,尤其对需复杂过滤和连接的自然语言问题。本文提出一种新策略,通过动态少样本示例与数据库关键词搜索(KwS)平台服务,将自然语言问题编译为SQL。利用示例和关键词匹配提升模式链接的精确率与召回率,并借助KwS平台生成包含必要连接的视图,简化查询生成过程。在真实数据库上的实验表明,该策略性能超越现有最先进方法。

原文摘要 · Abstract (English)

Text-to-SQL prompt strategies based on Large Language Models (LLMs) achieve remarkable performance on well-known benchmarks. However, when applied to real-world databases, their performance is significantly less than for these benchmarks, especially for Natural Language (NL) questions requiring complex filters and joins to be processed. This paper then proposes a strategy to compile NL questions into SQL queries that incorporates a dynamic few-shot examples strategy and leverages the services provided by a database keyword search (KwS) platform. The paper details how the precision and recall of the schema-linking process are improved with the help of the examples provided and the keyword-matching service that the KwS platform offers. Then, it shows how the KwS platform can be used to synthesize a view that captures the joins required to process an input NL question and thereby simplify the SQL query compilation step. The paper includes experiments with a real-world relational database to assess the performance of the proposed strategy. The experiments suggest that the strategy achieves an accuracy on the real-world relational database that surpasses state-of-the-art approaches. The paper concludes by discussing the results obtained.

Text-to-SQL大模型关键词搜索数据库

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。