RestGPT: Connecting Large Language Models with Real-World RESTful APIs
Yifan Song1, Weimin Xiong1, Dawei Zhu1, Wenhao Wu1, Han Qian2, Mingbo Song2 Hailiang Huang2, Cheng Li3, Ke Wang3, Rong Yao3, Ye Tian3, Sujian Li1111Corresponding author. 1School of Computer Science, Peking University 2School of Electronics Engineering and Computer Science, Peking University 3Huawei Technologies {yfsong, https://restgpt.github.io
Abstract
Tool-augmented large language models (LLMs) have achieved remarkable progress in tackling a broad range of tasks. However, existing methods are mainly restricted to specifically designed tools and fail to fulfill complex instructions, having great limitations when confronted with real-world scenarios. In this paper, we explore a more realistic scenario by connecting LLMs with RESTful APIs, which adhere to the widely adopted REST software architectural style for web service development. To address the practical challenges of tackling complex instructions, we propose RestGPT, which exploits the power of LLMs and conducts a coarse-to-fine online planning mechanism to enhance the abilities of task decomposition and API selection. RestGPT also contains an API executor tailored for calling RESTful APIs, which can meticulously formulate parameters and parse API responses. To fully evaluate the performance of RestGPT, we propose RestBench, a high-quality benchmark which consists of two real-world scenarios and human-annotated instructions with gold solution paths. Experiments show that RestGPT is able to achieve impressive results in complex tasks and has strong robustness, which paves a n
中文速览
让大语言模型(LLM)真正用上互联网上数以百万计的真实 RESTful API,是一件比调用几个预设工具难得多的事——现有方法只能连接十几个专门定制的 API,遇到复杂指令时规划能力也严重不足。为此,作者提出了 RestGPT 框架,核心思路是让 Planner、API Selector、Executor 三个模块分工协作:Planner 把用户指令拆解成自然语言子任务,API Selector 再把子任务细化映射到具体的 API 调用序列,Executor 则负责拼装参数、发起真实 HTTP 请求,并用 LLM 生成 Python 代码来解析结构复杂的 JSON 响应——这种"粗到细的在线规划"机制让框架能根据每次 API 返回的结果动态调整后续计划。为了客观评估,作者还构建了 RestBench 基准,包含 TMDB 电影数据库和 Spotify 音乐播放器两个真实场景、人工标注的复杂指令及标准解题路径,实验结果表明 RestGPT 在任务规划、API 理解和响应解析三个维度上均明显优于现有方法。这项工作首次打通了 LLM 与任意符合 OpenAPI 规范的 RESTful 应用之间的标准化通道,为 LLM 走向真实世界复杂任务提供了一条可扩展的新路径。
原文 arXiv:2306.06624;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2306.06624v2