Draft:Toolformer

From testwiki
Jump to navigation Jump to search

Template:AFC submission

Template:AFC comment


Template:Short description Template:Draft topics Template:AfC topic

ToolFormer is a method that enhances large language models (LLMs) by enabling interactions with external tools. Integrating tools with language models improves performance on complex tasks like question answering and arithmetic (on which LLMs have historically performed poorly[1]) with minimal human intervention. It also enables LLMs to answer queries about events outside the model's training data, which is impossible for a conventional LLM. Since its introduction in 2023, ToolFormer has gained considerable attention for its potential to extend LLM functionality and improve its adaptability to complex tasks.

Method

Dataset Creation

The model takes as input some plain text dataset represented as C={x1,...,x|C|} and adds possible API calls to it resulting in an augmented dataset C*. This is done by first sampling potential API calls for up to k candidate positions by calculating the probability of the Language Model M assigning an API call (<API>) as a continuation of a given sequence at position i for each i{1,...,n} as pi=pM(<API>|P(x),x1:i1). Only top k positions with probability pi>τs, where τs is a threshold, are kept and for each such position, m API calls are sampled.

Next, all the sampled API calls ci are executed and responses ri are collected (where ri is a text sequence). After this, API calls are filtered based on criss entropy loss values for the model. Loss is calculated as Li(z)=j=inwjilogpM(xj|z,x1:j1) given the model is prefixed with 𝐳 and weights are given as a sequence (wi|i). Cross entropy loss is calculated for two cases - (i) when the API call is made and the results are used in M and (ii) when API call is not made at all or the it's made but the response is not provided. These are computed using the following formulas: (i) Li+=Li(e(ci,ri)), (ii) Li=min(Li(ε),Li(e(ci,ε))) where ε is an empty sequence. Given the losses, APIs are filtered based on threshold τf such that LiLi+τf and the resulting APIs are added to the input. As a result, an augmented dataset C* is produced which is used in model finetuning.

Training

For training and evaluation, the authors used a subset of CCNet[2](dataset C) and GPT-J (language model M).

Evaluation

Authors compared four models in their experiment including GPT-J without finetuning, GPT-J finetuned on a subset of CCNet without API calls, Toolformer finetuned on the augmented dataset with API calls, and Toolformer with disabled API calls. These models, along with larger models - OPT and GPT-3 - were evaluated based on their performance on different downstream tasks without in-context examples fed into the model. The goal of this experimental set up is to see if the model can correctly decide which tools to use and how without users' directions.

When evaluated on subsets of LAMA[3][4] benchmark to fill in a missing part in a short statement, Toolformer with API calls outperforms all other models listed above. For math tasks evaluated using ASDiv,[5] SVAMP, and MAWPS,[6] Toolformer models with and without API calls outperform all the other models with Toolformer with API outperforming all the baseline models. Similar results are observed for temporal datasets as well evaluated on TempLama[7] and custom Dataset to check the utility of the Calendar API. Toolformer with API outperforms all the models except for GPT-3 in question answering task as well evaluated on Web Questions,[8] Natural Questions,[9] and TriviaQA[10] datasets. However, Toolformer shows worse performance for multilingual question answering tasks evaluated on MLQA.[11]

Benefits

Eliminate Memorization

Although LLMs are great at memorizing, they can't memorize every detail from the training set and consequently might not provide satisfactory responses to specialized questions. Integrating tools with LLMs (especially search/retrieval augmented generation) may help them respond better.

Enhanced Expertise

LLMs are generally trained on enormous corpora and may lack domain-specific knowledge, even when finetuned. Providing tooling for specific tasks, like a calculator, may improve expertise.

Interpretability

Explainable Artificial Intelligence is becoming very relevant, and tracking the tools that LLMs leverage can help us understand their decision-making process by recording when/how they're leveraged and their inputs and outputs.

Applications

Integrating tools with LLMs can be used to solve many challenging problems. Notably, search engines can be enhanced to use generative artificial intelligence techniques, like perplexity.ai[12] or Google's new AI overview feature.[13] Most LLM APIs specify techniques to help their models interact with other APIs[14][15][16]

Authors

The authors of the paper in which the Toolformer[17] model was introduced are Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, Thomas Scialom. Roberto Dessì is affiliated with Universitat Pompeu Fabra. All the other authors have an affiliation with Meta AI Research.

References

Template:Reflist