[论文解读] Toolformer: Language Models Can Teach Themselves to Use Tools
Toolformer 在自监督循环中训练语言模型以判断何时以及如何通过 API 调用外部工具,在各任务上取得强大的零-shot 结果,同时保留核心语言建模能力。
Language models (LMs) exhibit remarkable abilities to solve new tasks from just a few examples or textual instructions, especially at scale. They also, paradoxically, struggle with basic functionality, such as arithmetic or factual lookup, where much simpler and smaller models excel. In this paper, we show that LMs can teach themselves to use external tools via simple APIs and achieve the best of both worlds. We introduce Toolformer, a model trained to decide which APIs to call, when to call them, what arguments to pass, and how to best incorporate the results into future token prediction. This is done in a self-supervised way, requiring nothing more than a handful of demonstrations for each API. We incorporate a range of tools, including a calculator, a Q\&A system, two different search engines, a translation system, and a calendar. Toolformer achieves substantially improved zero-shot performance across a variety of downstream tasks, often competitive with much larger models, without sacrificing its core language modeling abilities.
研究动机与目标
- 使语言模型能够自主学习何时通过 API 调用哪些外部工具。
- 通过用带工具调用的数据来增强数据,而无需人工标注,从而提高零-shot 和少量样本任务的表现。
- 在增加工具使用行为的同时,保持模型的一般语言建模能力。
- 证明在没有任务特定监督的情况下,工具使用可以扩展到多样化的任务和工具。
提出的方法
- 将每次 API 调用表示为带有 <API> ... </API> 注释的文本嵌入令牌序列。
- 通过提示 LM 将数据注释为候选 API 调用、执行它们,并基于衡量未来令牌预测收益的自监督损失进行筛选,从而创建 C*。
- 计算 L_i^+ 为包含 API 调用及结果时的损失;L_i^- 为不含 API 调用或仅包含输入时的最小损失。
- 仅保留具备充分损失降低(τ_f)的 API 调用,并将有用的调用插入到原文本中形成 C*,然后以标准 LM 目标对 C* 对 LM 进行微调。
- 推理阶段,正常生成直到模型输出 →,获取 API 结果,并通过插入 API 响应来继续解码。
实验结果
研究问题
- RQ1语言模型是否能够在没有人工监督的情况下学会何时调用外部工具?
- RQ2哪些工具(QA、搜索、计算器、翻译、日历)在各种任务中提供最一致的提升?
- RQ3在工具增强数据上进行微调会削弱还是保留基础语言建模能力?
- RQ4模型规模如何影响在零-shot 设置中利用工具的能力?
主要发现
- Toolformer 在与同等规模基线相比下,显著提升了多样任务的零-shot 性能。
- 在 LAMA 子集(SQuAD、Google-RE、T-REx)上,Toolformer 的表现优于 GPT-J 基线,并且与 GPT-3(175B)相当。
- 在数学基准(ASDiv、SVAMP、MAWPS)上,带计算器调用的 Toolformer 远超基线,通常差异很大,大多数示例使用了计算器。
- 在问答数据集(WebQuestions、Natural Questions、TriviaQA)上,Toolformer 优于 GPT-J 基线,并且在检索上主要依赖维基百科搜索。
- 多语言问答(MLQA)显示 Toolformer 受益于机器翻译的使用,尽管不同语言的收益不同;在某些场景中,较大模型仍然优于 Toolformer。
- 时序数据集(TempLAMA、Dateset)显示在日历工具有用时 Toolformer 表现出色,Dateset 在使用日历时显示出强劲的提升。
- 在 WikiText 和 CCNet 子集上的困惑度表明,在推理阶段禁用 API 使用时,添加 API 调用不会增加语言模型的困惑度,保留核心 LM 能力。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。