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

使用函数调用查询数据库

Querying Databases with Function Calling

Weaviate;Contextual AI;Morningstar(晨星公司)
Connor Shorten, Charles Pierse, Thomas Benjamin Smith, Karel D'Oosterlinck, Tuana Celik, Erika Cardenas, Leonie Monigatti, Mohd Shukri Hasan, Edward Schmuhl, Da… 展开作者

Connor Shorten, Charles Pierse, Thomas Benjamin Smith, Karel D'Oosterlinck, Tuana Celik, Erika Cardenas, Leonie Monigatti, Mohd Shukri Hasan, Edward Schmuhl, Daniel Williams, Aravind Kesiraju, Bob van Luijt

AI总结:

本文提出一种统一的数据库查询工具定义,通过函数调用使LLMs能结合搜索查询、过滤器和聚合算子访问与转换数据,并在8个模型上验证了其有效性,发现高性能模型表现稳健。

摘要:

大型语言模型(LLMs)的能力正在快速提升,这在很大程度上得益于它们与外部工具的集成。查询数据库是这些集成中最有效的方法之一,使LLMs能够访问私有或持续更新的数据。虽然函数调用(Function Calling)是将外部工具与LLMs接口的最常用方法,但其作为工具在数据库查询中的应用却一直未得到充分探索。我们提出了一种用于数据库查询的工具定义,该定义统一了使用搜索查询、过滤器或两者结合来访问数据,以及使用聚合和groupby算子转换结果。为了评估其有效性,我们使用涵盖5个模型系列的8个LLMs进行了一项研究。我们提出了一种新颖的流程,改编Gorilla LLM框架来创建合成数据库模式和查询。我们主要使用预测和基准查询API的精确匹配来评估模型。在测试的模型中,Claude 3.5 Sonnet取得了最高的性能,精确匹配得分为74.3%,其次是GPT-4o mini,为73.7%,GPT-4o为71.8%。我们进一步按使用的API组件和跨合成用例分解这些结果。我们发现LLMs在利用布尔属性上的算子方面非常有效,但在文本属性过滤器方面表现不佳。在用例中,我们发现像GPT-4o这样性能较高的模型具有稳健的结果,但性能较低的模型在不同用例之间存在显著的性能差异。我们还进行了消融研究,探索了并行工具调用、在工具调用参数中添加理由、每个数据库集合使用单独工具以及使用结构化输出进行工具调用的影响。我们的发现证明了启用LLMs使用函数调用查询数据库的有效性。我们在github.com/weaviate/gorilla开源了我们的实验代码和结果。

英文摘要:

The capabilities of Large Language Models (LLMs) are rapidly accelerating largely thanks to their integration with external tools. Querying databases is among the most effective of these integrations, enabling LLMs to access private or continually updating data. While Function Calling is the most common method for interfacing external tools to LLMs, its application to database querying as a tool has been underexplored. We propose a tool definition for database querying that unifies accessing data with search queries, filters, or a combination both, as well as transforming results with aggregation and groupby operators. To evaluate its effectiveness, we conduct a study with 8 LLMs spanning 5 model families. We present a novel pipeline adapting the Gorilla LLM framework to create synthetic database schemas and queries. We primarily evaluate the models with the Exact Match of predicted and ground truth query APIs. Among the models tested, Claude 3.5 Sonnet achieves the highest performance with an Exact Match score of 74.3%, followed by GPT-4o mini at 73.7%, and GPT-4o at 71.8%. We further breakdown these results per API component utilized and across synthetic use cases. We find that LLMs are highly effective at utilizing operators on boolean properties, but struggle with text property filters. Across use cases we find robust results with the higher performing models such as GPT-4o, but significant performance variance across use cases from lower performing models. We additionally conduct ablation studies exploring the impact of parallel tool calling, adding a rationale as an argument of the tool call, using a separate tool per database collection, and tool calling with structured outputs. Our findings demonstrate the effectiveness of enabling LLMs to query databases with Function Calling. We have open-sourced our experimental code and results at github.com/weaviate/gorilla.

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

↑