Knowledge Swapping via Learning and Unlearning

Mingyu Xing, Lechao Cheng, Shengeng Tang, Yaxiong Wang, Zhun Zhong, Meng Wang

In the rapidly evolving landscape of artificial intelligence, pretrained models often face a "Goldilocks" dilemma: the need to acquire new tasks while simultaneously purging sensitive or outdated information, all without compromising core foundational capabilities. Traditional approaches like Continual Learning (CL) or Machine Unlearning (MU) address these needs in isolation, but real-world scenarios—such as updating medical AI with new protocols while removing deprecated patient data—require a unified approach.

Researchers from Hefei University of Technology have introduced Knowledge Swapping, a framework designed to teach models new tricks while ensuring they forget the "bad" ones.

Comparison of Continual Learning, Machine Unlearning, and the proposed Knowledge Swapping framework.

The Knowledge Swapping Framework

The authors formalize Knowledge Swapping by partitioning data into three distinct subsets:

  1. Retaining Set ($D_r$): Essential core knowledge that must be preserved.
  2. Forgetting Set ($D_f$): Specific categories or data points that must be surgically erased.
  3. Learning Set ($D_l$): New knowledge the model is required to acquire.

The challenge lies in the "sequence dilemma": whether to forget first to "clear space" or learn first to establish a new baseline.

The "Learning Before Forgetting" (L \rightarrow F) Strategy

The pivotal discovery of this research is the Knock-on Feature Hierarchy. By analyzing weight norms and gradients across network layers, the authors observed a fundamental asymmetry in how networks process information:

  • Learning typically progresses "bottom-up," starting with low-level representations (edges, textures) and moving toward high-level semantics.
  • Forgetting tends to occur "top-down," beginning with high-level semantic concepts and moving down to low-level features.
The Knowledge Swapping process: transitioning from learning new knowledge to unlearning specific information.

Based on this hierarchy, the authors propose the L \rightarrow F sequence. Learning first stabilizes the low-level feature distribution. Subsequent forgetting then only requires minor adjustments to high-level semantics. Conversely, an F \rightarrow L sequence risks "re-tuning" low-level features during the learning phase, which can cause previously "forgotten" high-level concepts to accidentally re-emerge.

Technical Implementation

To achieve efficient and precise swapping, the framework employs three key technical components:

  • LoRA-Based Fine-Tuning: Utilizing Low-Rank Adaptation (LoRA) allows the model to update only a tiny fraction of its parameters, maintaining efficiency.
  • Group Sparse Regularization (Lasso): Lasso regularization is applied to the LoRA matrices to "zero out" irrelevant modules. This prevents interference between the retaining, forgetting, and learning sets.
  • Boundary Constraint (BND): To prevent instability during the unlearning phase—where loss could theoretically grow unbounded—the authors introduce a ReLU-based boundary that halts the forgetting process once a specific "unlearning" threshold is reached.

Evaluation and Results

The framework was benchmarked across image classification (ImageNet-100), object detection (COCO), and semantic segmentation (ADE20K). Key findings include:

  • Effective Erasure: In classification tasks, the L \rightarrow F strategy reduced accuracy on the forgetting set to 0% while achieving over 90% accuracy on the learning set.
  • Stability: The retaining set performance typically stayed within 1-2% of its original baseline.
  • Sequence Superiority: In object detection, the F \rightarrow L sequence often failed to fully erase the forgetting set (maintaining a high mAP), whereas the L \rightarrow F strategy successfully dropped the forgetting set mAP to near zero.

Conclusion

Knowledge Swapping offers a surgical approach to model maintenance. While currently validated on vision models like ViT and DINO, the underlying principles of LoRA and feature hierarchy are highly applicable to Large Language Models (LLMs). Future work will likely explore "category-specific difficulty" and the complexities of swapping knowledge sets that share high semantic similarity.

Summary updated

BibTeX
@inproceedings{xing2025knowledge,
  author = {Mingyu Xing and Lechao Cheng and Shengeng Tang and Yaxiong Wang and Zhun Zhong and Meng Wang},
  title = {{Knowledge Swapping via Learning and Unlearning}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=B3zlIHdnER},
}
Figure