Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

## 📖 Overview

We provide efficient and streamlined implementations of the TOFU, MUSE and WMDP unlearning benchmarks while supporting 15+ unlearning methods, 5+ datasets, 10+ evaluation metrics, and 7+ LLM architectures. Each of these can be easily extended to incorporate more variants.
We provide efficient and streamlined implementations of the TOFU, MUSE and WMDP unlearning benchmarks while supporting 16+ unlearning methods, 5+ datasets, 10+ evaluation metrics, and 7+ LLM architectures. Each of these can be easily extended to incorporate more variants.

We invite the LLM unlearning community to collaborate by adding new benchmarks, unlearning methods, datasets and evaluation metrics here to expand OpenUnlearning's features, gain feedback from wider usage and drive progress in the field.

Expand Down Expand Up @@ -84,7 +84,7 @@ We provide several variants for each of the components in the unlearning pipelin
| **Component** | **Available Options** |
|------------------------|----------------------|
| **Benchmarks** | [TOFU](https://arxiv.org/abs/2401.06121), [MUSE](https://muse-bench.github.io/), [WMDP](https://www.wmdp.ai/), [DUET](https://arxiv.org/abs/2602.19612) |
| **Unlearning Methods** | GradAscent, GradDiff, NPO, SimNPO, DPO, RMU, UNDIAL, AltPO, SatImp, WGA, CE-U, PDU, AdaPop, T3, PALU |
| **Unlearning Methods** | GradAscent, GradDiff, NPO, SimNPO, DPO, RMU, UNDIAL, AltPO, SatImp, WGA, CE-U, PDU, AdaPop, T3, PALU, K-FORGE |
| **Evaluation Metrics** | Verbatim Probability, Verbatim ROUGE, Knowledge QA-ROUGE, Model Utility, Forget Quality, TruthRatio, Extraction Strength, Exact Memorization, 6 MIA attacks, [Unlearning Depth Score](https://arxiv.org/abs/2605.24614), [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) |
| **Datasets** | MUSE-News (BBC), MUSE-Books (Harry Potter), TOFU (different splits), WMDP-Bio, WMDP-Cyber, [DUET](https://huggingface.co/datasets/SwetieePawsss/DUET) (rare / popular Wikidata facts) |
| **Model Families** | TOFU: Llama-3.2, Llama-3.1, Llama-2; MUSE: Llama-2; DUET: Llama-3.1, Qwen2.5, Gemma; Additional: Phi-3.5, Phi-1.5, Gemma, Zephyr |
Expand Down
83 changes: 83 additions & 0 deletions community/methods/KFORGE/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# K-FORGE: Fisher-Guided Initialization for Preference-Based LLM Unlearning (Findings of IJCNLP-AACL 2026)

- Authors: Daniil Moskovskiy (AIRI, Skoltech), Alexander Panchenko (Skoltech, AIRI)
- Paper code and experiments: https://github.com/etomoscow/kron_unlearn

## Method

K-FORGE (Kronecker-Fisher One-shot Rank-r Generalized Erasure) is a training-free, one-shot unlearning edit. For every regex-selected `torch.nn.Linear` layer (default: MLP `down_proj`), it estimates empirical K-FAC-style Kronecker factors on forget and retain calibration batches — `A = E[x xᵀ]` from layer inputs, `B = E[g gᵀ]` from output gradients — simultaneously diagonalizes the forget/retain pairs, applies a retain-aware Wiener filter with a retain budget (`lambda_tradeoff`), truncates to rank `r`, and folds the negative edit into the checkpoint. The only backward passes are the calibration passes; the edit itself is closed-form. Calibration currently runs single-process.

K-FORGE can be used in two ways:

1. **One-shot unlearning**: stronger edits lower Forget Q/A Probability but progressively spend Model Utility, so the raw edited model is a tunable trade-off rather than a free lunch.
2. **Initialization for iterative unlearning (recommended; the paper's headline usage)**: run NPO or SimNPO from the edited checkpoint. With setup time and FLOPs fully charged, K-FORGE-initialized NPO reduces Forget Q/A Probability by 22.3% (p = 0.007) and improves Model Utility while using less total wall time and compute than training from the pretrained checkpoint (TOFU `forget10`, Llama-3.2-1B-Instruct, n = 3).

## Setup

`run.sh` reproduces the two-stage flow on TOFU `forget10` with Llama-3.2-1B-Instruct:

- **Stage 1** computes the one-shot K-FORGE edit (`wiener_v2`, paper configuration) and saves the edited checkpoint under `saves/unlearn/tofu_kforge_edit`.
- **Stage 2** runs downstream unlearning from the edited checkpoint. Set `DOWNSTREAM_TRAINER=SimNPO` to use SimNPO instead of the default NPO; for a one-shot-only run, stop after stage 1.

```bash
bash community/methods/KFORGE/run.sh

# SimNPO downstream instead of NPO
DOWNSTREAM_TRAINER=SimNPO bash community/methods/KFORGE/run.sh
```

Strength `alpha` (`trainer.method_args.strength`) controls the utility/forgetting trade-off of the edit; the paper reports α ∈ {0.45, 0.60} for initialized runs and α ∈ [0.1, 0.8] for the one-shot sweep. Starting values around 0.45 are a reasonable default on 1B-scale models; increase `rank`, `strength`, and `max_calibration_batches` for stronger edits after checking memory use.

## Hyperparameters (paper configuration, TOFU `forget10`, Llama-3.2-1B-Instruct)

| Argument | Value | Notes |
|---|---|---|
| `target_modules_regex` | `.*mlp\.down_proj$` | Full-match regex over module names |
| `rank` | 2 | Truncated SVD rank per layer |
| `strength` | 0.45 (also 0.60) | Multiplier α on the negative edit |
| `edit_variant` | `wiener_v2` | Retain-aware Wiener edit (theorem-backed) |
| `lambda_tradeoff` | 0.01 | Retain-Fisher budget (used by `wiener_v2` only) |
| `max_target_modules` | 4 | Memory guard; set `null` for all matched modules |
| `max_calibration_batches` | 8 | Forget and retain batches for factor estimation |
| `edit_weight_dtype` | `float32` | Upcasts the model to fp32 before folding the edit, so small α·δ survive the `add_`; `preserve` keeps bf16, where a tiny α·δ can round to zero |
| `damping` | 1e-4 | Relative Tikhonov damping before Cholesky |

## Results

Primary endpoint: **Forget Q/A Probability** (probability of gold forget answers; lower is better). TOFU `forget10`, Llama-3.2-1B-Instruct, n = 3 seeds, mean ± std.

| Steps | Method | Init | Utility ↑ | Forget Prob. ↓ | Extraction ↓ |
|---|---|---|---|---|---|
| 50 | NPO | scratch | 0.509 ± 0.004 | 0.093 ± 0.001 | **0.068 ± 0.002** |
| | | K-FORGE (0.450) | 0.565 ± 0.003 | 0.047 ± 0.003 | 0.072 ± 0.003 |
| | | K-FORGE (0.600) | **0.574 ± 0.004** | **0.045 ± 0.003** | 0.071 ± 0.001 |
| | SimNPO | scratch | **0.577 ± 0.006** | 0.662 ± 0.003 | 0.270 ± 0.010 |
| | | K-FORGE (0.450) | 0.572 ± 0.007 | 0.542 ± 0.002 | 0.192 ± 0.002 |
| | | K-FORGE (0.600) | 0.571 ± 0.005 | **0.534 ± 0.002** | **0.188 ± 0.005** |
| 100 | NPO | scratch | 0.569 ± 0.009 | 0.043 ± 0.002 | **0.065 ± 0.003** |
| | | K-FORGE (0.450) | 0.587 ± 0.002 | **0.029 ± 0.002** | 0.073 ± 0.003 |
| | | K-FORGE (0.600) | **0.593 ± 0.005** | 0.031 ± 0.002 | 0.073 ± 0.003 |
| | SimNPO | scratch | **0.582 ± 0.002** | 0.518 ± 0.010 | 0.172 ± 0.013 |
| | | K-FORGE (0.450) | 0.579 ± 0.003 | 0.413 ± 0.008 | **0.143 ± 0.002** |
| | | K-FORGE (0.600) | 0.582 ± 0.002 | **0.407 ± 0.011** | 0.144 ± 0.005 |
| 250 | NPO | scratch | 0.595 ± 0.009 | 0.029 ± 0.002 | **0.064 ± 0.003** |
| | | K-FORGE (0.450) | 0.601 ± 0.003 | **0.021 ± 0.001** | 0.072 ± 0.003 |
| | | K-FORGE (0.600) | **0.603 ± 0.004** | 0.022 ± 0.001 | 0.074 ± 0.001 |
| | SimNPO | scratch | **0.596 ± 0.003** | 0.337 ± 0.005 | 0.116 ± 0.004 |
| | | K-FORGE (0.450) | 0.595 ± 0.001 | 0.276 ± 0.012 | 0.111 ± 0.003 |
| | | K-FORGE (0.600) | 0.592 ± 0.004 | **0.272 ± 0.008** | **0.110 ± 0.001** |

The one-time setup for one edited layer costs ≈ 81 s and 3.6 × 10¹⁴ FLOPs at 1B scale (≈ 7–8 downstream training steps); NPO comparisons above remain favorable with setup charged.

Known boundaries (reported in the paper): direct relearning recovers the forgotten data (no recovery resistance), MUSE gains vary by metric, and Qwen2.5-1.5B is unchanged at reported precision.

## Citation

```bibtex
@inproceedings{moskovskiy2026kforge,
title = {K-FORGE: Fisher-Guided Initialization for Preference-Based LLM Unlearning},
author = {Moskovskiy, Daniil and Panchenko, Alexander},
booktitle = {Findings of the Association for Computational Linguistics: ICJNLP-AACL 2026},
Comment thread
etomoscow marked this conversation as resolved.
Resolved
year = {2026}
}
```
36 changes: 36 additions & 0 deletions community/methods/KFORGE/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# K-FORGE on TOFU forget10 (Llama-3.2-1B-Instruct), paper configuration.
#
# Stage 1 computes the one-shot K-FORGE edit (wiener_v2) and saves the edited
# checkpoint under saves/unlearn/tofu_kforge_edit. Stage 2 runs downstream
# preference-based unlearning (NPO by default, SimNPO via DOWNSTREAM_TRAINER)
# initialized from the edited checkpoint. For a one-shot-only run, stop after
# stage 1.
set -euo pipefail

DOWNSTREAM_TRAINER="${DOWNSTREAM_TRAINER:-NPO}"
EDIT_TASK="${EDIT_TASK:-tofu_kforge_edit}"

# ---------------------------------------------------------------------------
# Stage 1: one-shot K-FORGE edit (wiener_v2, rank 2, alpha = 0.45, lambda = 0.01)
# ---------------------------------------------------------------------------
python src/train.py \
--config-name=unlearn \
experiment=unlearn/tofu/default \
trainer=KFORGE \
trainer.method_args.target_modules_regex='.*mlp\.down_proj$' \
trainer.method_args.rank=2 \
trainer.method_args.strength=0.45 \
trainer.method_args.edit_variant=wiener_v2 \
trainer.method_args.lambda_tradeoff=0.01 \
task_name="${EDIT_TASK}"

# ---------------------------------------------------------------------------
# Stage 2: downstream unlearning initialized from the edited checkpoint
# ---------------------------------------------------------------------------
python src/train.py \
--config-name=unlearn \
experiment=unlearn/tofu/default \
trainer="${DOWNSTREAM_TRAINER}" \
model.model_args.pretrained_model_name_or_path="saves/unlearn/${EDIT_TASK}" \
task_name="tofu_$(echo "${DOWNSTREAM_TRAINER}" | tr '[:upper:]' '[:lower:]')_from_kforge"
31 changes: 31 additions & 0 deletions configs/trainer/KFORGE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defaults:
- finetune

handler: KFORGE
args:
num_train_epochs: 1
max_steps: 1
save_strategy: 'no'
eval_strategy: 'no'
gradient_checkpointing: False
method_args:
target_modules_regex: .*mlp\.down_proj$
rank: 8
strength: 1.0
damping: 1e-4
damping_mode: fixed
adaptive_damping_coeff: 0.1
damping_floor: 1e-12
max_calibration_batches: 8
max_samples: null
normalize_factors: true
skip_modules_larger_than: null
max_target_modules: 4
factor_mode: kron
use_retain_fisher: true
spectrum_output_path: null
spectrum_top_k: 64
skip_edit: false
edit_variant: wiener_v2
lambda_tradeoff: 0.01
edit_weight_dtype: float32
1 change: 1 addition & 0 deletions docs/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Links to research papers and resources corresponding to implemented features in
| AdaPop | Paper [📄](https://arxiv.org/abs/2608.14229), Popularity-annotated data [🤗](https://huggingface.co/datasets/SwetieePawsss/DUET) |
| T3-Unlearning | Paper[📄](https://arxiv.org/abs/2602.10217), Code [🐙](https://github.com/jacob-block/T3-Unlearning) |
| PALU | Paper[📄](https://arxiv.org/abs/2601.03190) (Naixin Zhai, University of Science and Technology of China, 2601.03190, Code [🐙](https://github.com/nxZhai/PALU) |
| K-FORGE | Findings of IJCNLP-AACL 2026, Code [🐙](https://github.com/etomoscow/kron_unlearn) |


---
Expand Down
2 changes: 2 additions & 0 deletions src/trainer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from trainer.unlearn.adapop import AdaPop
from trainer.unlearn.t3 import T3
from trainer.unlearn.palu import PALU
from trainer.unlearn.kforge import KFORGE


import logging
Expand Down Expand Up @@ -105,3 +106,4 @@ def load_trainer(
_register_trainer(AdaPop)
_register_trainer(T3)
_register_trainer(PALU)
_register_trainer(KFORGE)
Loading
Loading