Skip to content

Commit d71aa34

Browse files
Update documentation and some miscellaneous things (#96)
* Fix documentation and some miscellaneous things (#13) * Re-formatting + more badges * Update and fix docs * Make error msg accurate * handle lack of flash-attn flag better * Document more hydra features * update example exp configs to match latest supported metrics * Change HF logo * Simplify eval exp cfg dump * testing push workflows * Add workflow test branch * update workflow path again * Reformat badges to fix blue line issue * Fix div * revert change to tests build path --------- Co-authored-by: Dornavineeth <[email protected]>
1 parent 3661423 commit d71aa34

File tree

10 files changed

+251
-140
lines changed

10 files changed

+251
-140
lines changed

.github/workflows/tests.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: tests
22

33
on:
4-
# push:
5-
# paths:
6-
# - "**.py"
7-
# - "requirements.txt"
8-
# - ".github/workflows/*.yml"
4+
push:
5+
paths:
6+
- "**.py"
7+
- "requirements.txt"
8+
- ".github/workflows/*.yml"
99
pull_request:
1010
paths:
1111
- "**.py"

README.md

+18-24
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
<h3><strong>An easily extensible framework unifying LLM unlearning evaluation benchmarks.</strong></h3>
66

77
<div style="display: flex; gap: 10px; justify-content: center; align-items: center;">
8-
<a href="https://github.com/locuslab/open-unlearning/actions">
9-
<img src="https://github.com/locuslab/open-unlearning/actions/workflows/tests.yml/badge.svg" alt="Build Status">
10-
</a>
11-
<a href="https://huggingface.co/open-unlearning">
12-
<img src="https://img.shields.io/badge/Hugging%20Face-white?logo=huggingface" alt="Hugging Face">
13-
</a>
14-
<a href="https://github.com/locuslab/open-unlearning">
15-
<img src="https://img.shields.io/github/stars/locuslab/open-unlearning?style=social" alt="GitHub Repo stars">
16-
</a>
8+
<a href="https://github.com/locuslab/open-unlearning"><img src="https://img.shields.io/github/stars/locuslab/open-unlearning?style=social" alt="GitHub Repo stars"/></a>
9+
<a href="https://github.com/locuslab/open-unlearning/actions"><img src="https://github.com/locuslab/open-unlearning/actions/workflows/tests.yml/badge.svg" alt="Build Status"/></a>
10+
<a href="https://huggingface.co/open-unlearning"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue" alt="HuggingFace 🤗"/></a>
11+
<a href="https://github.com/locuslab/open-unlearning"><img src="https://img.shields.io/github/repo-size/locuslab/open-unlearning" alt="GitHub repo size"/></a>
12+
<a href="https://github.com/locuslab/open-unlearning"><img src="https://img.shields.io/github/languages/top/locuslab/open-unlearning" alt="GitHub top language"/></a>
13+
<a href="https://github.com/locuslab/open-unlearning/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue" alt="License: MIT"/></a>
1714
</div>
1815
</div>
1916

@@ -30,7 +27,7 @@ We invite the LLM unlearning community to collaborate by adding new benchmarks,
3027
### 📢 Updates
3128

3229
#### [Apr 6, 2025]
33-
⚠️⚠️ **IMPORTANT:** Be sure to run `python setup_data.py` immediately after merging the latest version. This is required to refresh the downloaded eval log files and ensure they're compatible with the latest evaluation metrics.
30+
🚨🚨 **IMPORTANT:** 🚨🚨 Be sure to run `python setup_data.py` immediately after merging the latest version. This is required to refresh the downloaded eval log files and ensure they're compatible with the latest evaluation metrics.
3431
- **More Metrics!** Added 6 Membership Inference Attacks (MIA) (LOSS, ZLib, Reference, GradNorm, MinK, and MinK++), along with Extraction Strength (ES) and Exact Memorization (EM) as additional evaluation metrics.
3532
- **More TOFU Evaluations!** Now includes a holdout set and supports MIA attack-based evaluation. You can now compute MUSE's privleak on TOFU.
3633
- **More Documentation!** [`docs/links.md`](docs/links.md) contains resources for each of the implemented features and other useful LLM unlearning resources.
@@ -89,13 +86,13 @@ We provide several variants for each of the components in the unlearning pipelin
8986
## ⚡ Quickstart
9087

9188
```bash
92-
# environment setup
89+
# Environment setup
9390
conda create -n unlearning python=3.11
9491
conda activate unlearning
9592
pip install .
9693
pip install --no-build-isolation flash-attn==2.6.3
9794

98-
# data setup
95+
# Data setup
9996
python setup_data.py # saves/eval now contains evaluation results of the uploaded models
10097
# Downloads log files with metric eval results (incl retain model logs) from the models
10198
# used in the supported benchmarks.
@@ -175,7 +172,7 @@ For more in-depth information on specific aspects of the framework, refer to the
175172
| [`docs/contributing.md`](docs/contributing.md) | Instructions on how to add new methods, benchmarks, components such as trainers, benchmarks, metrics, models, datasets, etc. |
176173
| [`docs/evaluation.md`](docs/evaluation.md) | Detailed instructions on creating and running evaluation metrics and benchmarks. |
177174
| [`docs/experiments.md`](docs/experiments.md) | Guide on running experiments in various configurations and settings, including distributed training, fine-tuning, and overriding arguments. |
178-
| [`docs/hydra.md`](docs/hydra.md) | Explanation of the Hydra features used in configuration management for experiments. |
175+
| [`docs/hydra.md`](docs/hydra.md) | A short tutorial on Hydra features, Hydra is the configuration management package we use extensively. |
179176
| [`community/leaderboard.md`](community/leaderboard.md) | Reference results from various unlearning methods run using this framework on TOFU and MUSE benchmarks. |
180177
| [`docs/links.md`](docs/links.md) | List of all links to the research papers or other sources the implemented features are sourced from. |
181178
| [`docs/repro.md`](docs/repro.md) | Results are provided solely for reproducibility purposes, without any parameter tuning. |
@@ -193,26 +190,25 @@ If you use OpenUnlearning in your research, please cite OpenUnlearning and the b
193190

194191
```bibtex
195192
@misc{openunlearning2025,
196-
title={OpenUnlearning: A Unified Framework for LLM Unlearning Benchmarks},
193+
title={{OpenUnlearning}: A Unified Framework for LLM Unlearning Benchmarks},
197194
author={Dorna, Vineeth and Mekala, Anmol and Zhao, Wenlong and McCallum, Andrew and Kolter, J Zico and Maini, Pratyush},
198195
year={2025},
199196
howpublished={\url{https://github.com/locuslab/open-unlearning}},
200197
note={Accessed: February 27, 2025}
201198
}
202199
@inproceedings{maini2024tofu,
203-
title={TOFU: A Task of Fictitious Unlearning for LLMs},
200+
title={{TOFU}: A Task of Fictitious Unlearning for LLMs},
204201
author={Maini, Pratyush and Feng, Zhili and Schwarzschild, Avi and Lipton, Zachary Chase and Kolter, J Zico},
205202
booktitle={First Conference on Language Modeling},
206203
year={2024}
207204
}
208-
@article{shi2024muse,
209-
title={MUSE: Machine Unlearning Six-Way Evaluation for Language Models},
205+
@inproceedings{
206+
shi2025muse,
207+
title={{MUSE}: Machine Unlearning Six-Way Evaluation for Language Models},
210208
author={Weijia Shi and Jaechan Lee and Yangsibo Huang and Sadhika Malladi and Jieyu Zhao and Ari Holtzman and Daogao Liu and Luke Zettlemoyer and Noah A. Smith and Chiyuan Zhang},
211-
year={2024},
212-
eprint={2407.06460},
213-
archivePrefix={arXiv},
214-
primaryClass={cs.CL},
215-
url={https://arxiv.org/abs/2407.06460},
209+
booktitle={The Thirteenth International Conference on Learning Representations},
210+
year={2025},
211+
url={https://openreview.net/forum?id=TArmA033BU}
216212
}
217213
```
218214
</details>
@@ -231,6 +227,4 @@ This project is licensed under the MIT License. See the [`LICENSE`](LICENSE) fil
231227

232228
---
233229

234-
### Star History
235-
236230
[![Star History Chart](https://api.star-history.com/svg?repos=locuslab/open-unlearning&type=Date)](https://www.star-history.com/#locuslab/open-unlearning&Date)

community/benchmarks/template/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Please include the experimental setup for the baselines
2626

2727
- [ ] **Hyperparameters & Search Space:** Specify key hyperparameters, their search ranges, number of trials etc.
2828
- [ ] **Computational Setup:** Mention the type and number of GPUs used.
29-
- [ ] **DeepSpeed Configuration:** If any modifications were made to the default DeepSpeed config, specify them here. (You may include the config as a code block.)
29+
- [ ] **DeepSpeed Configuration** (if used): If any modifications were made to the default DeepSpeed config, specify them here. (You may include the config as a code block.)
3030
- [ ] **Other Details:** Any additional setup details crucial for reproducing your method.
3131

3232
To replicate your results, provide a `run.sh` script that contains all necessary commands to reproduce the final results. Ensure the script is well-documented.

community/methods/template/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Please include the experimental setup such as
1111

1212
- [ ] **Hyperparameters & Search Space:** Specify key hyperparameters, their search ranges, number of trials etc.
1313
- [ ] **Computational Setup:** Mention the type and number of GPUs used.
14-
- [ ] **DeepSpeed Configuration:** If any modifications were made to the default DeepSpeed config, specify them here. (You may include the config as a code block.)
14+
- [ ] **DeepSpeed Configuration** (if used): If any modifications were made to the default DeepSpeed config, specify them here. (You may include the config as a code block.)
1515
- [ ] **Other Details:** Any additional setup details crucial for reproducing your method.
1616

1717
# Results

configs/experiment/examples/muse_unlearn.yaml

+115-35
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ trainer:
2222
per_device_train_batch_size: 4
2323
per_device_eval_batch_size: 16
2424
gradient_accumulation_steps: 8
25-
learning_rate: 1.0e-05
25+
learning_rate: 3.0e-05
2626
bf16: true
2727
bf16_full_eval: true
2828
logging_steps: 5
2929
output_dir: ${paths.output_dir}
3030
logging_dir: ${trainer.args.output_dir}/logs
3131
report_to: tensorboard
32+
ddp_find_unused_parameters: None
33+
gradient_checkpointing: false
3234
optim: paged_adamw_32bit
3335
save_strategy: 'no'
3436
save_only_model: true
@@ -53,22 +55,20 @@ data:
5355
args:
5456
hf_args:
5557
path: muse-bench/MUSE-News
56-
name: train
58+
name: raw
5759
split: ${forget_split}
5860
text_key: text
59-
max_length: 128
60-
insert_space: true
61+
max_length: 2048
6162
retain:
6263
MUSE_retain:
6364
handler: PretrainingDataset
6465
args:
6566
hf_args:
6667
path: muse-bench/MUSE-News
67-
name: train
68+
name: raw
6869
split: ${retain_split}
6970
text_key: text
70-
max_length: 128
71-
insert_space: true
71+
max_length: 2048
7272
anchor: forget
7373
collator:
7474
DataCollatorForSupervisedDataset:
@@ -119,64 +119,144 @@ eval:
119119
handler: rouge
120120
rouge_type: rougeL_f1
121121
batch_size: 16
122+
retain_knowmem_ROUGE:
123+
datasets:
124+
MUSE_retain_knowmem:
125+
handler: QADataset
126+
args:
127+
hf_args:
128+
path: muse-bench/MUSE-${eval.muse.data_split}
129+
name: knowmem
130+
split: retain_qa
131+
few_shot_dataset_hf_args:
132+
path: muse-bench/MUSE-${eval.muse.data_split}
133+
name: knowmem
134+
split: retain_qa_icl
135+
question_key: question
136+
answer_key: answer
137+
max_length: 512
138+
predict_with_generate: true
139+
collators:
140+
DataCollatorForSupervisedDataset:
141+
handler: DataCollatorForSupervisedDataset
142+
args:
143+
padding_side: left
144+
index: index
145+
generation_args:
146+
do_sample: false
147+
top_p: null
148+
temperature: null
149+
max_new_tokens: 32
150+
use_cache: true
151+
stopwords:
152+
- '
153+
154+
155+
'
156+
- '
157+
158+
Question'
159+
- 'Question:'
160+
handler: rouge
161+
rouge_type: rougeL_f1
162+
batch_size: 16
163+
forget_verbmem_ROUGE:
164+
datasets:
165+
MUSE_forget_verbmem:
166+
handler: CompletionDataset
167+
args:
168+
hf_args:
169+
path: muse-bench/MUSE-${eval.muse.data_split}
170+
name: verbmem
171+
split: forget
172+
prefix_key: prompt
173+
text_key: gt
174+
max_length: 2048
175+
insert_space: true
176+
predict_with_generate: true
177+
collators:
178+
DataCollatorForSupervisedDataset:
179+
handler: DataCollatorForSupervisedDataset
180+
args:
181+
padding_side: left
182+
index: index
183+
generation_args:
184+
do_sample: false
185+
top_p: null
186+
temperature: null
187+
max_new_tokens: 128
188+
use_cache: true
189+
handler: rouge
190+
rouge_type: rougeL_f1
191+
batch_size: 8
122192
privleak:
123193
pre_compute:
124-
forget_minKpc_neg_logprob:
194+
mia_min_k:
125195
datasets:
126-
MUSE_forget_privleak:
127-
handler: PretrainingDataset
196+
MUSE_MIA_holdout:
197+
access_key: holdout
198+
handler: CompletionDataset
128199
args:
129200
hf_args:
130201
path: muse-bench/MUSE-${eval.muse.data_split}
131202
name: privleak
132-
split: forget
203+
split: holdout
133204
prefix_key: prompt
134205
text_key: text
135-
collators:
136-
DataCollatorForSupervisedDataset:
137-
handler: DataCollatorForSupervisedDataset
138-
args:
139-
padding_side: right
140-
index: index
141-
handler: minKpc_negative_logprob
142-
batch_size: 8
143-
k: 0.4
144-
access_key: forget
145-
holdout_minKpc_neg_logprob:
146-
datasets:
147-
MUSE_holdout_privleak:
148-
handler: PretrainingDataset
206+
max_length: 2048
207+
MUSE_MIA_forget:
208+
access_key: forget
209+
handler: CompletionDataset
149210
args:
150211
hf_args:
151212
path: muse-bench/MUSE-${eval.muse.data_split}
152213
name: privleak
153-
split: holdout
214+
split: forget
154215
prefix_key: prompt
155216
text_key: text
217+
max_length: 2048
156218
collators:
157219
DataCollatorForSupervisedDataset:
158220
handler: DataCollatorForSupervisedDataset
159221
args:
160222
padding_side: right
161223
index: index
162-
handler: minKpc_negative_logprob
163224
batch_size: 8
225+
handler: mia_min_k
164226
k: 0.4
165-
access_key: holdout
227+
access_key: forget
166228
reference_logs:
167229
retain_model_logs:
168230
path: ${eval.muse.retain_logs_path}
169231
include:
170-
forget_minKpc_neg_logprob:
232+
mia_min_k:
171233
access_key: retain
172-
holdout_minKpc_neg_logprob:
173-
access_key: holdout
174234
handler: privleak
175235
ref_value: 0.5
236+
extraction_strength:
237+
datasets:
238+
MUSE_forget_verbmem:
239+
handler: CompletionDataset
240+
args:
241+
hf_args:
242+
path: muse-bench/MUSE-${eval.muse.data_split}
243+
name: verbmem
244+
split: forget
245+
prefix_key: prompt
246+
text_key: gt
247+
max_length: 2048
248+
insert_space: true
249+
collators:
250+
DataCollatorForSupervisedDataset:
251+
handler: DataCollatorForSupervisedDataset
252+
args:
253+
padding_side: right
254+
index: index
255+
handler: extraction_strength
256+
batch_size: 8
176257
handler: MUSEEvaluator
177-
device: cuda
178258
output_dir: ${paths.output_dir}
179-
overwrite: false
259+
overwrite: true
180260
data_split: ${data_split}
181261
retain_logs_path: ${retain_logs_path}
182262
paths:
@@ -188,6 +268,6 @@ paths:
188268
data_split: News
189269
forget_split: forget
190270
retain_split: retain1
191-
retain_logs_path: saves/eval/muse_news_retain/MUSE_EVAL.json
192-
task_name: llama2_news_NPO
271+
retain_logs_path: saves/eval/muse_Llama-2-7b-hf_News_retrain/MUSE_EVAL.json
272+
task_name: muse_npo_unlearn
193273
mode: unlearn

0 commit comments

Comments
 (0)