Toolformer: Language Models Can Teach Themselves to Use Tools

展示了LM可以通过简单的API教自己使用外部工具,并实现两个世界的最佳效果。我们介绍了Toolformer,这是一个经过训练的模型,可以决定调用哪些API,何时调用,传递哪些参数,以及如何将结果最好地纳入未来的标记预测中。这是以一种自我监督的方式完成的,只需要对每个API进行少量的演示即可。我们纳入了一系列的工具,包括一个计算器、一个问答系统、一个搜索引擎、一个翻译系统和一个日历。

1 摘要部分的主要信息:

1) 大模型的不足或者本文的问题来源:最新的事件信息、相关事实的倾向不能捕捉,理解低资源语言的困难,缺乏进行精确计算的数学技能(Patel等人,2021)和对时间的进展没有意识(Dhingra等人,2022)
2) 数据集的获取上:Given just a handful of human-written examples of how an API can be used, we let a LM annotate a huge language modeling dataset with potential API calls (在标注小批量数据集的基础上,使用API完成数据集标注)
3) 训练方式上:We then use a self-supervised loss to determine which of these API calls actually help the model in predicting future tokens. Finally, we finetune the LM itself on the API calls that it con siders useful. As illustrated in Figure 1, through this simple approach, LMs can learn to control a va riety of tools, and to choose for themselves which tool to use when and how. (自监督损失)

2 方法部分的主要信息:

目标是准备每个API需要的输入和输出信息;表示为文本序列形式;
**过程:**第一步是使用大模型挖掘一部分可能的API calls的需求;第二步是对挖掘出的这部分需求做过滤,保留有用的,删掉没有用的。第三步是将所有的API calls组合起来,使用LM在这部分自己做的数据集上做微调。进而,最终具备选择API解决问题 的能力。

2.1 sample API calls

写了一个prompt来促使PLM 能够完成API calls.

计算PLM在句子中的每个token位置续写的可能性,如果高于一个值,则选择在这个位置续写。(为了保证续写位置的数量的上限,设置了一个阈值,当续写的概率高于这个阈值时,会续写,低于的情况下直接舍弃,如果高于的数量超过了k个,则按概率选择前k位置作为续写的地方)

Your task is to add calls to a Question
Answering API to a piece of text.
The questions should help you get
information required to complete the
text. You can call the API by writing
"[QA(question)]" where "question" is the
question you want to ask. Here are some
examples of API calls:
Input: Joe Biden was born in Scranton,
Pennsylvania.
Output: Joe Biden was born in [QA("Where
was Joe Biden born?")] Scranton,
[QA("In which state is Scranton?")]
Pennsylvania.
Input: Coca-Cola, or Coke, is a
carbonated soft drink manufactured by
the Coca-Cola Company.
Output: Coca-Cola, or [QA("What other
name is Coca-Cola known by?")] Coke, is
a carbonated soft drink manufactured by
[QA("Who manufactures Coca-Cola?")] the
Coca-Cola Company.

2.2 executing API calls

这一步内部怎么执行的,取决于API内部的模型自己。

2.3 filtering API calls

调用API calls产生result的过程中,也会有cross_entropy loss,相比于两种极端情况:不适用API calls和使用API calls但不会产生response,两种极端情况下的损失值的最小值,和前者比较,如果后者-前者>=阈值,则保留API calls.

在这里插入图片描述
在这里插入图片描述

2.4 Model finetuning

将API产生的序列合并作为一份新的dataset。然后用来微调LM。

3 实验结果

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YingJingh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值