arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.01661cs.DBcs.AIcs.CLcs.LG
收藏

R-Bot:基于大语言模型的查询重写系统

R-Bot: An LLM-based Query Rewrite System

Tsinghua University(清华大学);Shanghai Jiao Tong University(上海交通大学);Huawei Company(华为公司)

Zhaoyan Sun, Xuanhe Zhou, Guoliang Li, Xiang Yu, Jianhua Feng, Yong Zhang

AI总结:

R-Bot 通过多源证据准备、混合结构-语义检索和逐步大语言模型重写,解决 LLM 查询重写中的幻觉问题,并在真实部署中超越现有方法、降低查询延迟。

摘要:

查询重写对于优化 SQL 查询至关重要,它能在不改变查询结果的前提下提高执行效率。传统上,该任务通过启发式方法和基于学习的方法来解决,但这两类方法分别在生成质量和鲁棒性方面存在不足。大语言模型(LLM)的最新进展提供了一种新范式,可以充分利用其卓越的自然语言和代码理解能力。尽管具有潜力,直接应用 GPT-4 等大语言模型仍面临幻觉等问题,即模型可能生成不准确或不相关的结果。为解决这一问题,我们提出 R-Bot,一个基于大语言模型且具有系统化方法的查询重写系统。我们首先设计了一个多源重写证据准备流水线,用于生成查询重写证据,以引导大语言模型避免幻觉。随后,我们提出一种混合结构-语义检索方法,结合结构分析和语义分析来检索最相关的重写证据,从而有效回答在线查询。接着,我们提出一种逐步式大语言模型重写方法,迭代利用检索到的证据,在自我反思机制下选择和编排重写规则。我们在真实数据集和广泛使用的基准上进行了全面实验,证明了 R-Bot 系统的优越性能,超越了当前最先进的查询重写方法。R-Bot 系统已在华为及真实客户环境中部署,结果表明所提出的 R-Bot 系统实现了更低的查询延迟。

英文摘要:

Query rewrite is essential for optimizing SQL queries to improve their execution efficiency without changing their results. Traditionally, this task has been tackled through heuristic and learning-based methods, each with its limitations in terms of inferior quality and low robustness. Recent advancements in LLMs offer a new paradigm by leveraging their superior natural language and code comprehension abilities. Despite their potential, directly applying LLMs like GPT-4 has faced challenges due to problems such as hallucinations, where the model might generate inaccurate or irrelevant results. To address this, we propose R-Bot, an LLM-based query rewrite system with a systematic approach. We first design a multi-source rewrite evidence preparation pipeline to generate query rewrite evidences for guiding LLMs to avoid hallucinations. We then propose a hybrid structure-semantics retrieval method that combines structural and semantic analysis to retrieve the most relevant rewrite evidences for effectively answering an online query. We next propose a step-by-step LLM rewrite method that iteratively leverages the retrieved evidences to select and arrange rewrite rules with self-reflection. We conduct comprehensive experiments on real-world datasets and widely used benchmarks, and demonstrate the superior performance of our system, R-Bot, surpassing state-of-the-art query rewrite methods. The R-Bot system has been deployed at Huawei and with real customers, and the results show that the proposed R-Bot system achieves lower query latency.

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

↑