Text-to-SQL, the task of translating natural language questions into SQL queries, is part of various business processes. Its automation, which is an emerging challenge, will empower software practitioners to seamlessly interact with relational databases using natural language, thereby bridging the gap between business needs and software capabilities. In this paper, we consider Large Language Models (LLMs), which have achieved state of the art for various NLP tasks. Specifically, we benchmark Text-to-SQL performance, the evaluation methodologies, as well as input optimization (e.g., prompting). In light of the empirical observations that we have made, we propose two novel metrics that were designed to adequately measure the similarity between SQL queries. Overall, we share with the community various findings, notably on how to select the right LLM on Text-to-SQL tasks. We further demonstrate that a tree-based edit distance constitutes a reliable metric for assessing the similarity between generated SQL queries and the oracle for benchmarking Text2SQL approaches. This metric is important as it relieves researchers from the need to perform computationally expensive experiments such as executing generated queries as done in prior works. Our work implements financial domain use cases and, therefore contributes to the advancement of Text2SQL systems and their practical adoption in this domain.
翻译:文本到SQL(Text-to-SQL)是将自然语言问题转换为SQL查询的任务,是多种业务流程的组成部分。其自动化作为一项新兴挑战,将使软件从业者能够通过自然语言与关系型数据库无缝交互,从而弥合业务需求与软件能力之间的鸿沟。在本文中,我们考虑了大语言模型(LLMs)——这类模型已在多种自然语言处理任务中达到最先进水平。具体来说,我们对Text-to-SQL性能、评估方法以及输入优化(如提示工程)进行了基准测试。基于实证观察,我们提出了两个旨在充分衡量SQL查询间相似度的新指标。总体而言,我们向社区分享了多项发现,特别是关于如何为Text-to-SQL任务选择合适的大语言模型。我们进一步证明,基于树的编辑距离是一种可靠的指标,可用于评估生成的SQL查询与基准测试中标准查询之间的相似度。该指标的重要性在于,它免除了研究者执行计算密集型实验(如先前工作中需运行生成的查询)的必要性。我们的工作实现了金融领域的用例,从而推动了Text2SQL系统的发展及其在该领域的实际应用。