arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.13301cs.CLcs.AI
收藏

提示GPT-3.5进行文本到SQL转换:去语义化与骨架检索

Prompting GPT-3.5 for Text-to-SQL with De-semanticization and Skeleton Retrieval

National University of Defense Technology(国防科技大学)

Chunxi Guo, Zhiliang Tian, Jintao Tang, Pancheng Wang, Zhihua Wen, Kang Yang, Ting Wang

AI总结:

提出基于LLM的文本到SQL框架,通过去语义化提取问题骨架检索相似示例,并建模问题与数据库模式关系,在三个跨领域基准上超越现有模型。

摘要:

文本到SQL是将自然语言问题转换为结构化查询语言(SQL)以从数据库中检索信息的任务。大型语言模型(LLMs)在自然语言生成任务中表现出色,但它们并未专门预训练以理解SQL命令的语法和语义。在本文中,我们提出了一种基于LLM的文本到SQL框架,该框架检索有用的演示示例来提示LLMs。然而,即使意图相似且对应的SQL查询表现出相似性,具有不同数据库模式的问题也可能差异很大。因此,识别符合我们需求的适当SQL演示变得至关重要。我们设计了一种去语义化机制来提取问题骨架,从而能够基于结构相似性检索相似示例。我们还对问题标记与数据库模式项(即表和列)之间的关系进行建模,以过滤掉与模式相关的信息。我们的框架调整提示中数据库模式的范围,以平衡长度和宝贵信息。回退机制允许在生成的SQL查询失败时提供更详细的模式。我们的方法优于最先进的模型,并在三个跨领域文本到SQL基准上展示了强大的泛化能力。

英文摘要:

Text-to-SQL is a task that converts a natural language question into a structured query language (SQL) to retrieve information from a database. Large language models (LLMs) work well in natural language generation tasks, but they are not specifically pre-trained to understand the syntax and semantics of SQL commands. In this paper, we propose an LLM-based framework for Text-to-SQL which retrieves helpful demonstration examples to prompt LLMs. However, questions with different database schemes can vary widely, even if the intentions behind them are similar and the corresponding SQL queries exhibit similarities. Consequently, it becomes crucial to identify the appropriate SQL demonstrations that align with our requirements. We design a de-semanticization mechanism that extracts question skeletons, allowing us to retrieve similar examples based on their structural similarity. We also model the relationships between question tokens and database schema items (i.e., tables and columns) to filter out scheme-related information. Our framework adapts the range of the database schema in prompts to balance length and valuable information. A fallback mechanism allows for a more detailed schema to be provided if the generated SQL query fails. Ours outperforms state-of-the-art models and demonstrates strong generalization ability on three cross-domain Text-to-SQL benchmarks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑