Large Language Models (LLMs) driven by In-Context Learning (ICL) have significantly improved the performance of text-to-SQL. Previous methods generally employ a two-stage reasoning framework, namely 1) schema linking and 2) logical synthesis, making the framework not only effective but also interpretable. Despite these advancements, the inherent bad nature of the generalization of LLMs often results in hallucinations, which limits the full potential of LLMs. In this work, we first identify and categorize the common types of hallucinations at each stage in text-to-SQL. We then introduce a novel strategy, Task Alignment (TA), designed to mitigate hallucinations at each stage. TA encourages LLMs to take advantage of experiences from similar tasks rather than starting the tasks from scratch. This can help LLMs reduce the burden of generalization, thereby mitigating hallucinations effectively. We further propose TA-SQL, a text-to-SQL framework based on this strategy. The experimental results and comprehensive analysis demonstrate the effectiveness and robustness of our framework. Specifically, it enhances the performance of the GPT-4 baseline by 21.23% relatively on BIRD dev and it yields significant improvements across six models and four mainstream, complex text-to-SQL benchmarks.
翻译:基于上下文学习驱动的大型语言模型显著提升了文本到SQL任务的性能。现有方法通常采用两阶段推理框架,即1)模式链接与2)逻辑合成,使该框架兼具高效性与可解释性。尽管取得这些进展,大型语言模型固有的泛化缺陷仍常导致幻觉现象,限制了其潜力的充分发挥。本研究首先识别并分类了文本到SQL各阶段常见的幻觉类型,进而提出一种新颖的任务对齐策略,旨在分阶段缓解幻觉问题。该策略促使大型语言模型借鉴相似任务的经验而非从零开始执行任务,从而减轻模型的泛化负担,有效抑制幻觉产生。基于此策略,我们进一步提出TA-SQL文本到SQL框架。实验结果表明,该框架在BIRD开发集上将GPT-4基线的性能相对提升21.23%,并在六种模型与四个主流复杂文本到SQL基准测试中均取得显著改进,验证了框架的有效性与鲁棒性。