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

NL2SQL系统中提示优化的有效性

Effectiveness of Prompt Optimization in NL2SQL Systems

Megagon Labs(梅加贡实验室);Adobe

Sairam Gurajada, Eser Kandogan, Sajjadur Rahman

AI总结:

本文针对生产环境NL2SQL系统,提出一种基于静态示例选择和多目标优化的提示优化框架,以提升高精度与性能,并通过初步实验验证其有效性。

摘要:

NL2SQL方法已从大型语言模型(LLMs)的卓越能力中受益匪浅。特别是,为特定领域引导一个NL2SQL系统可以简单到用足够的上下文信息(如模式细节和翻译示例)来指示LLM。然而,构建一个准确的系统仍然需要严格的任务:为每个查询选择合适的上下文——包括识别相关的模式元素、单元格值以及帮助LLM理解领域特定细微差别的合适示例。基于检索的方法已成为识别此类上下文的首选方法。虽然有效,但这些方法由于检索过程而引入了额外的推理时间成本。在本文中,我们认为生产场景需要高精度、高性能的NL2SQL系统,而不仅仅是高质量的SQL生成——后者是当前大多数NL2SQL方法关注的焦点。在这种场景下,精心选择一组静态示例——捕捉查询日志、目标数据库、SQL结构和执行延迟的复杂性——比仅基于相似性的示例选择起着更关键的作用。然而,关键挑战在于为给定的生产环境识别一组具有代表性的示例。为此,我们提出了一个提示优化框架,该框架不仅解决了高精度要求,还通过多目标优化优化了生成SQL的性能。初步实证分析证明了所提出框架的有效性。

英文摘要:

NL2SQL approaches have greatly benefited from the impressive capabilities of large language models (LLMs). In particular, bootstrapping an NL2SQL system for a specific domain can be as simple as instructing an LLM with sufficient contextual information, such as schema details and translation demonstrations. However, building an accurate system still requires the rigorous task of selecting the right context for each query-including identifying relevant schema elements, cell values, and suitable exemplars that help the LLM understand domain-specific nuances. Retrieval-based methods have become the go-to approach for identifying such context. While effective, these methods introduce additional inference-time costs due to the retrieval process. In this paper, we argue that production scenarios demand high-precision, high-performance NL2SQL systems, rather than simply high-quality SQL generation, which is the focus of most current NL2SQL approaches. In such scenarios, the careful selection of a static set of exemplars-capturing the intricacies of the query log, target database, SQL constructs, and execution latencies-plays a more crucial role than exemplar selection based solely on similarity. The key challenge, however, lies in identifying a representative set of exemplars for a given production setting. To this end, we propose a prompt optimization framework that not only addresses the high-precision requirement but also optimizes the performance of the generated SQL through multi-objective optimization. Preliminary empirical analysis demonstrates the effectiveness of the proposed framework.

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

↑