tool-retrieval-benchmark:为大型语言模型打造全面的工具检索基准
项目介绍
在人工智能发展的今天,大型语言模型(Large Language Models, LLMs)已经展现出了惊人的能力,但在实际应用中,它们仍需借助外部工具来扩展其功能。为此,tool-retrieval-benchmark(简称ToolRet)项目应运而生。该项目旨在为工具检索任务提供一个全面的评估基准,并配套一个大规模的训练数据集,以优化信息检索(IR)模型在工具检索任务上的性能。
项目技术分析
ToolRet项目包含了两个核心贡献:
- 全面的工具检索基准:该基准通过系统性地评估现有信息检索模型在工具检索任务上的表现,填补了当前评估标准的空白。
- 大规模训练数据集:该数据集专门用于优化IR模型在工具检索任务上的性能,使得模型能够更好地理解并检索合适的工具。
项目提供了一个具体的评估数据集示例,如下所示:
{
"id": "apigen_query_5",
"query": "Given an initial population of 500 bacteria with a growth rate of 0.3 per minute and a doubling time of 20 minutes, what will be the population after 45 minutes?",
"labels": [
{
"id": "apigen_tool_272",
"doc": {
"name": "bacterial_growth",
"description": "Calculates the bacterial population after a given time based on the initial population and growth rate.",
"parameters": {
"initial_population": {
"description": "The initial bacterial population.",
"type": "int",
"default": 20
},
"growth_rate": {
"description": "The growth rate per unit time.",
"type": "float",
"default": 20
},
"time": {
"description": "The time elapsed.",
"type": "float"
},
"doubling_time": {
"description": "The doubling time of the bacteria in minutes. Defaults to 20.",
"type": "float, optional"
}
}
},
"relevance": 1
}
],
"instruction": "Given a `bacterial population prediction` task, retrieve tools that calculate population growth by processing parameters such as initial population, growth rate, elapsed time, and doubling time to provide the projected population size."
}
该示例展示了如何给定一个查询,模型需要检索出能够计算细菌增长的工具。
项目技术应用场景
ToolRet项目在实际应用中具有广泛的使用场景。例如,在面对复杂问题时,LLMs可以通过检索合适的工具来辅助解决问题,比如计算、数据分析、信息查询等。以下是几个具体的应用场景:
- 科学计算:LLMs可以检索到用于科学计算的工具,如细菌增长计算、天体物理模拟等。
- 数据分析:在进行数据分析时,LLMs可以找到合适的统计工具,以辅助分析数据并得出结论。
- 信息查询:对于需要特定信息的问题,LLMs可以通过检索工具来查询Wayback Machine中的网页存档,或是检查网站的可访问性。
项目特点
ToolRet项目具有以下几个显著特点:
- 创新性:作为首个全面的工具检索基准,为LLMs的工具学习提供了系统性的评估方法。
- 实用性:提供了大规模的训练数据集,有助于优化IR模型在工具检索任务上的性能。
- 通用性:适用于多种类型的工具检索任务,包括科学计算、数据分析、信息查询等。
在Python环境中,可以通过以下命令创建项目所需的虚拟环境:
conda env create -f requirements.yml
评估模型时,项目支持多种先进的IR模型,如sentence-transformers、Huggingface-AutoModel等。以下是一个使用intfloat/e5-small-v2模型进行评估的示例:
# evaluate embedding models
from toolret.eval import eval_retrieval
from toolret.config import _MODEL, _TASK
import os
model = 'intfloat/e5-small-v2' # _MODEL[0]
task = ['all']
output_file = ','.join(task)+'.json'
results = eval_retrieval(model_name=model,
tasks=task,
category='all',
output_file=output_file,
is_inst=True)
print(results)
总之,tool-retrieval-benchmark项目为LLMs在工具学习领域提供了一个重要的评估和优化工具,对于研究人员和开发者来说,具有极高的使用价值和研究意义。如果您对这个项目感兴趣,不妨尝试使用并给出您的宝贵反馈。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考