TL;DR
This paper introduces Alopex, a framework designed to enable Large Language Models (LLMs) to reliably call external API functions on mobile devices. Alopex tackles challenges like scarce training data and catastrophic forgetting by proposing a novel logic-based data generation method and a data mixing strategy, significantly improving function call accuracy and preserving general LLM capabilities.
What Problem Does This Paper Address?
As LLMs become more integrated into our daily lives, particularly on mobile devices for personalized assistance, a crucial capability is their ability to interact with external tools by calling API functions. This allows LLMs to go beyond their inherent knowledge and perform real-world actions. However, developing these "LLM agents" for on-device use faces several hurdles:
- Data Scarcity: There's a lack of high-quality training data demonstrating how LLMs can effectively use API functions. Existing methods often rely on LLMs to generate synthetic data, which can be prone to errors and require manual verification, slowing down development.
- Ineffective Question Formatting: The way user queries are presented to the LLM significantly impacts its ability to select and use the correct API function. Current formats are not always optimal and can even lead to security risks if not handled carefully.
- Catastrophic Forgetting: Fine-tuning LLMs for specific tasks like function calling can cause them to "forget" their general knowledge and reasoning abilities, leading to a performance drop on other tasks. This is a major concern for on-device agents that need to maintain broad capabilities.
Methods
Alopex addresses these challenges with a multi-pronged approach:
- Logic-Based Data Generation: Instead of solely relying on LLMs to create training examples, Alopex employs a rule-based logic system. This system breaks down function descriptions into components (question, action, parameters) and systematically generates diverse, high-quality questions and corresponding function call outputs. This method is more efficient and less prone to errors than purely LLM-generated data, reducing the need for manual checks.
- Novel "Description-Question-Output" Data Format: The paper proposes a new format for fine-tuning LLMs. This format places the function description alongside the user's question and the expected output. This approach is shown to be more effective than previous formats, particularly in handling "out-of-logic" queries (queries that don't strictly follow predefined patterns), and also helps mitigate the risk of function information leakage.
- Data Mixing Strategy for Catastrophic Forgetting: To combat the issue of LLMs forgetting their general knowledge after function call fine-tuning, Alopex uses a data mixing strategy. It combines the newly generated function call training data with existing "textbook" datasets. This allows the LLM to retain its foundational knowledge while learning new function-calling skills.
Datasets
The paper utilizes and generates several datasets:
- Octopus-v2 Datasets: The study references and builds upon datasets from Octopus-v2 [5], which provides function descriptions for Android APIs.
- Rule-Based Logic Generated Datasets: Alopex generates its own training data using the proposed logic-based method. This includes datasets formatted according to DF1 (speculated Octopus-v2 format) and DF2 (the new "description-question-output" format).
- GPT-3.5 Generated Dataset: For comparison, a dataset was generated using the GPT-3.5 API, following the Octopus-v2 approach.
- Open-Source Textbook Datasets: For the data mixing strategy to mitigate catastrophic forgetting, the paper uses the
nampdn-ai/tiny-textbooksdataset.
Key Insights and Ideas
- Logic is Key for Data Generation: A rule-based logic approach for generating function call demonstrations is significantly more reliable and efficient than relying solely on LLMs, reducing errors and manual effort.
- Format Matters for Robustness: The proposed "description-question-output" (DF2) format proves superior to existing formats, especially for handling less conventional or "out-of-logic" user queries, leading to better function call accuracy.
- Mixing Data is Crucial for Preserving Skills: Combining task-specific data (function calls) with general knowledge data (textbooks) is an effective way to prevent catastrophic forgetting, allowing LLMs to learn new skills without sacrificing their existing capabilities.
- Fox LLM Shows Promise: The paper highlights the Fox LLM as a robust model that performs well with the Alopex framework, demonstrating high accuracy and stability.
Key Results
- Improved Function Call Accuracy: Alopex, particularly with the DF2 format, achieves very high function call accuracy, reaching up to 99% in some scenarios, especially for "in-logic" queries.
- Mitigated Catastrophic Forgetting: The data mixing strategy effectively recovers performance on general LLM benchmarks (MMLU, GSM8K, etc.) that are typically degraded by function call fine-tuning. While there are some fluctuations, the average accuracy across these benchmarks shows an upward trend.
- Efficiency Gains: The logic-based data generation method significantly reduces the need for manual verification and regeneration of training data, speeding up the development pipeline.
- Out-of-Logic Performance: The DF2 format shows particular strength in handling "out-of-logic" queries, achieving better accuracy compared to DF1.
Limitations and Future Work
- Focus on Single Function Calls: The current study primarily focuses on single function calls. Future work could explore enabling LLMs to handle more complex scenarios involving multiple function calls or tool sequences.
- Model Specificity: While Alopex is tested on several small LLMs, its performance might vary across different model architectures and sizes. Further research could investigate its generalizability.
- Manual Intervention for LLM-Generated Data: The paper notes that LLM-generated data (like from GPT-3.5) often requires manual validation and regeneration, which is a limitation of those approaches that Alopex aims to overcome.
- Exploration of Data Mixing Ratios: The study uses a 1:1 ratio for data mixing. Investigating optimal mixing ratios for different tasks and datasets could further enhance performance.
Summary updated