Recent advancements in Large Language Models (LLMs), such as Codex, ChatGPT and GPT-4 have significantly impacted the AI community, including Text-to-SQL tasks. Some evaluations and analyses on LLMs show their potential to generate SQL queries but they point out poorly designed prompts (e.g. simplistic construction or random sampling) limit LLMs' performance and may cause unnecessary or irrelevant outputs. To address these issues, we propose CBR-ApSQL, a Case-Based Reasoning (CBR)-based framework combined with GPT-3.5 for precise control over case-relevant and case-irrelevant knowledge in Text-to-SQL tasks. We design adaptive prompts for flexibly adjusting inputs for GPT-3.5, which involves (1) adaptively retrieving cases according to the question intention by de-semantizing the input question, and (2) an adaptive fallback mechanism to ensure the informativeness of the prompt, as well as the relevance between cases and the prompt. In the de-semanticization phase, we designed Semantic Domain Relevance Evaluator(SDRE), combined with Poincar\'e detector(mining implicit semantics in hyperbolic space), TextAlign(discovering explicit matches), and Positector (part-of-speech detector). SDRE semantically and syntactically generates in-context exemplar annotations for the new case. On the three cross-domain datasets, our framework outperforms the state-of-the-art(SOTA) model in execution accuracy by 3.7\%, 2.5\%, and 8.2\%, respectively.
翻译:近期,大型语言模型(如Codex、ChatGPT和GPT-4)的进展显著影响了人工智能领域,包括文本转SQL任务。针对这些模型的评估与分析表明,尽管其具备生成SQL查询的潜力,但提示设计不当(例如简单的构造或随机采样)会限制模型性能,并可能导致不必要的或无关的输出。为解决这些问题,我们提出CBR-ApSQL——一种结合GPT-3.5的基于案例推理框架,用于精确控制文本转SQL任务中与案例相关及无关的知识。我们设计了自适应提示以灵活调整GPT-3.5的输入,具体包括:(1)通过去语义化输入问题,根据意图自适应检索案例;(2)建立自适应回退机制以确保提示信息的丰富性,以及案例与提示之间的相关性。在去语义化阶段,我们设计了语义域相关性评估器(SDRE),其融合了庞加莱检测器(挖掘双曲空间中的隐含语义)、TextAlign(发现显式匹配)和Positector(词性检测器)。SDRE通过语义和句法分析为新案例生成上下文示例标注。在三个跨领域数据集上,我们的框架在执行准确率方面分别超过当前最优模型3.7%、2.5%和8.2%。