ToolLLM: Facilitando que los Modelos de Lenguaje de Gran Escala Dominen más de 16,000 APIs del Mundo Real
ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIs
July 31, 2023
Autores: Yujia Qin, Shihao Liang, Yining Ye, Kunlun Zhu, Lan Yan, Yaxi Lu, Yankai Lin, Xin Cong, Xiangru Tang, Bill Qian, Sihan Zhao, Runchu Tian, Ruobing Xie, Jie Zhou, Mark Gerstein, Dahai Li, Zhiyuan Liu, Maosong Sun
cs.AI
Resumen
A pesar de los avances de los modelos de lenguaje de gran escala (LLMs) de código abierto y sus variantes, como LLaMA y Vicuna, siguen siendo significativamente limitados en la realización de tareas de mayor nivel, como seguir instrucciones humanas para utilizar herramientas externas (APIs). Esto se debe a que el ajuste por instrucción actual se centra principalmente en tareas lingüísticas básicas en lugar del dominio de uso de herramientas. Esto contrasta con los LLMs de última generación (SOTA), como ChatGPT, que han demostrado excelentes capacidades de uso de herramientas pero que, lamentablemente, son de código cerrado. Para facilitar las capacidades de uso de herramientas en LLMs de código abierto, presentamos ToolLLM, un marco general de uso de herramientas que abarca la construcción de datos, el entrenamiento del modelo y la evaluación. Primero presentamos ToolBench, un conjunto de datos de ajuste por instrucción para el uso de herramientas, creado automáticamente utilizando ChatGPT. Específicamente, recopilamos 16,464 APIs RESTful del mundo real que abarcan 49 categorías de RapidAPI Hub, luego solicitamos a ChatGPT que genere diversas instrucciones humanas que involucren estas APIs, cubriendo tanto escenarios de una sola herramienta como de múltiples herramientas. Finalmente, utilizamos ChatGPT para buscar una ruta de solución válida (cadena de llamadas API) para cada instrucción. Para hacer el proceso de búsqueda más eficiente, desarrollamos un novedoso árbol de decisiones basado en búsqueda en profundidad (DFSDT), que permite a los LLMs evaluar múltiples trazas de razonamiento y expandir el espacio de búsqueda. Demostramos que DFSDT mejora significativamente las capacidades de planificación y razonamiento de los LLMs. Para una evaluación eficiente del uso de herramientas, desarrollamos un evaluador automático: ToolEval. Ajustamos LLaMA en ToolBench y obtenemos ToolLLaMA. Nuestro ToolEval revela que ToolLLaMA demuestra una capacidad notable para ejecutar instrucciones complejas y generalizar a APIs no vistas, y exhibe un rendimiento comparable al de ChatGPT. Para hacer la canalización más práctica, diseñamos un recuperador de APIs neuronal para recomendar APIs apropiadas para cada instrucción, eliminando la necesidad de selección manual de APIs.
English
Despite the advancements of open-source large language models (LLMs) and
their variants, e.g., LLaMA and Vicuna, they remain significantly limited in
performing higher-level tasks, such as following human instructions to use
external tools (APIs). This is because current instruction tuning largely
focuses on basic language tasks instead of the tool-use domain. This is in
contrast to state-of-the-art (SOTA) LLMs, e.g., ChatGPT, which have
demonstrated excellent tool-use capabilities but are unfortunately closed
source. To facilitate tool-use capabilities within open-source LLMs, we
introduce ToolLLM, a general tool-use framework of data construction, model
training and evaluation. We first present ToolBench, an instruction-tuning
dataset for tool use, which is created automatically using ChatGPT.
Specifically, we collect 16,464 real-world RESTful APIs spanning 49 categories
from RapidAPI Hub, then prompt ChatGPT to generate diverse human instructions
involving these APIs, covering both single-tool and multi-tool scenarios.
Finally, we use ChatGPT to search for a valid solution path (chain of API
calls) for each instruction. To make the searching process more efficient, we
develop a novel depth-first search-based decision tree (DFSDT), enabling LLMs
to evaluate multiple reasoning traces and expand the search space. We show that
DFSDT significantly enhances the planning and reasoning capabilities of LLMs.
For efficient tool-use assessment, we develop an automatic evaluator: ToolEval.
We fine-tune LLaMA on ToolBench and obtain ToolLLaMA. Our ToolEval reveals that
ToolLLaMA demonstrates a remarkable ability to execute complex instructions and
generalize to unseen APIs, and exhibits comparable performance to ChatGPT. To
make the pipeline more practical, we devise a neural API retriever to recommend
appropriate APIs for each instruction, negating the need for manual API
selection.