📄arXiv • 🤗HFPaper • 🤗HF Collection
This repository provides the official PyTorch implementation of our paper:
ReLearn: Unlearning via Learning for Large Language Models
Haoming Xu1, Ningyuan Zhao2, Liming Yang3, Sendong Zhao4, Shumin Deng5, Mengru Wang1, Bryan Hooi5, Nay Oo5, Huajun Chen1, Ningyu Zhang1
1Zhejiang University, 2Xiamen University, 3Tsinghua University, 4Harbin Institute of Technology, 5National University of Singapore
🏆 Our team won 2nd place in the SEMEval 2025 Challenge on Unlearning Sensitive Content from Large Language Models! Check out our implementation in the Semeval25
directory.
# Create and activate conda environment
conda create -n relearn python=3.10.15
conda activate relearn
# Install PyTorch with CUDA support
conda install pytorch pytorch-cuda=11.8 -c pytorch -c nvidia
conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit
# Install dependencies
pip install -r requirements.txt
pip install flash-attn --no-build-isolation
cd dataAugument
bash augu.sh
Currently supports:
- Llama3-8b instruct
- Gemma2-2b-it
- Llama2-7b chat
cd baselines/pretrain_scripts/
bash kud-pt.sh
cd baselines/unlearn_scripts/
bash kud-relearn.sh
cd evals
bash merge_all.sh
bash inf_all.sh
bash eval_all.sh
Method | Script | Source & Notes |
---|---|---|
GA / NPO | unlearn/baselines/unlearn_scripts/kud-baselines.sh |
Source |
SURE | unlearn/baselines/unlearn_scripts/kud-baselines.sh |
Source |
Memflex | unlearn/baselines/unlearn_scripts/kud-baselines.sh |
Source (Iterative version) |
ReLearn | unlearn/baselines/unlearn_scripts/kud-relearn.sh |
Our Method |
ReLearn_dpo | unlearn/baselines/unlearn_scripts/kud-relearn.sh |
Uses augmented data as positive samples |
-
Llama-2-7b-chat-KnowUnDo-Privacy (Vanilla)
🔗 ModelScope -
Llama-2-7b-chat-TOFU-Forget10-ReLearn
🔗 Google Drive -
Llama-2-7b-chat-KnowUnDo-Privacy-ReLearn
🔗 Google Drive
- Augmented KnowUnDo Privacy Dataset
🔗 Google Drive
This repository builds upon code from:TOFU and MUSE.
We thank the authors for their excellent work.
If you find this work useful for your research, please cite our paper:
@misc{xu2025relearnunlearninglearninglarge,
title={ReLearn: Unlearning via Learning for Large Language Models},
author={Haoming Xu and Ningyuan Zhao and Liming Yang and Sendong Zhao and
Shumin Deng and Mengru Wang and Bryan Hooi and Nay Oo and
Huajun Chen and Ningyu Zhang},
year={2025},
eprint={2502.11190},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2502.11190}
}