Skip to content

Commit 9e3b9bb

Browse files
committed
docs: add missing updates from final_polish in ulf
1 parent 1ba64ea commit 9e3b9bb

File tree

6 files changed

+73
-54
lines changed

6 files changed

+73
-54
lines changed

README.md

+26-12
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ We provide several variants for each of the components in the unlearning pipelin
3838
| **Unlearning Methods** | GradAscent, GradDiff, NPO, SimNPO, DPO |
3939
| **Evaluation Metrics** | Verbatim Probability, Verbatim ROUGE, QA-ROUGE, MIA Attacks, TruthRatio, Model Utility |
4040
| **Datasets** | MUSE-News (BBC), MUSE-Books (Harry Potter), TOFU (different splits) |
41-
| **Model Families** | LLaMA 3.2, LLaMA 3.1, LLaMA-2, Phi-3.5, ICLM (from MUSE), Phi-1.5, Gemma |
41+
| **Model Families** | TOFU: LLaMA-3.2, LLaMA-3.1, LLaMA-2; MUSE: LLaMA-2, ICLM; Additional: Phi-3.5, Phi-1.5, Gemma |
4242

4343
---
4444

@@ -48,14 +48,17 @@ We provide several variants for each of the components in the unlearning pipelin
4848
-[Quickstart](#-quickstart)
4949
- 🛠️ [Environment Setup](#-environment-setup)
5050
- 💾 [Data Setup](#-data-setup)
51-
- 📜 [Running Baseline Experiments](#-running-baseline-experiments)
51+
- 🔄 [Updated TOFU benchmark](#-updated-tofu-benchmark)
5252
- 🧪 [Running Experiments](#-running-experiments)
5353
- 🚀 [Perform Unlearning](#-perform-unlearning)
5454
- 📊 [Perform an Evaluation](#-perform-an-evaluation)
55+
- 📜 [Running Baseline Experiments](#-running-baseline-experiments)
5556
-[How to Add New Components](#-how-to-add-new-components)
5657
- 📚 [Further Documentation](#-further-documentation)
5758
- 🔗 [Support & Contributors](#-support--contributors)
58-
- 📝 [Citation](#-citation)
59+
- 📝 [Citing this work](#-citating-this-work)
60+
- 🤝 [Acknowledgements](#-acknowledgements)
61+
- 📄 [License](#-license)
5962

6063
---
6164

@@ -79,6 +82,14 @@ python setup_data.py # populates saves/eval with evaluation results of the uploa
7982

8083
---
8184

85+
### 🔄 Updated TOFU benchmark
86+
87+
We've updated Open-Unlearning's TOFU benchmark target models to use a wider variety of newer architectures with sizes varying from 1B to 8B. These include LLaMA 3.2 1B, LLaMA 3.2 3B, LLaMA 3.1 8B, and the original LLaMA-2 7B from [the old version of TOFU](github.com/locuslab/tofu).
88+
89+
For each architecture, we have finetuned with four different splits of the TOFU datasets: `full`, `retain90`, `retain95`, `retain99`, for a total of 16 finetuned models. The first serves as the target (base model for unlearning) and the rest are retain models used to measure performance against for each forget split. These models are on [HuggingFace](`https://huggingface.co/collections/open-unlearning/tofu-new-models-67bcf636334ea81727573a9f0`) and the paths to these models can be set in the experimental configs or in command-line overrides.
90+
91+
---
92+
8293
## 🧪 Running Experiments
8394

8495
We provide an easily configurable interface for running evaluations by leveraging Hydra configs. For a more detailed documentation of aspects like running experiments, commonly overriden arguments, interfacing with configurations, distributed training and simple finetuning of models, refer [`docs/experiments.md`](docs/experiments.md).
@@ -107,12 +118,13 @@ python src/eval.py --config-name=eval.yaml experiment=eval/tofu/default \
107118
task_name=SAMPLE_EVAL
108119
```
109120

110-
- `experiment`-Path to the evaluation configuration [`configs/experiment/eval/tofu/default.yaml`](configs/experiment/eval/tofu/default.yaml).
121+
- `experiment`- Path to the evaluation configuration [`configs/experiment/eval/tofu/default.yaml`](configs/experiment/eval/tofu/default.yaml).
111122
- `model`- Sets up the model and tokenizer configs for the `Llama-3.2-1B-Instruct` model.
112123
- `model.model_args.pretrained_model_name_or_path`- Overrides the default experiment config to evaluate a model from a HuggingFace ID (can use a local model checkpoint path as well).
113124

114125
For more details about creating and running evaluations, refer [`docs/evaluation.md`](docs/evaluation.md).
115126

127+
116128
### 📜 Running Baseline Experiments
117129
The scripts below execute standard baseline unlearning experiments on the TOFU and MUSE datasets, evaluated using their corresponding benchmarks. The expected results for these are in [`docs/results.md`](docs/results.md).
118130

@@ -130,7 +142,7 @@ Adding a new component (trainer, evaluation metric, benchmark, model, or dataset
130142
Please feel free to raise a pull request for any new features after setting up the environment in development mode.
131143

132144
```bash
133-
pip install .[flash-attn, dev]
145+
pip install .[dev]
134146
```
135147

136148
## 📚 Further Documentation
@@ -152,11 +164,7 @@ Developed and maintained by Vineeth Dorna ([@Dornavineeth](https://github.com/Do
152164

153165
If you encounter any issues or have questions, feel free to raise an issue in the repository 🛠️.
154166

155-
## 📝 Citation
156-
157-
This repo is inspired from [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory). We acknowledge the [TOFU](https://github.com/locuslab/tofu) and [MUSE](https://github.com/jaechan-repo/muse_bench) benchmarks, which served as the foundation for our re-implementation.
158-
159-
---
167+
## 📝 Citing this work
160168

161169
If you use OpenUnlearning in your research, please cite:
162170

@@ -176,7 +184,7 @@ If you use OpenUnlearning in your research, please cite:
176184
}
177185
```
178186
<details>
179-
<summary>To cite other benchmarks used from OpenUnlearning</summary>
187+
<summary>Expand for bibtex to cite other benchmarks used from OpenUnlearning</summary>
180188

181189
```bibtex
182190
@article{shi2024muse,
@@ -188,8 +196,14 @@ If you use OpenUnlearning in your research, please cite:
188196
```
189197
</details>
190198

199+
---
200+
201+
### 🤝 Acknowledgments
202+
203+
- This repo is inspired from [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory).
204+
- The [TOFU](https://github.com/locuslab/tofu) and [MUSE](https://github.com/jaechan-repo/muse_bench) benchmarks served as the foundation for our re-implementation.
191205

192206
---
193207

194-
## 📄 License
208+
### 📄 License
195209
This project is licensed under the MIT License. See the [`LICENSE`](LICENSE) file for details.

docs/components.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ A benchmark, aggregates various evaluation metrics into a suite, e.g. TOFU, MUSE
142142

143143
## Model
144144

145-
To add a new model:
145+
To add a new model architecture:
146146

147147
### Implement and register a handler
148-
For all the models currently supported, HuggingFace's `AutoModelForCausalLM` and `AutoTokenizer` are used, and therefore the user doesn't need to add or register any handler.
148+
For all the models currently supported, HuggingFace's `AutoModelForCausalLM` and `AutoTokenizer` are used, and therefore the user doesn't need to create or register any handler.
149149

150150
__Note__: Currently, we do not support loading models modified with LoRA and related variants. If you wish use such features, please create define and register model handlers for this logic in [`src/model`](../src/model) and provide the config info as discussed next.
151151

@@ -233,7 +233,12 @@ defaults: # load pre-defined configs for model, trainer, data format, datasets e
233233
- override /eval: tofu
234234
235235
# Now, we have to further modify specific arguments from the defaults imported above
236-
# This enables to easily run multiple experiments varying hyper paramters, data splits, models etc
236+
# This enables easily running multiple experiments varying hyper paramters, data splits, models etc
237+
238+
model:
239+
model_args: # use our finetuned target models for the TOFU benchmark task
240+
pretrained_model_name_or_path: open-unlearning/tofu_Llama-3.2-1B-Instruct_full
241+
237242
forget_split: forget10
238243
retain_split: retain90
239244
retain_logs_path: null

docs/evaluation.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ python src/eval.py --config-name=eval.yaml \
1818
model.model_args.pretrained_model_name_or_path=<LOCAL_MODEL_PATH> \
1919
task_name=SAMPLE_EVAL
2020
```
21-
- `--config-name=eval.yaml`-sets task to be [`configs/eval.yaml`](../configs/eval.yaml)
22-
- `experiment=eval/tofu/default`-set experiment to use [`configs/eval/tofu/default.yaml`](../configs/eval/tofu/default.yaml)
23-
- `model=Llama-3.2-3B-Instruct`-override the default (`Llama-3.2-1B-Instruct`) model config to use [`configs/model/Llama-3.2-3B-Instruct`](../configs/model/Phi-3.5-mini-instruct.yaml).
21+
- `--config-name=eval.yaml`- sets task to be [`configs/eval.yaml`](../configs/eval.yaml)
22+
- `experiment=eval/tofu/default`- set experiment to use [`configs/eval/tofu/default.yaml`](../configs/eval/tofu/default.yaml)
23+
- `model=Llama-3.2-3B-Instruct`- override the default (`Llama-3.2-1B-Instruct`) model config to use [`configs/model/Llama-3.2-3B-Instruct`](../configs/model/Phi-3.5-mini-instruct.yaml).
2424

2525

2626
Run the MUSE-Books benchmark evaluation on a checkpoint of a Phi-3.5 model:
@@ -80,12 +80,12 @@ def forget_quality(model, **kwargs):
8080
return {"agg_value": pvalue}
8181

8282
```
83-
- `@unlearning_metric(name="rouge")`-Defines a `rouge` handler.
83+
- `@unlearning_metric(name="rouge")` - Defines a `rouge` handler.
8484

8585
#### 2. Register the metric handler
8686
Register the handler to link the class to the configs via the class name in [`METRIC_REGISTRY`](../src/evals/metrics/__init__.py).
8787

88-
Example: Registering `rouge` handler
88+
Example: Registering the `rouge` handler
8989

9090
```python
9191
from evals.metrics.memorization import rouge
@@ -150,7 +150,7 @@ reference_logs:
150150
forget_truth_ratio: # keys to include from the logs
151151
access_key: retain # name of the key to access it inside metric
152152
153-
# since the forget_quality metric depends on another metric, truth ratio
153+
# since the forget_quality metric depends on another metric (truth ratio)
154154
pre_compute:
155155
forget_truth_ratio:
156156
access_key: forget

docs/experiments.md

+14-18
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,31 @@ At the core, three main Hydra configs—`train.yaml` (generic training), `eval.y
1414
---
1515

1616
### Table of Contents
17-
- [Configuring and running experiments](#configuring-and-running-experiments)
18-
- [Overview](#overview)
19-
- [Table of Contents](#table-of-contents)
20-
- [Example Commands](#example-commands)
21-
- [Commonly Overridden Arguments](#commonly-overridden-arguments)
22-
- [Model Settings](#model-settings)
23-
- [Trainer Settings](#trainer-settings)
24-
- [Data Settings](#data-settings)
25-
- [Experiment Settings](#experiment-settings)
26-
- [Simple Finetuning](#simple-finetuning)
27-
- [Distributed Training](#distributed-training)
17+
- [Overview](#overview)
18+
- [Table of Contents](#table-of-contents)
19+
- [Example Commands](#example-commands)
20+
- [Commonly Overridden Arguments](#commonly-overridden-arguments)
21+
- [Model Settings](#model-settings)
22+
- [Trainer Settings](#trainer-settings)
23+
- [Data Settings](#data-settings)
24+
- [Experiment Settings](#experiment-settings)
25+
- [Simple Finetuning](#simple-finetuning)
26+
- [Distributed Training](#distributed-training)
2827

2928
---
3029

3130
## Example Commands
3231

3332
```bash
3433
## runs a finetuning using experiment details from configs/finetune/tofu/default.yaml
35-
python src/train.py --config-name=train.yaml experiment=finetune/tofu/default \
36-
task_name=SAMPLE_TRAIN
34+
python src/train.py --config-name=train.yaml experiment=finetune/tofu/default task_name=SAMPLE_TRAIN
3735

3836
## runs an unlearning training using experiment details from configs/unlearn/tofu/default.yaml
39-
python src/train.py --config-name=unlearn.yaml experiment=unlearn/tofu/default \
40-
task_name=SAMPLE_TRAIN
37+
python src/train.py --config-name=unlearn.yaml experiment=unlearn/tofu/default task_name=SAMPLE_TRAIN
4138

4239

4340
## runs an evaluation using experiment details from configs/eval/muse/default.yaml
44-
python src/eval.py --config-name=eval.yaml experiment=eval/muse/default \
45-
task_name=SAMPLE_EVAL
41+
python src/eval.py --config-name=eval.yaml experiment=eval/muse/default task_name=SAMPLE_EVAL
4642
## Note: eval.yaml is the default config set in src/eval.py, so this argument can be omitted
4743

4844
## an extensively filled out configuration for an unlearning experiment
@@ -249,5 +245,5 @@ CUDA_VISIBLE_DEVICES=0,1 accelerate launch \
249245
**Note:** Evaluation runs are designed to work only a single GPU (this includes running evaluation during training). To run an evaluation job, modify your command to make only one GPU visible (assuming one GPU is enough for inference):
250246

251247
```bash
252-
CUDA_VISIBLE_DEVICES=0 python src/eval.py experiment=eval/muse/default.yaml task_name=DISTRIBUTED_EVAL
248+
CUDA_VISIBLE_DEVICES=0 python src/eval.py experiment=eval/muse/default.yaml task_name=SAMPLE_EVAL
253249
```

docs/hydra.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ defaults:
1414
# , setting up data structure for loading data during unlearning
1515
- override /eval: muse # loads MUSE evaluation suite from eval/muse.yaml into the eval attribute
1616

17+
# define variables
1718
data_split: News
1819
forget_split: forget
1920
retain_split: retain1
@@ -54,23 +55,25 @@ trainer:
5455
# optim: paged_adamw_32bit
5556
# optim: adamw_torch
5657

57-
task_name: ???
58+
task_name: ??? # ??? raises and error if this attribute is not set
5859
```
60+
- **Structure & Attribute Access:** Configs are written in YAML and structured hierarchically like a dictionary. Attributes are accessed using dot notation: In code `cfg.model.args.learning_rate`, in command-line: `model.args.learning_rate=1e-5`.
5961

60-
- **Defaults & Overrides:** Base configurations are overridden using the `defaults` list.
62+
- **Defaults & Overrides:** Configs are files are included in one another using `defaults` and `override` commands.
63+
64+
- **Command-Line Overrides:** Any parameter can be overridden directly from the command line. For instance:
65+
```bash
66+
python src/train.py --config-name=unlearn.yaml experiment=unlearn/muse/default \
67+
trainer.args.num_train_epochs=50 data_split=Books trainer=SimNPO trainer.method_args.beta=3 \
68+
task_name=unlearn_muse_simnpo
69+
```
6170

6271
- **Package Directives:** The `# @package` directive organizes configurations into namespaces for cleaner composition and specifies the configuration path. At the head of a YAML file, you might see directives like `# @package _global_` or more specific ones such as `# @package eval.muse.metrics.forget_knowmem_ROUGE` which inform Hydra exactly where the configuration parameters should be placed within the final composed config.
6372

6473
For example, refer [`configs/eval/muse_metrics/forget_knowmem_ROUGE.yaml`](../configs/eval/muse_metrics/forget_knowmem_ROUGE.yaml)
6574

6675
- **Variable Substitution:** Variables are defined once and reused using the `${}` syntax:
6776

68-
- **Command-Line Overrides:** Any parameter can be overridden directly from the command line. For instance:
69-
```bash
70-
python src/train.py --config-name=unlearn.yaml experiment=unlearn/muse/default \
71-
trainer.args.num_train_epochs=50 data_split=Books trainer=SimNPO trainer.method_args.
72-
```
73-
7477

7578
To understand the structure of an evaluation config and the available parameters for overriding, refer to: [`configs/experiment/examples/tofu_eval.yaml`](../configs/experiment/examples/tofu_eval.yaml).
7679

docs/results.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
</div>
66

7-
The scripts below execute standard baseline unlearning experiments on the TOFU and MUSE datasets, evaluated using their corresponding benchmarks.
7+
The scripts below execute standard baseline unlearning experiments on the TOFU and MUSE datasets, evaluated using their corresponding benchmarks.
88
```bash
99
bash scripts/tofu_unlearn.sh
1010
bash scripts/muse_unlearn.sh
@@ -27,7 +27,8 @@ __Note:__
2727
2. NPO in MUSE: for NPO, the MUSE implementation is inconsistent with the [original paper](https://github.com/licong-lin/negative-preference-optimization) as discussed [here]( https://github.com/jaechan-repo/muse_bench/issues/2). This inconsistency is carried over into implementations like [SimNPO](https://github.com/OPTML-Group/Unlearn-Simple/issues/5). Here, we use the original NPO implementation with the same loss function expression across datasets.
2828

2929

30-
### TOFU unlearning on `Llama-2-7b-hf-chat`
30+
31+
### TOFU unlearning on the `Llama-2-7b-hf-chat` architecture
3132

3233
<div style="overflow-x: auto; max-width: 100%;"t>
3334
<table class="dataframe">
@@ -144,7 +145,7 @@ __Note:__
144145
</div>
145146

146147

147-
### TOFU unlearning on `Llama-3.2-1B-Instruct`
148+
### TOFU unlearning on the `Llama-3.2-1B-Instruct` architecture
148149

149150
<div style="overflow-x: auto; max-width: 100%;">
150151
<table class="dataframe">
@@ -261,7 +262,7 @@ __Note:__
261262
</div>
262263

263264

264-
### MUSE unlearning on `Llama-2-7b-hf`
265+
### MUSE unlearning on the benchmark's target models
265266

266267
<div style="overflow-x: auto; max-width: 100%;">
267268
<table class="dataframe">
@@ -299,11 +300,11 @@ __Note:__
299300
<th>Retain</th>
300301
<td>0.33</td>
301302
<td>0.21</td>
302-
<td>0.0</td>
303+
<td>0</td>
303304
<td>0.56</td>
304305
<td>0.3</td>
305306
<td>0.14</td>
306-
<td>0.0</td>
307+
<td>0</td>
307308
<td>0.69</td>
308309
</tr>
309310
<tr>
@@ -355,4 +356,4 @@ __Note:__
355356
</tr>
356357
</tbody>
357358
</table>
358-
</div>
359+
</div>

0 commit comments

Comments
 (0)