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调用)能够显著提升其性能,但由于不同API之间存在复杂关联,函数调用仍是一项具有挑战性的任务,尤其是在无需微调的上下文学习场景中。本文提出一种简单且可控的目标驱动型方法——反向链,仅通过提示词即可赋予大语言模型使用外部API的能力。针对多数开源大语言模型工具使用或规划能力有限的现状,反向链仅让模型执行简单任务(如API选择与参数补全),并通过通用规则实现可控的多函数调用。该通用规则的具体流程为:首先由大语言模型选定处理当前任务的最终API,随后引导其根据用户查询与上下文填充所需参数。对于缺失参数,则通过让模型基于API描述选择另一API进行补全,此过程迭代直至任务完成。大量数值实验表明,反向链在多函数调用方面展现出卓越能力。有趣的是,实验还揭示现有大语言模型(如ChatGPT)的工具使用能力可通过反向链得到显著提升。