Tool Unlearning for Tool-Augmented LLMs

Jiali Cheng, Hadi Amiri

Introduction

Tool-augmented Large Language Models (LLMs) often need to "forget" specific APIs due to security vulnerabilities, privacy regulations (like HIPAA), or tool deprecation. This paper introduces ToolDelete, the first framework designed to surgically remove functional tool-using skills from an LLM's weights while preserving its general reasoning abilities and performance on other tools.

The Challenge: Tool vs. Sample Unlearning

As LLMs are increasingly deployed with the ability to call external APIs (calculators, databases, search engines), they embed these "skills" directly into their parametric knowledge. Traditional machine unlearning focuses on removing specific data samples (e.g., a specific user's private text). However, tool unlearning is about removing a functional capability.

Simply instructing a model not to use a tool via a prompt is brittle and easily bypassed by adversarial attacks. True unlearning requires modifying model parameters. The challenge lies in doing this without causing a "ripple effect" that breaks other tools or degrades the model's general intelligence (e.g., its ability to follow instructions or generate coherent text).

Traditional sample-level unlearning focuses on memorized strings, while tool unlearning must erase the underlying functional ability to call an API.

Methodology: The ToolDelete Framework

The authors propose ToolDelete, which optimizes for three key properties:

  1. Tool Knowledge Deletion (TKD): The model is fine-tuned to respond to "forget" tool queries as if it were a "tool-free" model that never encountered them.
  2. Tool Knowledge Retention (TKR): It uses a subset of the original training data to ensure the model maintains its proficiency with the remaining tools.
  3. General Capability Retention (GCR): To prevent the model from losing its foundational skills, the authors employ Task Arithmetic. They calculate a "knowledge vector" ($\theta_0 - \theta_R$) representing the original instruction-tuning phase and add it back to the unlearned model's weights.
The ToolDelete framework uses task arithmetic and specialized fine-tuning to balance forgetting specific tools with maintaining general model utility.

Additionally, they introduce LiRA-Tool, a novel Membership Inference Attack (MIA) for evaluation. Unlike standard MIAs that check for memorized training strings, LiRA-Tool uses GPT-4 to generate "shadow samples"—diverse, novel prompts that test if the model still possesses the abstract skill of using the tool.

Datasets & Evaluation

The study utilizes three primary benchmarks for tool-augmented LLMs:

  • ToolAlpaca: An agent-generated dataset featuring 495 tools and nearly 4,000 training examples.
  • ToolBench: A large-scale dataset containing over 16,000 real-world APIs across 49 categories.
  • API-Bench: A dataset focused on APIs that load machine learning models, used to evaluate the Gorilla model.

Key Insights & Results

  • Skills vs. Samples: Tool unlearning is fundamentally different from sample unlearning. A model might stop "memorizing" a specific training response but still retain the functional logic to invoke an API, which constitutes an unlearning failure.
  • The "Ripple Effect": Modifying parameters to forget one tool can unexpectedly degrade others. The paper shows that explicit retention objectives (TKR) are necessary to mitigate this.
  • Task Arithmetic as a Stabilizer: Aggressive unlearning often "damages" the model's general capabilities. Adding back the instruction-tuning vector via task arithmetic is a computationally efficient way to restore general intelligence without full retraining.
  • Prompting is Not Enough: The authors demonstrate that prompt-level blocking fails as the number of tools to be forgotten increases, whereas ToolDelete remains robust.
  • Effectiveness & Efficiency: ToolDelete outperformed standard unlearning baselines (like Gradient Ascent) by an average of 12.5% in accuracy on "forget" tools while maintaining higher performance on "retain" tools. Furthermore, the framework is significantly faster than the "gold standard" of retraining the model from scratch, saving approximately 74.8% of training time.
  • Privacy & Security: Evaluation with LiRA-Tool showed that ToolDelete effectively hides the presence of unlearned tools from sophisticated membership inference attacks.

Limitations and Future Work

  • Model Scale: The experiments were primarily conducted on 7B parameter models. The scalability of these techniques to much larger models (e.g., 70B+) remains an open question.
  • Shadow Sample Dependency: The LiRA-Tool evaluation relies on the quality and diversity of shadow samples generated by GPT-4; if these samples don't cover the full functional space of a tool, the evaluation might be incomplete.
  • Continual Learning: The authors suggest that future work should investigate tool unlearning in models that are being continually updated with new tools, where the risk of "re-learning" forgotten tools is higher.

Summary updated

BibTeX
@inproceedings{cheng2025tool,
  author = {Jiali Cheng and Hadi Amiri},
  title = {{Tool Unlearning for Tool-Augmented LLMs}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=7ez7LqHsP5},
}
Figure