NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Robust Function-Calling for On-Device Language Model via Function Masking

Qiqiang Lin, Muning Wen, Qiuying Peng, Guanyu Nie, Junwei Liao, Jun Wang, Xiaoyun Mo, Jiamu Zhou, Cheng Cheng, Yin Zhao, Weinan Zhang

Introduction

The Hammer family of models introduces a novel training technique called "Function Masking" that forces language models to prioritize semantic descriptions over brittle naming conventions. By training on a specialized irrelevance-augmented dataset, these lightweight models (ranging from 1.5B to 7B parameters) achieve state-of-the-art function-calling performance. Remarkably, they often outperform models ten times their size on major benchmarks like the Berkeley Function Calling Leaderboard (BFCL), all while remaining efficient enough for on-device deployment.

The Problem: Brittle Naming and Irrelevance

Function calling acts as the essential "glue" that allows Large Language Models (LLMs) to operate as autonomous agents by interacting with external tools and APIs. However, existing models typically suffer from two major flaws:

  1. Over-reliance on Names: Models often "cheat" by keying in on explicit function names (e.g., get_weather) rather than actually understanding the underlying documentation. If a developer uses a different or less intuitive naming style (e.g., fetch_temp_data), the model’s performance frequently collapses.
  2. The "Eager to Please" Problem: Many models struggle with irrelevance detection. When a user asks a question that cannot be answered by the available tools, the model often tries to force a function call anyway, leading to hallucinations and execution errors.

The authors address these specific gaps to create robust models that can run efficiently on mobile hardware without sacrificing accuracy.

Methodology: Function Masking

The core innovation of this paper is a training strategy called Function Masking.

The Hammer training pipeline featuring Function Masking.

During the fine-tuning process, the authors randomly replace function names, parameter names, and default values with random alphanumeric strings (e.g., LxOm64zLyg). By applying this mask to roughly 33% of the training data, the model is forced to ignore compact naming conventions and instead focus on the natural language descriptions of what the function actually does. This prevents the model from memorizing specific naming patterns and encourages a deeper semantic understanding of the tool's purpose.

Additionally, the team implemented a Tuning Framework that uses Supervised Fine-Tuning (SFT) on a mix of masked and unmasked data. This ensures the model remains compatible with standard naming conventions while retaining the robustness gained from the masking process.

Datasets and Evaluation

The researchers utilized several key datasets and introduced their own targeted augmentations:

  • xLAM-function-calling-60k: The primary base dataset used for training.
  • Irrelevance-Augmented Dataset: The authors added 7,500 new instances specifically designed to teach irrelevance detection. They generated these by taking valid samples and removing the "correct" function from the candidate list, training the model to output an empty list when no tool fits the query.

The models were tested against a gauntlet of industry standards, including the BFCL v2 (Berkeley Function Calling Leaderboard)—the gold standard for function calling—as well as API-Bank, Nexus Raven, Tool-Alpaca, and Seal-Tools to represent diverse "out-of-domain" challenges.

Key Insights and Results

Names are a Crutch

The paper proves that standard models are surprisingly fragile. When function names were obfuscated at test time, standard models like xLAM-1.3B saw a massive performance drop.

F1 score comparison showing Hammer's robustness against function and argument masking compared to the baseline.

As shown above, Hammer remained highly stable across various masking conditions (function name mask, argument name mask, and all mask). This confirms that current models are often just "pattern matching" names rather than reasoning, a flaw Hammer successfully mitigates.

The Irrelevance Trade-off

The authors discovered an inverse relationship: as a model gets better at executing specific functions, it often gets worse at realizing when no function is needed. Their 10% irrelevance-augmentation ratio was found to be the "sweet spot" to balance execution accuracy with hallucination prevention.

Leaderboard Dominance and Efficiency

A 7B parameter model (Hammer-7B) achieved an overall accuracy of 83.92% on the BFCL, ranking #2 globally and sitting just behind GPT-4. It outperformed much larger models like Functionary-Medium-v3.1 (70B), suggesting that for specialized tasks like tool use, high-quality, targeted training data is more critical than sheer architectural size.

Furthermore, the authors successfully quantized Hammer-7B to 4-bit (Q4_K_M). When deployed on a Snapdragon 8 Gen 3 processor (OPPO Find X7 Ultra), it achieved a decode speed of 7.9 tokens/sec with only a 2% performance hit, making it highly viable for real-time mobile use.

Limitations and Future Work

The authors acknowledge a few constraints with their approach:

  • Description Dependency: Function masking relies entirely on the quality of the function descriptions. If the documentation is poor or missing, the masking technique could degrade performance.
  • Inference Frameworks: While the model is small enough for mobile, current edge-side inference frameworks still need optimization to reach the full potential of these models.
  • Masking Ratios: An excessively high masking ratio during training can slow down the learning process, indicating that a careful balance between "natural" and "masked" data is critical.

Future work will likely explore how this masking technique scales to multi-turn dialogues and more complex, nested function calls.

Summary updated

BibTeX
@inproceedings{lin2025robust,
  author = {Qiqiang Lin and Muning Wen and Qiuying Peng and Guanyu Nie and Junwei Liao and Jun Wang and Xiaoyun Mo and Jiamu Zhou and Cheng Cheng and Yin Zhao and Jun Wang and Weinan Zhang},
  title = {{Robust Function-Calling for On-Device Language Model via Function Masking}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=yVQcr4qjD6},
}
Figure