TL;DR
This paper introduces "Hammer," a new family of lightweight language models designed for robust function-calling on edge devices. By employing a novel "function masking" technique and an augmented dataset for irrelevance detection, Hammer significantly improves generalization and outperforms larger models on various benchmarks, setting a new standard for on-device function-calling.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly being used as autonomous agents that leverage external tools and APIs to perform complex tasks. A critical component of this capability is "function-calling," where the LLM must accurately select the correct function from a set of options and provide the right arguments. However, existing function-calling models often exhibit inconsistent performance across different benchmarks. The authors identify that a primary reason for this instability is the models' over-reliance on function and parameter names, which can be misleading due to varying naming conventions across datasets. This leads to models performing well on benchmarks similar to their training data but struggling with those that use different naming styles. Furthermore, models often fail to detect when no appropriate function is available, leading to incorrect attempts.
Methods
The paper proposes two main innovations:
- Function Masking: During training, the function names and parameter names within the candidate functions are replaced with random strings. This forces the model to rely on the descriptions of functions and parameters to understand their purpose and usage, rather than potentially ambiguous names. This technique aims to improve generalization by making the model less sensitive to naming conventions.
- Irrelevance-Augmented Dataset: To address the issue of models failing to detect irrelevant functions, the authors augment an existing dataset (xLAM-function-calling-60k) with 7,500 new examples. In these examples, the correct function is deliberately excluded from the candidate list, and the expected output is an empty list. This trains the model to better identify when no suitable function is available.
These techniques are integrated into a tuning framework designed to enhance generalization capabilities.
Datasets
- Training Data:
- xLAM-function-calling-60k dataset (augmented with 7,500 irrelevance examples).
- Evaluation Benchmarks:
- Berkeley Function-Calling Leaderboard (BFCL) v2
- API-Bank
- Tool-Alpaca
- Nexus Raven API Evaluation
- Seal-Tools
The authors also introduce a specialized dataset for irrelevance detection as part of their contributions.
Key Insights and Ideas
- Naming Conventions are a Major Bottleneck: The paper strongly demonstrates that LLMs' performance in function-calling is heavily influenced by the naming conventions of functions and parameters. Models tend to "memorize" these names, leading to brittle performance when encountering different styles.
- Descriptions Hold the Key to Robustness: By masking function and parameter names, the authors show that models can be trained to rely on function descriptions, which are more detailed and less prone to ambiguity, leading to significantly improved generalization.
- Irrelevance Detection is Crucial for Real-World Agents: Models that can't identify when no function is suitable are prone to making incorrect calls, which is a critical failure mode for autonomous agents. The augmented dataset specifically targets this weakness.
- Lightweight Models Can Compete: Hammer, a family of lightweight models (e.g., 7B parameters), demonstrates performance comparable to or exceeding much larger proprietary models like GPT-4 on certain tasks, highlighting the effectiveness of their approach for on-device deployment.
Key Results
- State-of-the-Art Performance: Hammer-7B achieves top-tier performance on the Berkeley Function-Calling Leaderboard (BFCL) v2, ranking second only to GPT-4 among models of comparable size.
- Robust Generalization: Hammer shows remarkably stable performance across diverse benchmarks, even those with different naming conventions, indicating strong generalization capabilities.
- Outperforming Larger Models: Hammer models outperform many larger open-source models and compete with top-tier closed-source models like GPT-4 and GPT-4o on various benchmarks.
- Reduced Performance Degradation: In experiments where function and parameter names were obfuscated, Hammer showed a much smaller performance drop compared to models like xLAM-1.3B-fc, confirming its reliance on descriptions.
- Improved Irrelevance Detection: The irrelevance-augmented dataset significantly improves the model's ability to detect when no suitable function is available.
Limitations and Future Work
- Masking Ratio Trade-off: While function masking improves generalization, an excessively large mask ratio can slow down learning speed within the same task scenario. The optimal ratio may depend on the model and dataset.
- Proportion of Irrelevance Data: The optimal proportion of irrelevance-augmented data for training is approximately 10%, but this may need adjustment based on the specific model and dataset.
- Future Work: The authors suggest that their methodology is not exclusive to the Qwen model and can be applied to other architectures, indicating potential for broader application. The paper also highlights the need for continued research into robust function-calling for on-device AI agents.
Summary updated