Large language models (LLMs) with in-context learning have significantly improved the performance of text-to-SQL task. Previous works generally focus on using exclusive SQL generation prompt to improve the LLMs' reasoning ability. However, they are mostly hard to handle large databases with numerous tables and columns, and usually ignore the significance of pre-processing database and extracting valuable information for more efficient prompt engineering. Based on above analysis, we propose RB-SQL, a novel retrieval-based LLM framework for in-context prompt engineering, which consists of three modules that retrieve concise tables and columns as schema, and targeted examples for in-context learning. Experiment results demonstrate that our model achieves better performance than several competitive baselines on public datasets BIRD and Spider.
翻译:具备上下文学习能力的大语言模型显著提升了文本到SQL任务的性能。先前的研究通常侧重于使用专用的SQL生成提示来增强大语言模型的推理能力。然而,这些方法大多难以处理包含大量表和列的大型数据库,且通常忽略了预处理数据库以及提取有价值信息以进行更高效提示工程的重要性。基于以上分析,我们提出了RB-SQL,一种新颖的基于检索的上下文提示工程大语言模型框架。该框架包含三个模块,分别用于检索简洁的表和列作为模式,以及检索用于上下文学习的针对性示例。实验结果表明,在公开数据集BIRD和Spider上,我们的模型性能优于多个具有竞争力的基线方法。