While enabling large language models to implement function calling (known as APIs) can greatly enhance the performance of LLMs, function calling is still a challenging task due to the complicated relations between different APIs, especially in a context-learning setting without fine-tuning. This paper proposes a simple yet controllable target-driven approach called Reverse Chain to empower LLMs with capabilities to use external APIs with only prompts. Given that most open-source LLMs have limited tool-use or tool-plan capabilities, LLMs in Reverse Chain are only employed to implement simple tasks, e.g., API selection and argument completion, and a generic rule is employed to implement a controllable multiple functions calling. In this generic rule, after selecting a final API to handle a given task via LLMs, we first ask LLMs to fill the required arguments from user query and context. Some missing arguments could be further completed by letting LLMs select another API based on API description before asking user. This process continues until a given task is completed. Extensive numerical experiments indicate an impressive capability of Reverse Chain on implementing multiple function calling. Interestingly enough, the experiments also reveal that tool-use capabilities of the existing LLMs, e.g., ChatGPT, can be greatly improved via Reverse Chain.
翻译:尽管使大型语言模型能够实现函数调用(即API)可显著提升LLM的性能,但由于不同API之间的复杂关联,函数调用仍是一项具有挑战性的任务,尤其在无需微调的上下文学习场景中。本文提出一种名为反向链的简单且可控的目标驱动方法,通过仅使用提示词赋予LLM调用外部API的能力。考虑到多数开源LLM在工具使用或工具规划方面能力有限,反向链中的LLM仅用于执行简单任务(如API选择与参数补全),并通过通用规则实现可控的多函数调用。在该通用规则下,首先通过LLM选择处理给定任务的最终API,接着要求LLM从用户查询和上下文中填充所需参数。当遇到缺失参数时,可进一步让LLM基于API描述选择另一个API来补全参数,此过程持续至任务完成。大量数值实验表明,反向链在实现多函数调用方面具有卓越能力。有趣的是,实验还揭示现有LLM(如ChatGPT)的工具使用能力可通过反向链得到显著提升。