wikillm

Paper · 2023-10-31 · cs.CL, cs.AI

Unlearn What You Want to Forget: Efficient Unlearning for LLMs

Trains small unlearning layers on a frozen T5 model with a selective teacher-student KL objective, then merges them in closed form to handle a sequence of deletion requests. Author-reported on IMDB (T5-base, 0.5% forgotten): forget-set accuracy 65.7 vs 92.5 for re-training, at 1200 s vs 6685 s. The official repo has no unlearning code at the pinned commit.

Machine unlearningParameter-efficient fine-tuningMembership inferenceModel editingmachine-unlearningprivacyright-to-be-forgottenadapterst5

arXivPDFCodeMarkdown15 min read

AI-compiled by claude-haiku-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Sometimes a model has learned from data that someone later asks to have removed, for privacy reasons. Retraining the whole model without that data is the clean fix, but for a large model it is slow and expensive. This paper asks whether the model can instead be adjusted so that it behaves as if it never saw that data, while still doing its job well.

The approach keeps the big model fixed and adds a small, separate piece that is trained only to forget. The training pushes the model's answers on the data to keep toward the original model's answers, and pushes its answers on the data to forget away from them. A second term keeps the model good at its real task, and a third term makes the forgotten text harder to recover from the model's word-filling ability. Each new deletion request gets its own small piece, and a final step combines these pieces into one, so that several requests can be handled in turn.

The authors test this on two text tasks, sentiment classification of movie reviews and summarising chat conversations, using two sizes of the T5 model. The tests simulate requests to delete all data tied to a given person or name.

TL;DR

  • Add small unlearning layers to a frozen T5 model and train them with a selective teacher-student KL objective, a task loss on retained data and a negated masked-LM loss on forgotten data §3.1 eq. 5.
  • Several unlearning layers are merged into one by a closed-form least-squares formula over stored Gram matrices, so no data is kept and no retraining is needed §3.2 eq. 6 eq. 7.
  • Author-reported: on IMDB with T5-base, forget-set accuracy falls to 65.7 at 0.5% forgotten, against 92.5 for re-training, and the update takes 1200 s against 6685 s tab. 2.
  • MEND is faster in every block of the main tables tab. 2 tab. 3, and MEND is not evaluated on SAMSum §4.3.
  • The official repository, at the pinned commit, has no unlearning code. Implement from the paper and the equations here README.md.

Problem

Privacy rules such as the GDPR and CCPA require that personal data can be deleted on request §1. For an LLM that has memorised such data, the exact fix is to retrain without it. The paper says this is extremely expensive for large models §2.2. The SISA method trains on isolated shards and retrains only the affected shard, but it needs a lot of storage §1 and gets lower accuracy in the authors' runs §4.5. Differentially private training slows convergence and can hurt accuracy §1. Methods of both kinds must redo the whole model, so they do not handle a sequence of deletion requests well §1 §2.2.

The paper's goal is a method that is efficient, handles a sequence of deletions, and keeps task accuracy §1 §3.

Method

Setting. The base model F is trained on data D = {(x, y)}. A deletion request gives a forget set D^f, and the retained data is D^r = D − D^f. The target is a model F' with mutual information between F's and F''s outputs that is zero on D^f and one on D^r eq. 1 §3. The paper does not state how this is tested in practice. Its experiments use output accuracy, MLM loss, and a membership attack instead §4.2 §4.6.

Unlearning layer. The new model is F'(·) = F(f(·)). The adapter f(·; W) has far fewer parameters than F, and only f is updated, while the LLM stays frozen §3.1. The layers are plugged into transformer layers after the feed-forward networks fig. 1. The paper tunes 0.5% of the parameters §4.4.

Selective teacher-student KL eq. 2. The KL term rewards the student for matching the teacher on retained data and rewards it for diverging from the teacher on forget data. A hyperparameter alpha balances the two §3.1. The paper states the formula as written in eq. 2, with a minus sign on the forget term.

Task loss eq. 3. On retained data, a task loss keeps performance. For classification this is cross-entropy §3.1.

Negated LM loss eq. 4. On forget data, the original pre-training objective is negated, so the forgotten text becomes harder to predict. For T5 the masked-LM loss is used, with the instruction "Predict the masked word" prepended to the input §3.1.

Total objective eq. 5. The three terms are combined with weights lambda and gamma §3.1 eq. 5. The paper optimises this min-max form by alternating an epoch on retained data with an epoch on forget data §3.1. The paper does not say which terms are computed on which epoch. The pseudocode below assigns each term to the data it is defined on; this is the card's reading, not the paper's wording.

Fusion eq. 6 eq. 7. For each forget set i, a layer f_i with weights W_i is learned. The fused layer W_m minimises the squared difference between its output and each f_i's output on the forget inputs X_i^f eq. 6. The closed form is W_m = (Σ_i X_i^T X_i)^{-1} Σ_i X_i^T X_i W_i eq. 7. Only the Gram matrices X_i^T X_i of the hidden states before the unlearning layers are stored, not the data §3.2. Fusion needs no extra training §3.2.

Steps for one deletion request (pseudocode follows eq. 2 to eq. 5 and the alternation in §3.1):

Pseudocode
# Learn one unlearning layer for one deletion request  [§3.1] [eq. 5]
# Input:  teacher (frozen F); adapter (weights W); retained and forgotten
#         data; alpha, lam, gam (hyperparameters)
# Output: trained adapter weights W

def train_unlearning_layer(
    teacher, adapter, retained, forgotten, alpha, lam, gam
):
    # Alternate: one epoch on retained data, then one on forgotten  [§3.1]
    for each round:
        for batch in retained:
            # Student follows teacher on retained data  [eq. 2]
            kl_retain = KL(teacher(batch) || student(batch))
            # Task loss keeps accuracy on retained data  [eq. 3]
            task_loss = loss(student(batch), labels(batch))
            update(adapter, alpha * kl_retain + lam * task_loss)
        for batch in forgotten:
            # Student moves away from teacher on forgotten data  [eq. 2]
            kl_forget = KL(teacher(batch) || student(batch))
            # Negated masked-LM loss, with the masking prefix  [eq. 4] [§3.1]
            lm_loss = -masked_lm_loss(student(prefixed(batch)))
            update(adapter, -kl_forget + gam * lm_loss)
    return adapter
Pseudocode
# Fuse the unlearning layers of several deletion requests  [§3.2] [eq. 7]
# Input:  weights[i] (d, d_out) per request; grams[i] = X_i^T X_i (d, d)
# Output: fused weights W_m (d, d_out)

def fuse_unlearning_layers(weights, grams):
    # Sum of the stored Gram matrices over all forget sets  [eq. 7]
    total_gram = sum(grams)
    # Sum of each Gram matrix times its layer's weights  [eq. 7]
    weighted_sum = sum(grams[i] @ weights[i] for i in requests)
    # Closed-form solution, written with an inverse in the paper  [eq. 7]
    return inverse(total_gram) @ weighted_sum

Key equations, verbatim where the exact form matters:

L_{KL} = \alpha \sum_{x^r} KL(F(x^r)||F(f(x^r))) - \sum_{x_f} KL(F(x^f)||F(f(x^f))) eq. 2

L_{EUL} = L_{KL} + \lambda L_{TASK} + \gamma L_{LM} eq. 5

W_m = (\sum_i {X^f_i}^TX^f_i)^{-1}\sum_i({X^f_i}^TX^f_iW_i) eq. 7

Hyperparameters

NameValueWhereNotes
BackbonesT5-base and T5-3b§4.4pre-trained, fine-tuned on each task first
Trainable share0.5% of parameters§4.4unlearning layers only; adapter architecture not stated
alpha0.8§4.4grid search over {0.1, 0.2, 0.5, 0.8, 1.0}; search split not stated
lambda1.0§4.4same grid
gamma0.2§4.4same grid
LR schedulelinear decay, warmup ratio 0.06§4.4optimizer not stated
Max learning rate5e-5§4.4
Epochs3 or 5§4.4which setting uses which not stated
Max sequence length128 (IMDB), 800 (SAMSum)§4.4
Batch size, IMDB256 (base), 128 (3b)§4.4
Batch size, SAMSum8 (base), 2 (3b)§4.4
Forget sizes0.5%, 1%, 10% of training data§4.5IMDB and SAMSum
Mislabelled setting10% of labels randomly changed§4.5IMDB, T5-base only
Random runs5 (IMDB), 3 (SAMSum)tab. 2 tab. 3 tab. 4no spread reported
Hardware8 A100 GPUs§4.4per-method hardware split not stated
Retain/forget alternationone epoch retain, then one epoch forget§3.1rounds count not stated
Model input prefix"Predict the masked word"§3.1
Fusionclosed form, no extra training§3.2regularisation not stated
Baseline SISA splitas in Kumar et al.§4.4shard count not stated

Dataset sizes, as split counts tab. 1:

  • IMDB, classification: 20000 training, 2000 dev, 25000 test examples.
  • SAMSum, summarization: 14732 training, 818 dev, 819 test examples.

Results

Author-reported. Setup: T5-base and T5-3b, fine-tuned on each dataset; baselines Re-train, Fine-tune, SISA, Reverse-Gradient and MEND §4.3. The paper marks the best value per block in bold; those marks are not reproduced here. Columns are the paper's: Test and Retained are accuracy (IMDB) or ROUGE-1/2/L (SAMSum), Forgot is the same metric on the forget set (lower is better), MLM loss is higher when the forgotten information is harder to extract, and time is the update time in seconds §4.2. EUL is the paper's method (marked † in the paper).

IMDB, full tab. 2

ModelForgot dataMethodTestRetainedForgotMLM lossTime (s)
T5-base-Original93.21001001.46-
T5-base0.5%Re-train92.810092.51.526685
T5-base0.5%Fine-tune93.010096.51.474200
T5-base0.5%SISA92.498.291.51.541580
T5-base0.5%Reverse-Gradient92.097.368.61.564400
T5-base0.5%MEND92.298.573.51.6034
T5-base0.5%EUL93.010065.71.781200
T5-base1%Re-train92.710091.61.556610
T5-base1%Fine-tune92.810096.21.483950
T5-base1%SISA92.298.190.41.552930
T5-base1%Reverse-Gradient91.596.467.41.594166
T5-base1%MEND91.395.574.61.6262
T5-base1%EUL93.010064.41.841526
T5-base10%Re-train92.110090.21.566026
T5-base10%Fine-tune92.010095.81.523133
T5-base10%SISA91.698.288.41.552010
T5-base10%Reverse-Gradient91.096.565.41.623228
T5-base10%MEND90.894.876.21.66328
T5-base10%EUL92.299.057.22.011828
T5-3b-Original97.01001001.28-
T5-3b0.5%Re-train96.610094.81.3026855
T5-3b0.5%Fine-tune96.710096.21.2820465
T5-3b0.5%SISA95.097.294.11.3316503
T5-3b0.5%Reverse-Gradient93.396.578.91.4221826
T5-3b0.5%MEND93.095.889.51.304980
T5-3b0.5%EUL96.510070.21.669240
T5-3b1%Re-train96.310094.21.3025280
T5-3b1%Fine-tune96.510096.01.2818466
T5-3b1%SISA93.896.892.71.3515680
T5-3b1%Reverse-Gradient92.596.080.11.4618800
T5-3b1%MEND92.895.084.41.486600
T5-3b1%EUL96.510067.51.729840
T5-3b10%Re-train96.010093.51.3122140
T5-3b10%Fine-tune96.210094.01.3016752
T5-3b10%SISA93.095.592.21.3514180
T5-3b10%Reverse-Gradient91.995.268.41.4617850
T5-3b10%MEND92.094.278.51.5012072
T5-3b10%EUL96.010060.81.9210460

SAMSum, full tab. 3

Cells are ROUGE-1/2/L. MEND has no row because the authors could not design the editing target for summarization §4.3.

ModelForgot dataMethodTestRetainedForgotMLM lossTime (s)
T5-base-Original47.2/23.5/39.671.4/42.6/62.770.2/42.2/62.71.37-
T5-base0.5%Re-train46.8/23.0/38.171.7/42.8/62.442.4/23.2/42.01.4028000
T5-base0.5%Fine-tune46.6/23.2/38.172.5/44.7/65.258.8/34.1/54.11.3827120
T5-base0.5%SISA44.2/22.0/37.470.5/41.6/60.541.4/23.0/40.81.4822582
T5-base0.5%Reverse-Gradient43.2/20.9/35.868.8/40.2/58.542.3/21.4/38.11.6428800
T5-base0.5%EUL46.8/23.0/38.571.5/42.4/63.338.4/20.2/37.21.8817060
T5-base1%Re-train45.4/22.8/37.572.4/43.0/62.842.2/22.8/41.61.4426855
T5-base1%Fine-tune46.4/23.2/38.172.9/43.6/64.056.4/31.8/52.71.4027210
T5-base1%SISA43.1/21.1/36.869.8/40.2/60.041.4/23.0/40.81.5022420
T5-base1%Reverse-Gradient42.0/20.0/34.668.8/40.2/58.542.3/21.4/38.11.6427700
T5-base1%EUL46.5/22.8/38.071.5/42.4/63.335.8/19.0/36.21.9516820
T5-base10%Re-train44.2/21.2/35.870.4/41.2/60.541.4/21.4/40.01.4826155
T5-base10%Fine-tune45.2/22.1/36.671.1/42.6/62.951.5/28.6/50.01.4327510
T5-base10%SISA41.8/19.6/33.868.3/38.8/58.840.2/20.1/38.91.5520790
T5-base10%Reverse-Gradient40.8/18.4/33.066.6/38.3/55.538.0/19.4/36.61.7127240
T5-base10%EUL45.8/22.4/37.870.9/42.0/62.333.0/18.3/33.02.2315000
T5-3b-Original53.6/29.6/45.178.5/47.6/66.174.2/43.5/64.91.30-
T5-3b0.5%Re-train52.8/28.8/44.077.4/46.1/65.450.4/27.2/43.01.3484480
T5-3b0.5%Fine-tune53.3/29.0/44.478.0/47.1/65.860.2/36.1/55.71.3083600
T5-3b0.5%SISA51.7/27.2/40.874.8/44.8/63.549.4/26.8/42.21.3375000
T5-3b0.5%Reverse-Gradient50.6/25.9/39.972.8/42.0/62.844.3/23.1/39.01.4483200
T5-3b0.5%EUL53.6/29.4/44.877.5/46.3/66.641.0/21.8/38.21.6760430
T5-3b1%Re-train52.0/28.2/42.876.7/45.8/64.849.6/26.6/42.11.3582440
T5-3b1%Fine-tune52.5/28.5/43.676.2/45.5/64.256.8/32.2/52.41.3281135
T5-3b1%SISA50.0/26.1/38.972.3/43.1/61.149.0/25.8/41.11.3873550
T5-3b1%Reverse-Gradient48.6/24.3/37.270.6/41.5/60.942.2/22.0/37.71.4582485
T5-3b1%EUL53.3/29.0/44.476.4/45.3/64.338.4/19.9/36.01.7460880
T5-3b10%Re-train50.8/26.4/40.574.2/45.0/63.248.2/25.5/41.41.3881010
T5-3b10%Fine-tune51.4/27.2/41.975.2/45.3/64.052.1/29.8/49.91.3581800
T5-3b10%SISA48.2/24.5/36.070.4/40.5/59.641.2/23.5/40.01.4070400
T5-3b10%Reverse-Gradient44.7/22.0/34.268.5/40.9/58.840.9/21.0/36.51.4982070
T5-3b10%EUL52.0/28.4/42.674.9/45.0/63.636.2/18.6/34.71.7859900

IMDB, mislabelled training labels, T5-base tab. 4

10% of training labels were changed at random, and the model was asked to unlearn them. Columns: Test, Retained, Forgot, and update time in seconds. Averaged over 5 runs §4.5 tab. 4.

MethodTestRetainedForgotUpdating time (s)
Original91.810091.2-
Re-train92.510012.66026
Fine-tune92.310026.83133
SISA92.298.212.61510
Reverse-Gradient92.898.69.03228
MEND92.297.816.8328
EUL93.099.05.01828

Ablation, IMDB, T5-base, 0.5% forgotten tab. 5

Removing one objective at a time. Run count not stated.

MetricEUL-KL-TASK-LM
Test set93.091.491.092.4
Retained set10010097.499.0
Forgot set65.790.867.469.0
MLM loss1.781.751.781.50

Sequence of removals, IMDB, T5-base, single order tab. 6

Cells are Test/Retained accuracy after each step in the order set 2, set 1, set 3. Each set is 1% of the training data §4.5. The averaged curves for 1 to 5 sets are in fig. 2, not tabulated.

MethodSet 2Set 2, 1Set 2, 1, 3
Re-train92.7/91.492.5/90.891.3/90.0
Fine-tune92.8/96.092.1/94.091.0/93.3
SISA92.2/90.492.0/87.891.2/85.8
Reverse-Gradient91.5/67.990.5/67.289.8/66.0
EUL93.0/64.692.1/64.891.0/64.2
EUL-fuse93.0/64.692.8/62.292.4/60.8

EUL keeps one unlearning layer and trains it on each set in turn. EUL-fuse learns one layer per set and merges them with eq. 7 §4.5.

Membership attack, 1% forgotten, T5-base tab. 7

Accuracy of a classifier that tries to tell forgotten from retained inputs. Closer to 0.5 means harder to tell apart §4.6.

MethodIMDBSAMSum
Original0.5420.510
Re-train0.5500.522
Fine-tune0.5680.525
SISA0.5850.530
Reverse-Gradient0.6260.588
EUL0.5660.530

Paper vs code

The paper's abstract footnote links https://github.com/SALT-NLP/Efficient_Unlearning. The owner is SALT-NLP, the "SALT Lab" the acknowledgment thanks, and one of the authors is Diyi Yang. We cloned it at 6abab5ba7159586322da4e0184bf1e1a268dd288 and read it.

  • No unlearning code. The repository contains no implementation of the selective KL objective, the task or LM terms, the alternation, or the fusion. Searching all files for "unlearn" or "forgot" finds only the README. README.md says "The codes will be updated soon."
  • README commands do not exist. The README gives python src/run.py --unlearn ... and python src/run.py --merge ... README.md README.md. The path is src/models/run.py, and that script has no such arguments: it parses only the Hugging Face argument classes run.py.
  • The script is a generic classifier fine-tuner. It loads GLUE-style or local CSV/JSON classification data and adds a classification head run.py. It has no generation path, while the paper's SAMSum results use summarization with T5 §4.1.
  • Sequence length default. The default maximum length is 128 run.py. This matches the paper's IMDB setting §4.4, but not the 800 used for SAMSum §4.4. The paper's per-task settings are not in the code.
  • Adapter default. The adapter configuration defaults to "pfeiffer" training.py. The paper does not name an adapter architecture §4.4, so this cannot be checked against the paper, and the repository does not show whether it is the one used for the results.
  • Licence. The repository is Apache-2.0 LICENSE, which allows reuse and is not an NC or copyleft licence.

Net result: the code cannot be used to reproduce any table. Implement from the equations and tables above, and treat the numbers as author-reported.

Pitfalls

  • No reference code. Nothing at the pinned commit implements the method, so every design choice not stated in the paper (adapter architecture, optimizer, epoch-to-term mapping, stopping rule) is open. The code's README promises an update, so check the commit again before relying on it.
  • Faster claim. The results text says EUL updates faster than the previous unlearning baselines §4.5. MEND is faster in every block of both tables: for example 34 s vs 1200 s on IMDB T5-base at 0.5% tab. 2. The claim holds only against the other baselines.
  • Text and table disagree. The results text reports 65.6% forgot-set accuracy and "1/6 of the updating time" §4.5. The table value is 65.7 tab. 2.
  • Unbounded forget terms. The forget-side KL in eq. 2 and the negated LM loss in eq. 4 have no bound in the paper. The paper gives no clipping, early stopping, or stopping rule. The number of alternation rounds is not stated §3.1.
  • Term-to-epoch mapping. The paper does not say which terms are computed on the retain epoch and which on the forget epoch. The pseudocode assigns each term to the data it is defined on; the paper does not confirm this.
  • Hyperparameter search. alpha, lambda and gamma are chosen from one grid §4.4, but the split used for the search, and whether it was a full product grid, is not stated.
  • Epoch counts. The paper gives 3 or 5 epochs without saying which setting uses which §4.4. The optimizer is not named §4.4.
  • Fusion stability. The closed form in eq. 7 needs the summed Gram matrix to be invertible. The paper does not mention regularisation, a pseudo-inverse, or the matrix size. The formula also assumes each unlearning layer is linear in its input eq. 6 §3.2, while the adapter's internal structure is not stated in the paper, so the paper does not show that the closed form applies to the trained layer as used.
  • No bias term or activation stated for the fusion eq. 6, so an implementer should decide this and state it.
  • Gram matrices are the stored state. Fusion keeps one (d, d) Gram matrix per forget set §3.2. The memory cost for a given hidden size is not stated.
  • Name-based forget sets. For IMDB, entities are extracted with AllenNLP's pretrained NER §4.1. The model version is not stated, and the forget sets depend on its output. Names in dev and test are replaced by special tokens §4.1.
  • MEND is not run on SAMSum. The authors say MEND cannot be applied to summarization §4.3, so the SAMSum table has no MEND row tab. 3.
  • Few runs, no spread. Results average 5 runs (IMDB) or 3 runs (SAMSum) tab. 2 tab. 3. Standard deviations are not reported, and the ablation and sequence tables give no run count tab. 5 tab. 6.
  • Membership attack is weak evidence. The attack is barely above chance even before unlearning (0.542 on IMDB) §4.6 tab. 7. The paper concludes that the deleted data could not be easily inferred before or after unlearning §4.6. Because the classifier is near chance before unlearning, this result cannot show that forgetting happened.
  • Forgetting is measured by task accuracy. The paper's evaluation uses accuracy on the forget set and MLM loss. Whether the model can still recall or be identified from the forgotten content is left to future work §6.
  • Simulated requests only. All deletion requests are simulated §6. The paper does not test on real deletion workloads.
  • Mislabelled setting differs. The 10% mislabelled test tab. 4 asks the model to forget examples with wrong labels rather than privacy data §4.5. The paper only reports T5-base for it tab. 4.

Lineage

  • Builds on: the selective teacher-student formulation of Kurmanji et al. (2023), which the paper cites for its objective §3.1 eq. 2. Parameter-efficient adapters are cited from Houlsby et al. (2019) and Chien et al. (2023) §3.1.
  • Compared against: Re-train and Fine-tune, SISA §4.3 (Kumar et al., 2022), Reverse-Gradient (Liu et al., 2022) §4.3, and MEND (Mitchell et al., 2021), a model editor §4.3.
  • Related work: differential privacy methods §2.2, and model editing, which the paper contrasts with unlearning §2.2.
  • Superseded by: not known from this card's sources.

Source and license

Adapted from “Unlearn What You Want to Forget: Efficient Unlearning for LLMs” by Jiaao Chen, Diyi Yang (arXiv:2310.20150), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/SALT-NLP/Efficient_Unlearning at commit 6abab5ba7159 (Apache-2.0). Any quoted code is shown under that license.