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

Who's Harry Potter? Approximate Unlearning in LLMs

Ronen Eldan, Mark RussinovicharXiv 2023

TL;DR

This paper introduces a novel method for "unlearning" specific data from large language models (LLMs) without full retraining. By fine-tuning a model to generate "generic" versions of target text, they demonstrate effective removal of Harry Potter knowledge from Llama2-7b in just one GPU hour, while preserving general capabilities. This work offers a practical step towards more adaptable and legally compliant LLMs.

What Problem Does This Paper Address?

Large language models (LLMs) are trained on massive datasets, often including copyrighted material. This raises significant legal and ethical concerns, as models can inadvertently reproduce or reveal this sensitive information. Retraining LLMs from scratch to remove specific data is computationally prohibitive. Therefore, there's a critical need for efficient methods to selectively "unlearn" subsets of training data from already trained LLMs.

Methods

The authors propose a three-component technique for approximate unlearning:

  1. Reinforced Model for Token Identification: A baseline model is further trained on the target data (e.g., Harry Potter books) to create a "reinforced model." This reinforced model's logits are compared to the baseline's to identify tokens most related to the unlearning target.
  2. Generic Prediction Generation: For each token in the target data, the model aims to predict what a model not trained on that data would generate. This involves replacing idiosyncratic expressions (like "Harry Potter") with generic counterparts (like "Jon") and using the reinforced model's insights to guide the generation of these "generic predictions."
  3. Fine-tuning with Generic Predictions: The original model is then fine-tuned using the original text as input but with the generated "generic predictions" as the target labels. This process effectively teaches the model to produce generic continuations, thereby erasing the specific knowledge from its memory.

Datasets

  • Training Data: The authors used Meta's Llama2-7b model as their base. The unlearning target was the Harry Potter book series. The unlearn dataset was a concatenation of the original books (2.1M tokens) and synthetically generated discussions, blog posts, and wiki-like entries about the books (1M tokens).
  • Evaluation Benchmarks: Standard benchmarks were used to assess the preservation of general capabilities: WinoGrande, HellaSwag, ARC (challenge and easy), BoolQ, OpenBookQA, and PIQA.

Key Insights and Ideas

  • "Unlearning" is Achievable Without Full Retraining: The core insight is that selective knowledge removal is possible through targeted fine-tuning, drastically reducing computational cost compared to retraining.
  • Generic Predictions as a Proxy for Unlearning: Instead of directly forcing the model to forget, the strategy is to teach it what it should have predicted if it hadn't seen the target data. This "generic prediction" acts as a substitute target during fine-tuning.
  • Idiosyncrasy is Key: The Harry Potter series, with its rich and unique vocabulary and names, serves as an ideal test case. The method leverages these specific terms to identify and replace them with generic alternatives.
  • Reinforcement Helps Identify Target Tokens: Using a reinforced model (trained on the target data) helps pinpoint which tokens are most strongly associated with the unwanted knowledge, guiding the unlearning process.

Key Results

  • Effective Knowledge Removal: After approximately 1 GPU hour of fine-tuning, the Llama2-7b model effectively "forgot" the Harry Potter books. Prompts that previously elicited detailed knowledge of the series now resulted in generic or unrelated responses.
  • Preservation of General Capabilities: Performance on standard benchmarks (WinoGrande, HellaSwag, etc.) remained largely unaffected, demonstrating that the unlearning process did not degrade the model's overall linguistic understanding or reasoning abilities.
  • Efficiency: The unlearning process was significantly faster than retraining, taking about 1 GPU hour compared to the original 184K GPU-hours for pretraining.

Limitations and Future Work

  • Potential for "Super-set" Unlearning: The technique might inadvertently unlearn related content (e.g., Wikipedia articles about Harry Potter). The authors suggest this can be mitigated by fine-tuning on related content to re-learn it.
  • Reliance on GPT-4 for Anchoring: The current method relies on GPT-4 to identify idiosyncratic terms and generate generic counterparts. Future work could explore less knowledge-dependent methods for entity extraction, possibly using n-gram frequency analysis.
  • Challenges with Non-Fiction: Applying this to non-fiction or textbooks presents challenges due to the less dense nature of unique terms and the presence of abstract concepts. Adapting the technique for such content is a direction for future research.
  • Adversarial Evaluation: While the current evaluation is promising, the authors acknowledge that more adversarial methods (like probing token probability distributions) might reveal subtle remnants of knowledge. They have open-sourced their model to encourage community-based adversarial testing.

Summary updated

BibTeX
@misc{eldan2023who,
  author = {Ronen Eldan and Mark Russinovich},
  title = {{Who's Harry Potter? Approximate Unlearning in LLMs}},
  year = {2023},
  eprint = {2310.02238},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.02238},
}
Figure