Learn while Unlearn: An Iterative Unlearning Framework for Generative Language Models

Haoyu Tang, Ye Liu, Xukai Liu, Kai Zhang, Yanghai Zhang, Qi Liu, Enhong Chen · DOI

Abstract

Large Language Models (LLMs) are prone to memorizing sensitive or copyrighted information from their training data. While privacy regulations necessitate the removal of such data, existing machine unlearning techniques often trigger "model collapse," where the model's general linguistic capabilities degrade into repetitive or incoherent outputs. We propose the Iterative Contrastive Unlearning (ICU) framework to address this trade-off. ICU combines a targeted unlearning objective with contrastive learning on topically similar "analogous" data. Our experiments demonstrate that ICU effectively reduces data extraction risks while preserving the model's reasoning and text-generation performance across various scales.

Introduction

The "memorization" phenomenon in LLMs poses significant privacy and legal challenges. As models scale, their capacity to store verbatim training sequences increases, potentially leaking personal identifiable information (PII) or proprietary content. While the "Right to Be Forgotten" (e.g., under GDPR) provides a legal basis for data removal, the technical execution is non-trivial.

Traditional unlearning methods typically rely on gradient ascent to maximize loss on target data. However, this often leads to a catastrophic loss of information entropy, resulting in a "lobotomized" model that produces repetitive loops. Furthermore, many existing methods require access to the original training set, which is frequently unavailable for proprietary or massive-scale models.

Comparison of unlearning outcomes: Original LLMs retain sensitive info, baselines like KUMPR suffer from model collapse, while ICU maintains coherence.

The Iterative Contrastive Unlearning (ICU) Framework

The ICU framework treats unlearning as a balancing act between forgetting specific facts and maintaining general linguistic knowledge. It is composed of three integrated modules:

  1. Knowledge Unlearning Induction (KUI): This module implements the core "forgetting" mechanism. It utilizes a loss function that negates the standard training objective, making the target sequence highly unlikely for the model to generate.
  2. Contrastive Learning Enhancement (CLE): To prevent model collapse, ICU introduces analogous data. Using K-Nearest Neighbors (KNN) sampling, the framework retrieves documents (e.g., from Wikipedia) that are topically related to the target data but contain different factual content. By training the model to learn this new data while unlearning the target, ICU provides a "safe" direction for weight updates, preserving the model's expressive capabilities.
  3. Iterative Unlearning Refinement (IUR): Unlearning is treated as an iterative process. After each epoch, the model is evaluated using similarity metrics (e.g., BERTScore). Once the output for a sensitive prompt falls below a predefined threshold, the unlearning process for that specific entry stops, preventing "over-unlearning" and unnecessary performance degradation.
The ICU framework architecture, illustrating the interaction between target data, paired analogous data, and the three core modules (KUI, CLE, and IUR).

Experimental Evaluation

We evaluated the ICU framework using a 15,000-sample subset of The Pile as the target dataset for unlearning. Analogous data was retrieved from Wikipedia based on category overlap. We tested the framework on GPT-NEO models ranging from 125M to 2.7B parameters.

To assess model utility, we employed nine classification tasks (including Hellaswag and MMLU) and four dialogue tasks. Unlearning effectiveness was measured via Extraction Likelihood—the probability of a model leaking the target data under attack.

Key Results and Insights

The ICU framework consistently outperformed baseline methods like KUMPR, DPO, and LLMU in balancing unlearning efficiency with model utility.

  • Preservation of Coherence: While baseline methods often saw Perplexity (PPL) skyrocket to over 1000 (indicating total failure), ICU maintained PPL levels close to the original model. For the 2.7B parameter model, ICU achieved a PPL of 13.1, compared to the original 12.0.
  • Effective Forgetting: ICU successfully reduced the Extraction Likelihood in the 2.7B model from approximately 96% to just 4.5%.
  • The "Learning to Unlearn" Paradigm: Our results suggest that providing the model with a path to follow (analogous data) is superior to simply telling it what not to say. By "learning" related but non-sensitive facts, the model retains its structural understanding of the topic without retaining the specific private details.
  • Scalability: We observed that larger models have a higher propensity for memorization, making the controlled unlearning provided by ICU increasingly vital as model size grows.

Conclusion and Future Work

The ICU framework provides a robust solution for the "Right to Be Forgotten" in the era of generative AI. By leveraging analogous data and an iterative refinement process, it avoids the pitfalls of model collapse common in simpler unlearning schemes.

Future research will focus on automating the generation of analogous data for niche or proprietary domains where retrieval is difficult, and testing the framework's resilience against more advanced adversarial extraction attacks on "frontier" models exceeding 70B parameters.

Summary updated

BibTeX
@misc{tang2024learn,
  author = {Haoyu Tang and Ye Liu and Xukai Liu and Kai Zhang and Yanghai Zhang and Qi Liu and Enhong Chen},
  title = {{Learn while Unlearn: An Iterative Unlearning Framework for Generative Language Models}},
  year = {2024},
  eprint = {2407.20271},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.20271},
}
Figure