Add 1 files
Browse files- 2403/2403.03031.md +197 -0
2403/2403.03031.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Title: Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models
|
| 2 |
+
|
| 3 |
+
URL Source: https://arxiv.org/html/2403.03031
|
| 4 |
+
|
| 5 |
+
Markdown Content:
|
| 6 |
+
Zhengliang Shi 1 Shen Gao 2 Xiuyi Chen 3 Yue Feng 4 Lingyong Yan 3
|
| 7 |
+
|
| 8 |
+
Haibo Shi 3 Dawei Yin 3 Pengjie Ren 1 Suzan Verberne 5 Zhaochun Ren 5
|
| 9 |
+
|
| 10 |
+
1 Shandong University 2 University of Electronic Science and Technology of China
|
| 11 |
+
|
| 12 |
+
3 Baidu Inc., Beijing, China 4 University of Birmingham, Birmingham, UK
|
| 13 |
+
|
| 14 |
+
5 Leiden University, Leiden, The Netherlands
|
| 15 |
+
|
| 16 |
+
shizhl@mail.sdu.edu.cn z.ren@liacs.leidenuniv.nl
|
| 17 |
+
|
| 18 |
+
###### Abstract
|
| 19 |
+
|
| 20 |
+
Tool learning empowers large language models (LLMs) as agents to use external tools and extend their utility. Existing methods employ one single LLM-based agent to iteratively select and execute tools, thereafter incorporating execution results into the next action prediction. Despite their progress, these methods suffer from performance degradation when addressing practical tasks due to: (1) the pre-defined pipeline with restricted flexibility to calibrate incorrect actions, and (2) the struggle to adapt a general LLM-based agent to perform a variety of specialized actions. To mitigate these problems, we propose ConAgents, a Co operative and i n teractive Agents framework, which coordinates three specialized agents for tool selection, tool execution, and action calibration separately. ConAgents introduces two communication protocols to enable the flexible cooperation of agents. To effectively generalize the ConAgents into open-source models, we also propose specialized action distillation, enhancing their ability to perform specialized actions in our framework. Our extensive experiments on three datasets show that the LLMs, when equipped with the ConAgents, outperform baselines with substantial improvement (_i.e.,_ up to 14% higher success rate).
|
| 21 |
+
|
| 22 |
+
Learning to Use Tools via Cooperative and Interactive Agents
|
| 23 |
+
|
| 24 |
+
with Large Language Models
|
| 25 |
+
|
| 26 |
+
Zhengliang Shi 1 Shen Gao 2 Xiuyi Chen 3 Yue Feng 4 Lingyong Yan 3 Haibo Shi 3 Dawei Yin 3 Pengjie Ren 1 Suzan Verberne 5 Zhaochun Ren 5 1 Shandong University 2 University of Electronic Science and Technology of China 3 Baidu Inc., Beijing, China 4 University of Birmingham, Birmingham, UK 5 Leiden University, Leiden, The Netherlands shizhl@mail.sdu.edu.cn z.ren@liacs.leidenuniv.nl
|
| 27 |
+
|
| 28 |
+
1 Introduction
|
| 29 |
+
--------------
|
| 30 |
+
|
| 31 |
+
Although large language models (LLMs) have achieved remarkable performance in a broad range of natural language processing tasks(self-instruction; chang2023survey), they still encounter inherent limitations such as out-of-date information(toolw; mallen2023not). Tool learning is proposed to equip LLMs with various auxiliary resources, _e.g.,_ a search engine(webcpm; webgpt) or a calculator(toolformer; pal), which empower them as tool-use agents and improve their proficiency in tackling concrete complex tasks. As shown in Figure[1](https://arxiv.org/html/2403.03031v4#S1.F1 "Figure 1 โฃ 1 Introduction โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")(a), most previous studies allow the LLM-based agent to interleave multiple actions in a pre-defined order to interact with tools react; yang2023mm; zhuang2023toolqa. The agent first breaks down the task and plans a series of tools in a step-by-step manner. For each step, the agent executes the tools by passing arguments and continuously incorporates useful intermediates into the next action prediction.
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
|
| 35 |
+
Figure 1: Comparison between (a) existing single-agent tool learning method and (b) our cooperative agent framework ConAgents. The ConAgents coordinates three agents through two proposed communication protocols, _e.g.,_ automatic and adaptive interaction.
|
| 36 |
+
|
| 37 |
+
Despite the advancement of existing methods, they face two challenges in practice. First, most of them alternate the planning and execution with a pre-defined pipeline yang2023mm; restgpt, which inevitably constrains their flexibility in handling exceptional errors that frequently occur during a tool-use workflow(shi2024chain; wang2023mint; prasad2023adapt). When failing to invoke tools, it is crucial to enable agents to revise their incorrect actions instead of directly shifting to the next step with the error response of previous steps. Second, it is struggling to adapt a single LLM-based agent to learn a variety of specialized actions in solving a task(dziri2023faith; yin2023lumos). Solving a practical task involves varied actions with substantial differences, _e.g.,_ planning, execution, and reflection, drawing upon different facets of the LLMs shen2024small; qiao2024autoact. Therefore, developing effective agent flow and adapting tool-use models to solve practical tasks remains a challenging research topic.
|
| 38 |
+
|
| 39 |
+
In this work, we propose ConAgents, a Co operative and i n terative Agents framework for tool learning tasks. As illustrated in Figure[1](https://arxiv.org/html/2403.03031v4#S1.F1 "Figure 1 โฃ 1 Introduction โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models"), ConAgents decomposes the overall tool-use workflow using three specialized agents: Grounding, Execution, and Review agents. The grounding agent reasons the task description and grounds it into planning by specifying which tool to use. The execution agent follows the planning to execute the selected tool by generating executable code. The review agent reviews the incorrectness in planning or execution, providing feedback for revision. To enable the dynamic cooperation of these specialized agents, we propose two communication protocols, including automatic and adaptive interaction. In the process of automatic interaction, the review agent provides real-time reviews to calibrate incorrect actions. Thus, the agent flow alternates between the planning-review and execution-review phases as shown in Figure[1](https://arxiv.org/html/2403.03031v4#S1.F1 "Figure 1 โฃ 1 Introduction โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models"). In the process of adaptive interaction, the review agent only provides feedback when exceptional errors are captured while executing the tools.
|
| 40 |
+
|
| 41 |
+
For a comprehensive evaluation, we conduct experiments on two benchmarks, _i.e.,_ ToolBench and RestBench, using various LLMs as backbones. We find that ConAgents outperforms the state-of-the-art baseline with both communication protocols (6% improvement in Success Rate on average).
|
| 42 |
+
|
| 43 |
+
Despite closed-source LLMs performing well with our framework, we find the open-source models may struggle with the modulized agent flow. Thus, we propose an approach called sp ecialized a ction distillatio n (SPAN), enhancing the performance of open-source models in ConAgents. We heuristically sample 2,919 high-quality tasks from the ToolBench toolllm training set, and cluster them based on their similarity, retaining only one task in each cluster to avoid duplication. For each task, we guide the GPT-4 to generate solutions using ConAgents, and reorganize them into actions tailored to specialized agent functionalities in ConAgents. These actions are separately distilled into different student models through instruction tuning. We employ parameter-efficient tuning techniques, _i.e.,_ LoRA hu2021lora, further extending our distillation method into low-resource scenarios. Experiment results show that our distillation method empowers open-source models with strong performance with only 500 training examples.
|
| 44 |
+
|
| 45 |
+
Our contributions are summarized as follows: (1) We propose ConAgents, a cooperative and interactive agents framework, for tool learning tasks. ConAgents coordinates three specialized agents with two communication protocols to solve a complex task. (2) We propose specialized action distillation (SPAN), which more effectively enables open-source models to work with the ConAgents; (3) Both automatic and human evaluation conducted on two benchmarks validate the superiority of ConAgents.
|
| 46 |
+
|
| 47 |
+
2 Related Work
|
| 48 |
+
--------------
|
| 49 |
+
|
| 50 |
+
#### LLMs for tool learning.
|
| 51 |
+
|
| 52 |
+
Enhancing LLMs with external tools has been proven a promising method for solving practical tasks chemcrow; qu2024tool; wang2024tools. Previous works empower a tool-learning agent typically by supervised fine-tuning(patil2023gorilla; gpt4tools; gao2023confucius) or prompt learning(chameleon; huggingfacegpt). Specifically, the former trains LLMs on tool-use dataset self-instruction, teaching LLMs how to use tools from the data. The latter directly demonstrates tool usages to LLM using in-context examples (art; rci). However, solving complex tasks with tools involves various actions, _e.g.,_ deciding which tools to use, what arguments to pass, and how to utilize the results(toolformer; qiao2024autoact). Compelling one single agent to learn all abilities places even greater pressure on it(yin2023lumos; prasad2023adapt). In addition, as the tasks become complex, LLMs-based agents struggle to incorporate lengthy task-solving contexts to predict the next actions correctly due to their limited working memory(pmlr-v202-shi23a). In contrast, our proposed ConAgents coordinates three specialized agents, generating a solution through agent cooperation.
|
| 53 |
+
|
| 54 |
+
#### Multi-agent cooperation.
|
| 55 |
+
|
| 56 |
+
Synergizing multiple agents has demonstrated strong performance on a variety of tasks(liu2023dynamic; sun2023corex; zhang2023agentcf), enhancing the capabilities of individual agents(talebirad2023multi; mohtashami2023social; qian2023communicative). Recent studies take multiple agents into a debate for a fixed number of rounds(wang2023mac; liang2023encouraging), boosting their factuality(cohen2023lm) and reasoning abilities(du2023improving; fu2023improving). In the tool learning tasks, recent work separately implements the task planning and execution with different agents, thereby reducing the workload of a single agent shen2024small; restgpt; qiao2024autoact. Despite their progress, their agent flow is simplified into a pre-defined pipeline(prasad2023adapt), struggling to handle exceptional errors that frequently occur during the tool-use workflows(zhuang2023toolqa; wang2023mint). In our work, we propose two communication protocols, which enable the action calibrations and dynamic cooperation of agents.
|
| 57 |
+
|
| 58 |
+
3 Methodology
|
| 59 |
+
-------------
|
| 60 |
+
|
| 61 |
+

|
| 62 |
+
|
| 63 |
+
Figure 2: Our proposed cooperative and interactive agent framework. The left shows the three specialized agents in our framework (ยง[3.1](https://arxiv.org/html/2403.03031v4#S3.SS1 "3.1 Overall Framework โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")). The right illustrates two proposed communication protocols to coordinate these specialized agents, including the automatic and adaptive communication (ยง[3.3](https://arxiv.org/html/2403.03031v4#S3.SS3 "3.3 Agent communication protocols โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")).
|
| 64 |
+
|
| 65 |
+
### 3.1 Overall Framework
|
| 66 |
+
|
| 67 |
+
Our cooperative framework, ConAgents, is proposed to enable the dynamic cooperation of agents to solve complex tasks. As shown in Figure[2](https://arxiv.org/html/2403.03031v4#S3.F2 "Figure 2 โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models"), ConAgents streamlines and modularizes the workflow of tool learning tasks into a grounding agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT, execution agent โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT, and review agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT. These agents are implemented with different system prompt or learnable parameters. Given a complex task x ๐ฅ x italic_x, the โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT first decomposes x ๐ฅ x italic_x into simpler sub-tasks and generates tool-use planning t ๐ก t italic_t in a step-by-step manner. For each step, the โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT executes the selected tool by writing executable code following the planning t ๐ก t italic_t. The execution result r ๐ r italic_r is then incorporated into the context of the grounding agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT to predict planning in the next iteration. The โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT is employed to simulate an expert to provide feedback to agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT and โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT, guiding them to revise their incorrect planning or execution. To coordinate these three specialized agents, we explore and analyze two communication protocols, including the automatic and adaptive interactions.
|
| 68 |
+
|
| 69 |
+
### 3.2 Specialized Agents
|
| 70 |
+
|
| 71 |
+
#### Grounding Agent.
|
| 72 |
+
|
| 73 |
+
The grounding agent is designed to break down an input task and generate a series of tool-use planing. At i ๐ i italic_i th iteration, the grounding agent generates planning t i subscript ๐ก ๐ t_{i}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT on the condition of the task x ๐ฅ x italic_x and current trajectory โ i={(t j,r j)|j<i}subscript โ ๐ conditional-set subscript ๐ก ๐ subscript ๐ ๐ ๐ ๐\mathcal{H}_{i}=\{(t_{j},r_{j})|j<i\}caligraphic_H start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = { ( italic_t start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT , italic_r start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT ) | italic_j < italic_i }, consisting of the accumulation of previous planning t<i subscript ๐ก absent ๐ t_{<i}italic_t start_POSTSUBSCRIPT < italic_i end_POSTSUBSCRIPT and results r<i subscript ๐ absent ๐ r_{<i}italic_r start_POSTSUBSCRIPT < italic_i end_POSTSUBSCRIPT. It can be formulated as:
|
| 74 |
+
|
| 75 |
+
t i=โณ Gโข(x,๐ฎ,โ i),subscript ๐ก ๐ subscript โณ ๐บ ๐ฅ ๐ฎ subscript โ ๐ t_{i}=\mathcal{M}_{G}(x,\mathcal{S},\mathcal{H}_{i}),italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT ( italic_x , caligraphic_S , caligraphic_H start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ,(1)
|
| 76 |
+
|
| 77 |
+
where t i subscript ๐ก ๐ t_{i}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT contains a tool selected from the provided toolset S ๐ S italic_S and necessary arguments to invoke the tool, such as โโUse the Bing search to find a movie shown on Dec 24, 2023โโ.
|
| 78 |
+
|
| 79 |
+
#### Execution Agent.
|
| 80 |
+
|
| 81 |
+
Following the generated planning t i subscript ๐ก ๐ t_{i}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, the execution agent โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT executes the selected tool by generating executable code c ๐ c italic_c with the assistance of the tool documentation d ๐ d italic_d. This process can be formulated as:
|
| 82 |
+
|
| 83 |
+
c i subscript ๐ ๐\displaystyle c_{i}italic_c start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT=โณ Eโข(d,t i).absent subscript โณ ๐ธ ๐ subscript ๐ก ๐\displaystyle=\mathcal{M}_{E}(d,t_{i}).= caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT ( italic_d , italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) .
|
| 84 |
+
|
| 85 |
+
The execution result r i subscript ๐ ๐ r_{i}italic_r start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is obtained by running the generated code c i subscript ๐ ๐ c_{i}italic_c start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT to request the data from the backend servers of tools, denoted as r i=Executeโข(c i)subscript ๐ ๐ Execute subscript ๐ ๐ r_{i}=\text{Execute}(c_{i})italic_r start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = Execute ( italic_c start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ). When the tool fails to execute, the r i subscript ๐ ๐ r_{i}italic_r start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT indicates an error message as a failure signal. When the tool executes successfully, the result r i subscript ๐ ๐ r_{i}italic_r start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT contains the targeted information in response to the planning t i subscript ๐ก ๐ t_{i}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT.
|
| 86 |
+
|
| 87 |
+
#### Review Agent.
|
| 88 |
+
|
| 89 |
+
Incorrect planning and execution are frequently observed during the tool-use workflow. The review agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT is employed as an expert, providing feedback to agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT and โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT for revision. Specifically, if the planning generated by โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT is vague or selects a non-existing tool, the agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT generates verbal feedback to instruct the โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT to reformulate planning. It can be formulated as:
|
| 90 |
+
|
| 91 |
+
f RโG subscript ๐โ๐
๐บ\displaystyle f_{R\rightarrow G}italic_f start_POSTSUBSCRIPT italic_R โ italic_G end_POSTSUBSCRIPT=M Rโข(x,๐ฎ,t i)absent subscript ๐ ๐
๐ฅ ๐ฎ subscript ๐ก ๐\displaystyle=M_{R}(x,\mathcal{S},t_{i})= italic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT ( italic_x , caligraphic_S , italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT )(2)
|
| 92 |
+
|
| 93 |
+
Similarly, if โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT hallucinates generating a wrong program to execute the tool, the agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT reviews execution results (or errors) and re-checks the tool documentation, providing instructions for calibration:
|
| 94 |
+
|
| 95 |
+
f RโE subscript ๐โ๐
๐ธ\displaystyle f_{R\rightarrow E}italic_f start_POSTSUBSCRIPT italic_R โ italic_E end_POSTSUBSCRIPT=M Rโข(x,d,c i,r i)absent subscript ๐ ๐
๐ฅ ๐ subscript ๐ ๐ subscript ๐ ๐\displaystyle=M_{R}\left(x,d,c_{i},r_{i}\right)= italic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT ( italic_x , italic_d , italic_c start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_r start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT )(3)
|
| 96 |
+
|
| 97 |
+
We denote the maximum turns of interaction between agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT and agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT (or โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT) is denoted as ฮฑ ๐ผ\alpha italic_ฮฑ (or ฮฒ ๐ฝ\beta italic_ฮฒ). Their communication protocol and action flow are explained in ยง[3.3](https://arxiv.org/html/2403.03031v4#S3.SS3 "3.3 Agent communication protocols โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models").
|
| 98 |
+
|
| 99 |
+
### 3.3 Agent communication protocols
|
| 100 |
+
|
| 101 |
+
We propose two agent communication protocols, including automatic and adaptive interaction.
|
| 102 |
+
|
| 103 |
+
#### Automatic interaction.
|
| 104 |
+
|
| 105 |
+
As illustrated in Figure[2](https://arxiv.org/html/2403.03031v4#S3.F2 "Figure 2 โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models"), our automatic interaction alternates between planning-review and execution-review phases. For the i ๐ i italic_i th step, it starts with the interaction between the agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT and โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT until a correct planning t i subscript ๐ก ๐ t_{i}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is determined or up to the maximum turns ฮฑ ๐ผ\alpha italic_ฮฑ. Formally, it can be formulated as:
|
| 106 |
+
|
| 107 |
+
t i j superscript subscript ๐ก ๐ ๐\displaystyle t_{i}^{j}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT=M Gโข(x,๐ฎ,โ i,{t i<j,f RโG<j}โplanning calibration)absent subscript ๐ ๐บ ๐ฅ ๐ฎ subscript โ ๐ subscriptโsuperscript subscript ๐ก ๐ absent ๐ superscript subscript ๐โ๐
๐บ absent ๐ planning calibration\displaystyle=M_{G}(x,\mathcal{S},\mathcal{H}_{i},\underbrace{\{t_{i}^{<j},f_{% R\rightarrow G}^{<j}\}}_{\text{planning calibration}})= italic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT ( italic_x , caligraphic_S , caligraphic_H start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , underโ start_ARG { italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT < italic_j end_POSTSUPERSCRIPT , italic_f start_POSTSUBSCRIPT italic_R โ italic_G end_POSTSUBSCRIPT start_POSTSUPERSCRIPT < italic_j end_POSTSUPERSCRIPT } end_ARG start_POSTSUBSCRIPT planning calibration end_POSTSUBSCRIPT )(4)
|
| 108 |
+
|
| 109 |
+
Here, j ๐ j italic_j indicates j ๐ j italic_j th interaction of two agents. Following the planning t ๐ก t italic_t, the agent โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT generates executable programs to execute the selected tool and calibrates the incorrect result r ๐ r italic_r with the feedback of agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT for up to ฮฒ ๐ฝ\beta italic_ฮฒ turns. This process can be formulated as:
|
| 110 |
+
|
| 111 |
+
c i j superscript subscript ๐ ๐ ๐\displaystyle c_{i}^{j}italic_c start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT=โณ Eโข(t i,d,{c i<j,f RโE<j}โexecution calibration)absent subscript โณ ๐ธ subscript ๐ก ๐ ๐ subscriptโsuperscript subscript ๐ ๐ absent ๐ superscript subscript ๐โ๐
๐ธ absent ๐ execution calibration\displaystyle=\mathcal{M}_{E}(t_{i},d,\underbrace{\{c_{i}^{<j},f_{R\rightarrow E% }^{<j}\}}_{\text{execution calibration}})= caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT ( italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_d , underโ start_ARG { italic_c start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT < italic_j end_POSTSUPERSCRIPT , italic_f start_POSTSUBSCRIPT italic_R โ italic_E end_POSTSUBSCRIPT start_POSTSUPERSCRIPT < italic_j end_POSTSUPERSCRIPT } end_ARG start_POSTSUBSCRIPT execution calibration end_POSTSUBSCRIPT )(5)
|
| 112 |
+
|
| 113 |
+
The calibrated result is then incorporated into the context of โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT for the next planning generation.
|
| 114 |
+
|
| 115 |
+
#### Adaptive interaction.
|
| 116 |
+
|
| 117 |
+
In our adaptive interaction strategy, the agent flow primarily alternates from (1) generating tool-use planning by agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT and (2) generating execution code by agent โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT, in a step-by-step manner. The review agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT is adaptively triggered to provide feedback only when the generated code fails to execute correctly. Specifically, a runtime error can be caused by either unfeasible planning or coding faulty. Thus, the agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT first reviews the generated planning and code, routines the errors to agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT or โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT accordingly, and provides feedback for revision.
|
| 118 |
+
|
| 119 |
+
4 Specialization by Agent Distillation
|
| 120 |
+
--------------------------------------
|
| 121 |
+
|
| 122 |
+
Our initial experiment shows that powerful LLMs such as GPT-4, achieve promising results when equipped with our framework. However, these model are often considered black boxes(webcpm; gao2023confucius) with potential privacy issues. Thus, we aim to adapt our framework to open-source models. We propose specialized action distillation (SPAN), which distills the task-solving trajectory of powerful commercial LLMs into different open-source LLM agents tailored to specific functionalities in ConAgents.
|
| 123 |
+
|
| 124 |
+
### 4.1 Synthesize the Training Dataset
|
| 125 |
+
|
| 126 |
+
Our distillation method collects the task-solving trajectory of specialized agents simulated by GPT-4, in ConAgents (ยง[3.1](https://arxiv.org/html/2403.03031v4#S3.SS1 "3.1 Overall Framework โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")). To achieve this, we first sample tasks from ToolBench toolllm, which contains nearly 200k practical tasks across 3,451 tools. We select 2,919 tasks using various heuristic strategies (see Appendix LABEL:sec:app:filter for more details). Each task x ๐ฅ x italic_x is paired with a list of relevant tools. Since we find that some tasks in ToolBench are very similar to each other, we cluster them based on the semantic similarities between task descriptions and retain one instance for each cluster. Next, we supplement each of these selected tasks with a detailed solution. Specifically, we separately implement our grounding, execution, and review agent with GPT-4, and coordinate them using the proposed automatic communication protocol (ยง[3.3](https://arxiv.org/html/2403.03031v4#S3.SS3.SSS0.Px1 "Automatic interaction. โฃ 3.3 Agent communication protocols โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")) to generate solutions. Finally, we synthesize a dataset with 500 diverse examples. Each example contains a task x ๐ฅ x italic_x, a candidate toolset ๐ฎ ๐ฎ\mathcal{S}caligraphic_S, and the task-solving trajectory of three agents. The statistics of our synthetic dataset are provided in Table[1](https://arxiv.org/html/2403.03031v4#S4.T1 "Table 1 โฃ 4.1 Synthesize the Training Dataset โฃ 4 Specialization by Agent Distillation โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models").
|
| 127 |
+
|
| 128 |
+
Statistic# The data scale 500# The average tokens of input task 52.48# The average number of candidate tools 20# The average number of ground truth tools per task 3.39# The average turns of planning-review interaction 4.62# The average turns of execution-review interaction 5.21
|
| 129 |
+
|
| 130 |
+
Table 1: The statistics of our synthetic dataset in our specialized action distillation method.
|
| 131 |
+
|
| 132 |
+
### 4.2 Agent Training
|
| 133 |
+
|
| 134 |
+
Due to the large number of parameters of the LLM, we employ a parameter-efficient tuning technique (_i.e.,_ LoRa(hu2021lora)) to train each specialized agent separately. The objective is to optimize the delta parameters ฮโขฮธ ฮ ๐\Delta\theta roman_ฮ italic_ฮธ of the LLM ฮธ ๐\theta italic_ฮธ to minimize the loss function.
|
| 135 |
+
|
| 136 |
+
We reorganize the dataset according to the agentsโ functionality (ยง[3.1](https://arxiv.org/html/2403.03031v4#S3.SS1 "3.1 Overall Framework โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")), thereby distilling specific abilities into different student models. Formally, given a task x ๐ฅ x italic_x, in the i ๐ i italic_i th step, the โ i subscript โ ๐\mathcal{H}_{i}caligraphic_H start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT contains historical planning and execution results. We train the agent โณ G subscript โณ ๐บ\mathcal{M}_{G}caligraphic_M start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT to generate the i ๐ i italic_i th tool-use planning t i subscript ๐ก ๐ t_{i}italic_t start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT on the condition of H i subscript ๐ป ๐ H_{i}italic_H start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT and revise its incorrect planning following the review from agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT ( ). We train the agent โณ E subscript โณ ๐ธ\mathcal{M}_{E}caligraphic_M start_POSTSUBSCRIPT italic_E end_POSTSUBSCRIPT to generate programs c ๐ c italic_c for tool execution following the generated planning t ๐ก t italic_t and feedback of agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT ( ). Similarly, the agent โณ R subscript โณ ๐
\mathcal{M}_{R}caligraphic_M start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT are trained to provide feedback as . We apply the standard language modeling loss for the optimization. More details and formulations can be found in Appendix LABEL:sec:app:distillation.
|
| 137 |
+
|
| 138 |
+
5 Experimental Setup
|
| 139 |
+
--------------------
|
| 140 |
+
|
| 141 |
+
Method RestBench-TMDB RestBench-Spotify ToolBench
|
| 142 |
+
Success Rate Path%Success Rate Path%Success Rate Path%
|
| 143 |
+
gpt-3.5-turbo
|
| 144 |
+
\faUser ReAct(react)40.00 71.19 51.28 60.35 39.39 65.04
|
| 145 |
+
\faUser Chameleon(chameleon)63.00 66.10 56.20 64.55 37.44 67.55
|
| 146 |
+
\faUser CodeAct(wang2024executable)63.00 80.91 54.30 76.64โโ
|
| 147 |
+
\faUser ToolLLM(DFSDT, toolllm)68.00 76.77 61.40 74.77 66.39 86.43
|
| 148 |
+
\faUsers Reflexion(reflexion)53.00 55.00 49.10 50.90โโ
|
| 149 |
+
\faUsers ฮฑ ๐ผ\alpha italic_ฮฑ-UMi(shen2024small)62.00 70.23 66.74 70.27 67.55 78.37
|
| 150 |
+
\faUsers RestGPT(restgpt)65.00 69.21 67.10 70.75 63.88 77.40
|
| 151 |
+
\faUsers ConAgents w/ Ada 78.00 79.57 69.43 77.54 69.84 81.58
|
| 152 |
+
\faUsers ConAgents w/ Auto 79.00 81.97 71.21 79.17 72.15 83.33
|
| 153 |
+
\faUser ReAct@N โN=2โabsent N 2\rightarrow\text{N}=2โ N = 2 54.00 67.90 56.71 59.47 41.41 63.67
|
| 154 |
+
\faUser ReAct@N โN=3โabsent N 3\rightarrow\text{N}=3โ N = 3 62.00 65.40 58.13 63.26 42.67 66.12
|
| 155 |
+
\faUser ToolLLM@N โN=2โabsent N 2\rightarrow\text{N}=2โ N = 2 70.00 76.54 63.16 75.27 68.37 86.43
|
| 156 |
+
\faUser ToolLLM@N โN=3โabsent N 3\rightarrow\text{N}=3โ N = 3 71.00 78.11 63.16 76.30 68.77 87.54
|
| 157 |
+
|
| 158 |
+
Table 2: The results on three datasets. The metrics Success% and Path% indicate the Success Rate and Correct Path Rate, respectively. The icon \faUser denotes the single-agent method and \faUsers symbolizes multi-agent architecture.
|
| 159 |
+
|
| 160 |
+
### 5.1 Datasets and Evaluation Metrics
|
| 161 |
+
|
| 162 |
+
Datasets. We conduct experiments on two well established benchmarks, _i.e.,_ RestBench(restgpt) and Toolbench(toolllm). The RestBench consists of two subsets, including: (1) TMDB, a high-quality human annotated dataset consisting of 54 movie-related tools; and (2) Spotify, a dataset with 40 music-related tools. The Toolbench contains various practical tasks across diverse scenarios. We provide more details for these datasets in Appendix LABEL:sec:app:dataset.
|
| 163 |
+
|
| 164 |
+
Evaluation metrics. Following gpt4tools; gao2023confucius, we use two evaluation metrics: (1) Success Rate (Success%) measuring the proportion of successful query completions, and (2) Correct Path Rate (Path%) calculating the F1 score between the generated tool sequence and ground-truth tool sequence. We also conduct a human evaluation, in which three well-educated volunteers are invited to evaluate 30 randomly sampled cases with a three-scale rating in two aspects: (1) Executability (Exec): whether multiple tools are invoked in a correct logical order; and (2) Utility: whether the execution results of tools can be used to generate an answer.
|
| 165 |
+
|
| 166 |
+
### 5.2 Baselines
|
| 167 |
+
|
| 168 |
+
We compare our method with agent-based tool learning methods, including: (1) Chameleon(chameleon), an LLM-based agent that directly generates multi-step plans for tool use and then sequentially executes the plan; (2) ReAct react, which prompts LLM to generate the chain-of-thought and actions in an interleaved manner.; (3) CodeAct wang2024executable, which allows the LLM to generate executable code snippets as actions to use tools; (4) ToolLLM(DFSDT, toolllm), which enhances LLMs with the Depth First Search-based Decision Tree (DFSDT) to select tools to solve a task. For further comparison, Since our ConAgents coordinates three specialized agents, we also establish two baselines, _i.e.,_ ReAct@N and ToolLLM@N, which are up to N times runs of their vanilla method (ReAct or ToolLLM) until an input task is completed.
|
| 169 |
+
|
| 170 |
+
We also consider baselines with multi-agent architecture, including (1) RestGPT(restgpt): which consists of a planning module, a tool selector, an executor, and a response parsing module; (2) Reflexion reflexion, which employs an LLM for task execution and uses another LLM to verbally reflect on task feedback signals; and (3) ฮฑ ๐ผ\alpha italic_ฮฑ-UMi shen2024small, which consists of a planner, an executor, and an answer generator.
|
| 171 |
+
|
| 172 |
+
Method TMDB Spotify Success%Path%Success%Path%\faUsers ConAgents (Mixtral-8x7B)w/ Auto (Distilled)53.00 79.32 36.09 73.92 w/ Auto (Vanilla)49.00 76.22 34.21 68.14 w/ Ada (Distilled)51.00 78.74 35.47 69.86 w/ Ada (Vanilla)47.00 74.05 33.33 66.41 Baselines (Mixtral-8x7B)\faUser ReAct 26.00 61.21 21.35 47.21\faUser ReAct@3 33.00 63.27 26.93 50.31\faUser ToolLLM 37.00 64.32 28.07 52.31\faUser ToolLLM@3 45.00 74.40 31.58 57.68\faUsers RestGPT 34.00 72.20 31.58 67.82
|
| 173 |
+
|
| 174 |
+
Table 3: We employ the Mixtral-8x7B as the backbone LLM of for our method and baselines. The Vanilla and Distilled indicate enable our framework by prompting and our action distillation, respectively.
|
| 175 |
+
|
| 176 |
+
### 5.3 Implementation Details
|
| 177 |
+
|
| 178 |
+
We use gpt-3.5-turbo 1 1 1[https://openai.com/chatgpt](https://openai.com/chatgpt) from OpenAI as the LLM backbone for each agent in our method and all baselines. We instruct the three agents to perform specific actions with different system prompts. The decoding temperature is set to 0 for the most deterministic generation. We also repeat the experiment with an open-source model Mistral-8x7B 2 2 2[https://huggingface.co/mistralai](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1) for further comparison. In our agent communication (ยง[3.3](https://arxiv.org/html/2403.03031v4#S3.SS3 "3.3 Agent communication protocols โฃ 3 Methodology โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models")), we set the maximum iteration of interactions ฮฑ=3 ๐ผ 3\alpha=3 italic_ฮฑ = 3 and ฮฒ=3 ๐ฝ 3\beta=3 italic_ฮฒ = 3, respectively. For each sample in the test set, we provide all the baselines with the same candidate toolset for a fair comparison, which contains the required tools and ten randomly sampled tools.
|
| 179 |
+
|
| 180 |
+
Our action distillation separately trains three Mistral-8x7B using the corresponding optimization objectives in ยง[4.2](https://arxiv.org/html/2403.03031v4#S4.SS2 "4.2 Agent Training โฃ 4 Specialization by Agent Distillation โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models") with the learning rate of 5ร10โ5 5 superscript 10 5 5\times 10^{-5}5 ร 10 start_POSTSUPERSCRIPT - 5 end_POSTSUPERSCRIPT. The training of our model can be done within 4 hours with 3 NVIDIA A800-PCIE-80GB GPUs using LoRA hu2021lora.
|
| 181 |
+
|
| 182 |
+
6 Results and Analysis
|
| 183 |
+
----------------------
|
| 184 |
+
|
| 185 |
+
### 6.1 Experimental Results
|
| 186 |
+
|
| 187 |
+
#### Overall performance.
|
| 188 |
+
|
| 189 |
+
Table[2](https://arxiv.org/html/2403.03031v4#S5.T2 "Table 2 โฃ 5 Experimental Setup โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models") demonstrates the experimental performances of all methods. We find that our proposed ConAgents outperforms all the baselines in three datasets in terms of all metrics. A reason here is that our cooperative framework design enables each agent to perform specialized actions instead of grasping all required capabilities, thereby reducing the workload encountered by a single agent. The significant improvement over ReAct@N and ToolLLM@N baselines can further validate the effectiveness of our framework. Compared with baselines with multi-agent architecture like RestGPT, ConAgents achieves about 12% higher Success Rate. The potential reason for our improvement is that the proposed two communication protocols enable the dynamic interaction of agents, which is more flexible to handle exception errors.
|
| 190 |
+
|
| 191 |
+
#### Performance with the open-source LLM.
|
| 192 |
+
|
| 193 |
+
We further evaluate our ConAgents by swapping the backbone LLM with Mistral-8x7B and repeating the experiment under the same conditions. As shown in Table[3](https://arxiv.org/html/2403.03031v4#S5.T3 "Table 3 โฃ 5.2 Baselines โฃ 5 Experimental Setup โฃ Learning to Use Tools via Cooperative and Interactive Agents with Large Language Models"), we implement our framework in two ways with Mistral-8x7B: (1) directly prompting (w/ Auto and w/ Ada); (2) tuning with our proposed action distillation (w/ Autoโ and w/ Adaโ ). We observe that directly prompting Mistral-8x7B with ConAgents yields better performance than baselines. The action distillation further improves overall performance substantially, such as pushing the Success Rate from 47.00 to 51.00 in the TMDB dataset. These results further prove the effectiveness of our cooperative framework.
|
| 194 |
+
|
| 195 |
+
### 6.2 Human Evaluation
|
| 196 |
+
|
| 197 |
+
Table LABEL:tab:human shows the results of the human evaluation. We find that ConAgents achieves the best results in the Executability aspect with 0.08~0.12 improvement. These results further validate the necessity of agent specialization and cooperation. The overall Kappa statistics for Executability and Utility are 0.75 0.75 0.75 0.75 and 0.71 0.71 0.71 0.71, illustrating substantial agreement landis1977measurement among the annotators.
|