Octopus: On-device language model for function calling of software APIs

Authors: Wei Chen, Zhiyuan Li, Mingyuan Ma

Submitted to arXiv on 02 Apr. 2024
License: CC BY-NC-SA 4.0
Abstract

In the rapidly evolving domain of artificial intelligence, Large Language Models (LLMs) play a crucial role due to their advanced text processing and generation abilities. This study introduces a new strategy aimed at harnessing on-device LLMs in invoking software APIs. We meticulously compile a dataset derived from software API documentation and apply fine-tuning to LLMs with capacities of 2B, 3B and 7B parameters, specifically to enhance their proficiency in software API interactions. Our approach concentrates on refining the models' grasp of API structures and syntax, significantly enhancing the accuracy of API function calls. Additionally, we propose \textit{conditional masking} techniques to ensure outputs in the desired formats and reduce error rates while maintaining inference speeds. We also propose a novel benchmark designed to evaluate the effectiveness of LLMs in API interactions, establishing a foundation for subsequent research. Octopus, the fine-tuned model, is proved to have better performance than GPT-4 for the software APIs calling. This research aims to advance automated software development and API integration, representing substantial progress in aligning LLM capabilities with the demands of practical software engineering applications.

The papers around it, by date and closeness

Higher is closer to this paper; left is older. Lines join papers close to each other: groups of lines are sub-topics. Select a point to see why it is there. Back to the summary of this paper

How to read this map? Illustrated guide

Closest papers Prior work it builds on Papers that cite it

Papers around this one

Ranked by how close their title and abstract are to this paper’s. Select some to read them together.

Closest papers

  1. Very close Builds on this paper
    Octopus v2: On-device language model for super agent
    Wei Chen, Zhiyuan Li · 2024 · Computation and Language · preprint, not peer reviewed · cited 51 times · AI summary available

    Octopus v2 develops an on-device 2-billion-parameter model for function calling, extending Octopus’s focus on accurate API calls with improved latency and context length.

    Abstract

    Language models have shown effectiveness in a variety of software applications, particularly in tasks related to automatic workflow. These models possess the crucial ability to call functions, which is essential in creating AI agents. Despite the high performance of large-scale language models in cloud environments, they are often associated with concerns over privacy and cost. Current on-device models for function calling face issues with latency and accuracy. Our research presents a new method that empowers an on-device model with 2 billion parameters to surpass the performance of GPT-4 in both accuracy and latency, and decrease the context length by 95\%. When compared to Llama-7B with a …

  2. Very close Groundwork for this paper Cited by this paper
    API-Bank: A Benchmark for Tool-Augmented LLMs
    Minghao Li, Feifan Song, Bowen Yu et al. · 2023 · Computation and Language · cited 762 times · AI summary available

    API-Bank provides an annotated tool-use benchmark for evaluating API calls, while Octopus introduces a benchmark for software API interactions.

    Abstract

    Recent research has shown that Large Language Models (LLMs) can utilize external tools to improve their contextual processing abilities, moving away from the pure language modeling paradigm and paving the way for Artificial General Intelligence. Despite this, there has been a lack of systematic evaluation to demonstrate the efficacy of LLMs using tools to respond to human instructions. This paper presents API-Bank, the first benchmark tailored for Tool-Augmented LLMs. API-Bank includes 53 commonly used API tools, a complete Tool-Augmented LLM workflow, and 264 annotated dialogues that encompass a total of 568 API calls. These resources have been designed to thoroughly evaluate LLMs' ability …

  3. Very close Builds on this paper Cites this paper
    Octopus v4: Graph of language models
    Wei Chen, Zhi-Yuan Li · 2024 · arXiv.org · preprint, not peer reviewed · cited 15 times · Not summarized yet

    Octopus v4 uses functional tokens to combine task-specific language models, citing Octopus’s work on on-device API calling.

    Abstract

    Language models have been effective in a wide range of applications, yet the most sophisticated models are often proprietary. For example, GPT-4 by OpenAI and various models by Anthropic are expensive and consume substantial energy. In contrast, the open-source community has produced competitive models, like Llama3. Furthermore, niche-specific smaller language models, such as those tailored for legal, medical or financial tasks, have outperformed their proprietary counterparts. This paper introduces a novel approach that employs functional tokens to integrate multiple open-source models, each optimized for particular tasks. Our newly developed Octopus v4 model leverages functional tokens to …

  4. Very close Another approach to the problem
    Gorilla: Large Language Model Connected with Massive APIs
    Shishir G. Patil, Tianjun Zhang, Xin Wang et al. · 2023 · Computation and Language · cited 1,827 times · AI summary available

    Gorilla fine-tunes a LLaMA-based model to generate API calls, addressing the same API-calling problem as Octopus with a different model and approach.

    Abstract

    Large Language Models (LLMs) have seen an impressive wave of advances recently, with models now excelling in a variety of tasks, such as mathematical reasoning and program synthesis. However, their potential to effectively use tools via API calls remains unfulfilled. This is a challenging task even for today's state-of-the-art LLMs such as GPT-4, largely due to their inability to generate accurate input arguments and their tendency to hallucinate the wrong usage of an API call. We release Gorilla, a finetuned LLaMA-based model that surpasses the performance of GPT-4 on writing API calls. When combined with a document retriever, Gorilla demonstrates a strong capability to adapt to test-time d…

  5. Very close Another approach to the problem
    Harnessing LLMs for API Interactions: A Framework for Classification and Synthetic Data Generation
    Chunliang Tao, Xiaojing Fan, Yahe Yang · 2024 · 2024 5th International Conference on Computers and Artificial Intelligence Technology (CAIT) · cited 29 times · Not summarized yet

    Harnessing LLMs classifies natural-language commands into API calls and generates evaluation data, whereas Octopus fine-tunes on-device models for software API calling.

    Abstract

    As Large Language Models (LLMs) advance in natural language processing, there is growing interest in leveraging their capabilities to simplify software interactions. In this paper, we propose a novel framework that integrates LLMs for both classifying natural language inputs into corresponding API calls and automating the creation of sample datasets tailored to specific API functions. By classifying natural language commands, our work allows users to invoke complex software functionalities through simple inputs, improving interaction efficiency and lowering the barrier to software utilization. Our dataset generation approach also enables the efficient and systematic evaluation of different L…

  6. Close Another approach to the problem Cited by this paper
    TPTU-v2: Boosting Task Planning and Tool Usage of Large Language Model-based Agents in Real-world Systems
    Yilun Kong, Jingqing Ruan, Yihong Chen et al. · 2023 · Artificial Intelligence · preprint, not peer reviewed · cited 56 times · Not summarized yet

    TPTU-v2 tackles API selection and ordering for complex real-world tasks, while Octopus focuses on accurate on-device software API calls.

    Abstract

    Large Language Models (LLMs) have demonstrated proficiency in addressing tasks that necessitate a combination of task planning and the usage of external tools that require a blend of task planning and the utilization of external tools, such as APIs. However, real-world complex systems present three prevalent challenges concerning task planning and tool usage: (1) The real system usually has a vast array of APIs, so it is impossible to feed the descriptions of all APIs to the prompt of LLMs as the token length is limited; (2) the real system is designed for handling complex tasks, and the base LLMs can hardly plan a correct sub-task order and API-calling order for such tasks; (3) Similar sema…

  7. Close Another approach to the problem
    ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIs
    Yujia Qin, Shihao Liang, Yining Ye et al. · 2023 · Artificial Intelligence · cited 2,564 times · Not summarized yet

    ToolLLM trains and evaluates models for using thousands of real-world APIs, while Octopus targets fine-tuned on-device models for software API calling.

    Abstract

    Despite the advancements of open-source large language models (LLMs), e.g., LLaMA, they remain significantly limited in tool-use capabilities, i.e., using external tools (APIs) to fulfill human instructions. The reason is that current instruction tuning largely focuses on basic language tasks but ignores the tool-use domain. This is in contrast to the excellent tool-use capabilities of state-of-the-art (SOTA) closed-source LLMs, e.g., ChatGPT. To bridge this gap, we introduce ToolLLM, a general tool-use framework encompassing data construction, model training, and evaluation. We first present ToolBench, an instruction-tuning dataset for tool use, which is constructed automatically using Chat…

  8. Close Broader context
    Measuring an LLM's Proficiency at using APIs: A Query Generation Strategy
    Ying Sheng, Sudeep Gandhe, Bhargav Kanagal et al. · 2024 · Knowledge Discovery and Data Mining · cited 11 times · Not summarized yet

    Measuring API proficiency proposes query generation for evaluating API use, related to Octopus’s benchmark for software API interactions.

    Abstract

    Connecting Large Language Models (LLMs) with the ability to leverage APIs (Web Search, Charting, Calculators, Calendar, Flight Search, Hotel Search, Data Lookup, etc. ) is likely to allow us to solve a variety of new hard problems. Several research efforts have made this observation and suggested recipes for LLMs to emit API calls, and proposed mechanisms by which they can generate additional text conditioned on the output for the API call. However, in practice, the focus has been on relatively simple slot-filling tasks that make an API call rather unlocking novel capabilities by combining different tools, reasoning over the response from a tool, making multiple invocations, or complex plann…

Prior work it builds on

  1. Close Review Cites this paper
    On-Device Language Models: A Comprehensive Review
    Jia-Jun Xu, Zhi-Yuan Li, Wei Chen et al. · 2024 · arXiv.org · preprint, not peer reviewed · cited 206 times · Not summarized yet

    On-Device Language Models surveys architectures and compression for running LLMs on resource-constrained devices, the deployment setting Octopus targets.

    Abstract

    The advent of large language models (LLMs) revolutionized natural language processing applications, and running LLMs on edge devices has become increasingly attractive for reasons including reduced latency, data localization, and personalized user experiences. This comprehensive review examines the challenges of deploying computationally expensive LLMs on resource-constrained devices and explores innovative solutions across multiple domains. The paper investigates the development of on-device language models, their efficient architectures, including parameter sharing and modular designs, as well as state-of-the-art compression techniques like quantization, pruning, and knowledge distillation…

  2. Close Groundwork for this paper
    Toolformer: Language Models Can Teach Themselves to Use Tools
    Timo Schick, Jane Dwivedi-Yu, Roberto Dessì et al. · 2023 · Computation and Language · cited 6,437 times · AI summary available

    Toolformer trains language models to choose API calls, arguments, and when to use them, establishing an earlier approach to tool use relevant to Octopus.

    Abstract

    Language models (LMs) exhibit remarkable abilities to solve new tasks from just a few examples or textual instructions, especially at scale. They also, paradoxically, struggle with basic functionality, such as arithmetic or factual lookup, where much simpler and smaller models excel. In this paper, we show that LMs can teach themselves to use external tools via simple APIs and achieve the best of both worlds. We introduce Toolformer, a model trained to decide which APIs to call, when to call them, what arguments to pass, and how to best incorporate the results into future token prediction. This is done in a self-supervised way, requiring nothing more than a handful of demonstrations for each…

  3. Close Broader context
    LawBench: Benchmarking Legal Knowledge of Large Language Models
    Zhiwei Fei, Xiaoyu Shen, Dawei Zhu et al. · 2023 · Computation and Language · preprint, not peer reviewed · cited 176 times · AI summary available

    LawBench benchmarks legal knowledge rather than API calling, illustrating LLM evaluation in a specialized domain.

    Abstract

    Large language models (LLMs) have demonstrated strong capabilities in various aspects. However, when applying them to the highly specialized, safe-critical legal domain, it is unclear how much legal knowledge they possess and whether they can reliably perform legal-related tasks. To address this gap, we propose a comprehensive evaluation benchmark LawBench. LawBench has been meticulously crafted to have precise assessment of the LLMs' legal capabilities from three cognitive levels: (1) Legal knowledge memorization: whether LLMs can memorize needed legal concepts, articles and facts; (2) Legal knowledge understanding: whether LLMs can comprehend entities, events and relationships within legal…

  4. Related Shared data, tool or method Used in depth by this paper
    Llama 2: Open Foundation and Fine-Tuned Chat Models
    Hugo Touvron, Louis Martin, Kevin R. Stone et al. · 2023 · arXiv.org · preprint, not peer reviewed · cited 18,887 times · Not summarized yet

    Llama 2 releases pretrained and fine-tuned models that can serve as foundations for LLM research, while Octopus fine-tunes small models for API calling.

    Abstract

    In this work, we develop and release Llama 2, a collection of pretrained and fine-tuned large language models (LLMs) ranging in scale from 7 billion to 70 billion parameters. Our fine-tuned LLMs, called Llama 2-Chat, are optimized for dialogue use cases. Our models outperform open-source chat models on most benchmarks we tested, and based on our human evaluations for helpfulness and safety, may be a suitable substitute for closed-source models. We provide a detailed description of our approach to fine-tuning and safety improvements of Llama 2-Chat in order to enable the community to build on our work and contribute to the responsible development of LLMs.

  5. Close Another approach to the problem
    Small LLMs Are Weak Tool Learners: A Multi-LLM Agent
    Wei-Zhou Shen, Chenliang Li, Hongzhan Chen et al. · 2024 · Conference on Empirical Methods in Natural Language Processing · cited 142 times · Not summarized yet

    Small LLMs Are Weak Tool Learners splits tool use among planner, caller, and summarizer models, unlike Octopus’s fine-tuning of on-device models for API calls.

    Abstract

    Large Language Model (LLM) agents significantly extend the capabilities of standalone LLMs, empowering them to interact with external tools (e.g., APIs, functions) and complete various tasks in a self-directed fashion. The challenge of tool use demands that LLMs not only understand user queries and generate answers accurately but also excel in task planning, tool invocation, and result summarization. While traditional works focus on training a single LLM with all these capabilities, performance limitations become apparent, particularly with smaller models. To overcome these challenges, we propose a novel approach that decomposes the aforementioned capabilities into a planner, caller, and sum…

Papers that cite it

  1. Close Builds on this paper
    Hammer: Robust Function-Calling for On-Device Language Models via Function Masking
    Qiqiang Lin, Mu-Ning Wen, Qiuying Peng et al. · 2024 · arXiv.org · preprint, not peer reviewed · cited 70 times · Not summarized yet

    Hammer targets robust on-device function calling with function masking, building on Octopus’s on-device API-calling work and conditional output constraints.

    Abstract

    Large language models have demonstrated impressive value in performing as autonomous agents when equipped with external tools and API calls. Nonetheless, effectively harnessing their potential for executing complex tasks crucially relies on enhancements in their function calling capabilities. This paper identifies a critical gap in existing function calling models, where performance varies significantly across benchmarks, often due to being misled by specific naming conventions. To address such an issue, we introduce Hammer, a novel family of foundation models specifically engineered for on-device function calling. Hammer employs an augmented dataset that enhances models' sensitivity to irre…

  2. Close Another approach to the problem
    Less is More: Optimizing Function Calling for LLM Execution on Edge Devices
    Varatheepan Paramanayakam, Andreas Karatzas, Iraklis Anagnostopoulos et al. · 2024 · cited 33 times · Not summarized yet

    Less-is-More selects tools dynamically without fine-tuning for edge-device function calling, whereas Octopus fine-tunes models for software API interactions.

    Abstract

    The advanced function-calling capabilities of foundation models open up new possibilities for deploying agents to perform complex API tasks. However, managing large amounts of data and interacting with numerous APIs makes function calling hardware-intensive and costly, especially on edge devices. Current Large Language Models (LLMs) struggle with function calling at the edge because they cannot handle complex inputs or manage multiple tools effectively. This results in low task-completion accuracy, increased delays, and higher power consumption. In this work, we introduce Less-is-More, a novel fine-tuning-free function-calling scheme for dynamic tool selection. Our approach is based on the k…

  3. Close Same question
    TinyAgent: Function Calling at the Edge
    Lutfi Eren Erdogan, Nicholas Lee, Siddharth Jha et al. · 2024 · Conference on Empirical Methods in Natural Language Processing · cited 84 times · Not summarized yet

    TinyAgent trains and deploys small agents for function calling at the edge, sharing Octopus’s focus on on-device API use.

    Abstract

    Recent large language models (LLMs) have enabled the development of advanced agentic systems that can integrate various tools and APIs to fulfill user queries through function calling. However, the deployment of these LLMs on the edge has not been explored since they typically require cloud-based infrastructure due to their substantial model size and computational demands. To this end, we present TinyAgent, an end-to-end framework for training and deploying task-specific small language model agents capable of function calling for driving agentic systems at the edge. We first show how to enable accurate function calling for open-source models via the LLMCompiler framework. We then systematica…

  4. Related Broader context Uses this paper in depth
    LLMind 2.0: Distributed IoT Automation with Natural Language M2M Communication and Lightweight LLM Agents
    Yu-Yang Du, Qun Yang, Liujianfu Wang et al. · 2025 · IEEE Internet of Things Journal · cited 10 times · Not summarized yet

    LLMind 2.0 uses lightweight device agents to generate code for local proprietary APIs, applying language-model API interaction to distributed IoT automation.

    Abstract

    Recent advances in large language models (LLMs) have generated great interest in their applications for IoT automation and device management. However, centralized approaches struggle to scale across heterogeneous, large-scale systems. We present LLMind 2.0, a distributed framework that embeds lightweight LLM-empowered device agents and adopts natural language for machine-to-machine (M2M) communication. In LLMind 2.0, a central coordinator translates human instructions into natural-language subtask descriptions, which instruct distributed device agents to generate device-specific code locally based on their proprietary APIs. Using natural language as a unified medium overcomes device heteroge…

  5. Close Same question
    API Pack: A Massive Multi-Programming Language Dataset for API Call Generation
    Zhen Guo, Adriana Meza Soria, Wei Sun et al. · 2024 · International Conference on Learning Representations · cited 6 times · Not summarized yet

    API Pack trains models to generate API calls from a large multilingual dataset, sharing Octopus’s focus on improving API-call generation through data and fine-tuning.

    Abstract

    We introduce API Pack, a massive multi-programming language dataset containing over one million instruction-API calls for improving the API call generation capabilities of large language models. Our evaluation highlights three key findings: First, fine-tuning on API Pack enables open-source models to outperform GPT-3.5 and GPT-4 in generating code for entirely new API calls. We show this by fine-tuning CodeLlama-13B on 20,000 Python instances from API Pack. Second, fine-tuning on a large dataset in one language, combined with smaller datasets from others, improves API generation accuracy across multiple languages. Third, we confirm the benefits of larger datasets for API generalization, as i…

How are these papers found?

We compare the title and abstract of this paper with those of every paper summarized on this site, and with the papers Semantic Scholar recommends, those it cites and those citing it (for a much-cited paper, its most recent citations and, from OpenAlex, the most cited ones). Among the prior work and the follow-ups, the papers that use each other in depth, a method it uses and the much-cited follow-ups come a little higher. The levels (very close, close, related) come from the similarity of the texts, not from a judgment of quality; * marks a paper without an abstract, compared by its title. The sentence under a paper is written by an AI from the two abstracts: check it in the papers. A paper marked not relevant by three readers leaves the list.

Updated on 2 November 2026.

The illustrated guide to the papers around a paper