Who is Harry Potter? Approximate unlearning in large language modelsWho's Harry Potter? Approximate Unlearning in LLMs
The authors propose an approximate unlearning method and, on Llama2-7b, unlearn Harry Potter with about 1 GPU hour of fine-tuning; the authors state that general benchmarks are almost unaffected.
- LLM training corpora often contain copyrighted content, and retraining from scratch is too costly. The authors study whether generative models can approximately unlearn a specified subset using only compute commensurate with the size of the unlearning target.
- First continue training on the unlearning target to obtain a reinforced model, and use the difference between its logits and the baseline's to locate target-related tokens; then use the anchor terms dictionary extracted by GPT-4 to replace specific expressions with generic paraphrases, take the baseline model's predictions on the replaced text as generic labels, combine them according to the formula, and fine-tune the original model.
- Unlearning *Harry Potter* on Llama2-7b: completion familiarity drops from 0.290 to 0.007 (100 steps), general benchmarks are almost unchanged; the authors report a small amount of residual leakage (e.g., it can answer Hogwarts), and ablations show that reinforcement bootstrapping alone performs poorly.
- The authors note: prompt-based evaluation may not detect adversarial extraction; the method depends on GPT-4's existing knowledge of the original books; applicability to non-fiction, textbook-type content is unknown; and it may unlearn a superset of the target. Experiments were conducted only on two models, Llama2-7b and Phi-1.5, and on a single unlearning target.
- Evaluated models
- Meta-llama/Llama-7b-hf-chatMSFT/Phi-1.5
- Benchmarks
- ARCBoolQHellaSwagOpenBookQAPIQAWinoGrande300 条哈利·波特补全提示词30 条 token 概率提示词
- Metrics
- Familiarity (completion)Familiarity (probabilities)通用基准准确率
Ronen Eldan and Mark Russinovich of Microsoft Research propose an approximate unlearning method that removes part of a large language model's training data without retraining from scratch, and validated it on Meta's Llama2-7b by unlearning the Harry Potter book series. The method first compares the logits of a reinforced model further trained on the target data with those of a baseline model to locate the tokens most relevant to the unlearning target, then uses GPT-4 to extract about 1500 proper nouns and replace them with generic words, has the model generate replacement labels itself, and finally fine-tunes the baseline model with these labels. The authors state that about 150 steps of fine-tuning, about 1 GPU hour, can make the model largely stop generating or recalling the related content, while benchmarks such as ARC, BoolQ, HellaSwag, OpenBookQA, PIQA and WinoGrande are almost unaffected. The authors also note that a small amount of leakage remains, for example it still gives Hogwarts when asked to list fictional schools, and that the technique's effectiveness on non-fiction or textbook-like content is still uncertain.
Why it was selectedThe paper presents a procedure and benchmark comparison for making Llama2-7b approximately unlearn specific books with about 1 GPU hour of fine-tuning, which can serve as a reference for data compliance approaches.
Paper analysis
What problem does this paper attempt to solve?
How to make an LLM approximately unlearn a specified subset of its training data (e.g., Harry Potter) without retraining.
Core question: Can an already-trained generative LLM approximately unlearn a specified subset of its training corpus without retraining from scratch (the paper targets the Harry Potter series)?
- Problem setting and motivation: The authors note that LLM training corpora often contain copyrighted text, toxic content, personal data, etc., which has already prompted litigation and regulatory pressure; retraining from scratch is both time-consuming and resource-intensive, and impractical. The authors want the time and compute required for unlearning to scale with the size of the unlearning target rather than retraining the entire model.
- Shortcomings of existing methods: The authors state that most existing unlearning research targets classification tasks, with few works aimed at generative models or LLMs; the naive reversed loss approach performs poorly in this paper's setting—it harms general language ability (for example, unlearning generic expressions like "my name is"), and the gradient for high-probability tokens is small, requiring many steps to lower their probability.
- Core observation: The key to unlearning is not deleting the entity itself but severing the associations between entities (the authors use the links between "Harry Potter" and "magic" and "Hogwarts" as an example); for each token one needs to answer "what would a model that was not trained on the target data predict," i.e., the generic prediction.
- Contributions of the paper: It proposes a three-component approximate unlearning technique and, as a proof of concept, unlearns Harry Potter on Llama2-7b: the authors report that about 1 GPU hour of fine-tuning can eliminate the model's ability to generate or recall related content, with general benchmark performance almost unchanged (abstract). The authors state that this is, to the best of their knowledge, the first effective unlearning technique for generative language models ("to the best of our knowledge").
What related research exists?
Machine unlearning research mostly targets classification tasks, with few specific techniques for generative models; the authors position their work as approximate unlearning.
Machine unlearning surveys
- [JLZ+ 22], [NHN+ 22], [ZNIS23]—survey work in the field of machine unlearning. The paper notes that most work in this field focuses on classification tasks, and that literature aimed at generative models or LLMs is still scarce.
Challenges and directions for LLM unlearning
- [ZFBH+ 23]—discusses the challenges and impacts of the "right to be forgotten" in the era of large models, as well as high-level potential mitigation directions. The paper positions its own work as "approximate unlearning" within the framework discussed in that paper.
Specific unlearning techniques for generative models
- [JYY+ 22]—proposes an unlearning technique that is shown to mitigate privacy risk in certain privacy scenarios (i.e., the negative loss idea; the paper cites it when discussing naive methods to show that this idea is effective in privacy scenarios but performs poorly in this paper's scenario).
- [WCY+ 23]—proposes the knowledge-gap-alignment algorithm; the paper notes that it may be applicable to LLMs in some cases, but the assumptions it relies on do not appear to hold in this paper's scenario.
Baselines and benchmarks: the paper does not compare against baselines of other unlearning methods; general capability evaluation uses ARC, BoolQ, HellaSwag, OpenBookQA, PIQA, WinoGrande (run via the LM Harness Eval suite [GTB+ 21]), and unlearning effectiveness is evaluated with the authors' own 300 completion prompts and 30 token-probability prompts.
The authors position this paper as: providing a concrete, empirically effective approximate unlearning technique on generative LLMs, distinct from most existing work that focuses on classification tasks and from discussions that give only high-level directions.
How does the paper address this problem?
Use the reinforced model to locate target tokens and anchor terms to generate generic labels, then fine-tune the baseline model according to the combined logits.
Overall idea: for each token in the unlearn target, construct the "prediction a model that has not been trained on the target data would make" (generic prediction), and use this as the label to fine-tune the model. The method consists of three components: reinforcement bootstrapping, anchored terms, and fine-tuning that combines the two.
Problem setting
- The model is trained on dataset X, and a specified subset Y ⊂ X is designated as the unlearn target; the goal is to approximately simulate the effect of retraining on X \ Y, assuming the cost of retraining is unacceptable.
- The authors first explain why a naive negative loss does not work: it forgets general language knowledge unrelated to the target, and for high-probability tokens the cross-entropy gradient is small, so lowering their probability requires many steps; the most likely token will only switch among a few candidates related to the target.
Component one: reinforcement bootstrapping
- Continue training the baseline model on the unlearn target to obtain a reinforced model; it has deeper knowledge of the target content and tends to give target-related completions even when the prompt contains almost no target information.
- For the same context, take the logit vectors of the two models and compute the generic logits as vgeneric := vbaseline − α ReLU(vreinforced − vbaseline), and take the largest entry as the generic prediction; the meaning of ReLU is to use only the information of those tokens whose logits rose after reinforcement (Equation 1).
- The authors point out two flaws of using this component alone: when the probability ranking of two target-related tokens swaps after reinforcement, the formula instead pushes up one of them; and when the prompt already contains strong specific information, reinforcement barely changes the logits.
Component two: anchored terms
- Use GPT-4 to perform entity extraction on the unlearn target: input random passages, have it list expressions, names, or entities specific to the text, and provide alternative expressions that remain coherent but are not specific to the book; aggregate to obtain a dictionary of about 1,500 anchor terms and their generic translations (Section 2.2).
- Replace the anchor terms in each text chunk with their generic translations, run a forward pass of the baseline model on the replaced text, and obtain next-token predictions as generic predictions; the goal is to make the model's predictions on the original text match these generic predictions.
- Consistency handling: an anchor term that has already appeared in the same chunk is not counted in the loss from its second occurrence onward, and the logits of the corresponding translation tokens are lowered; the authors state that without this handling the model would produce inconsistent completions. The technical details of tokenization and source-target token alignment are not elaborated in the paper and are referred to its code repository.
Combination and fine-tuning procedure (Algorithm 1)
- Build the anchor terms dictionary.
- Chunk the text with a context length of 512 tokens; for each chunk, process the original text with the reinforced model and the replaced text with the baseline model.
- Combine the logits according to Equation 1 (α = 5), take the token with the largest logit as the label, and apply consistency handling.
- Fine-tune the baseline model with the original text as input and the generic labels as targets; the authors state that about 150 gradient descent steps suffice.
Key parameters and data (Section 2.4)
- Unlearning dataset: 2.1M tokens from the original books plus 1M tokens of synthesized discussions, blogs, and wiki-like entries.
- Reinforced model: Llama-7b-chat-hf fine-tuned on the unlearning dataset for 3 epochs, learning rate 3·10⁻⁶, batch size 8, gradient accumulation 16 steps.
- Final fine-tuning: 2 epochs, learning rate 10⁻⁶, batch size 8, gradient accumulation 16 steps.
- The authors note that the method may unlearn a superset of content beyond the target (such as Wikipedia entries discussing these books), and believe this can be recovered by further fine-tuning on related content.
What experiments did the paper conduct?
Unlearning Harry Potter on Llama2-7b: familiarity drops substantially, general benchmarks are almost unchanged, but there is a small amount of residual leakage.
Experimental setup
- Target model: Meta's Llama-7b-chat-hf (7B parameters); a second set of experiments was also run on a modified version of Microsoft Phi-1.5 (1.3B parameters, trained only on synthetic data)—the forgetting target was mixed into the training data to obtain a baseline model. The authors state that the results of the two are qualitatively very similar, and the main text shows only the former.
- Forgetting target: the original Harry Potter series books, 2.1M tokens, plus 1M tokens of synthetic discussion text.
- General capability benchmarks: ARC (challenge/easy), BoolQ, HellaSwag, OpenBookQA, PIQA, WinoGrande, run with the LM Harness Eval suite.
- Forgetting evaluation: completion-based uses 300 prompts (generated by GPT-4 based on random 300-word excerpts from the books, Appendix 6.2); probability-based uses 30 manually selected prompts, with candidate next tokens manually classified as idiosyncratic and generic, and the total probability of idiosyncratic tokens averaged over the prompts.
- Evaluation method: completions are classified by GPT-4 on a 0–3 scale (the scoring instructions are given in Appendix Figure 12), counting only the top two categories, with the first category multiplied by 5 and then aggregated; the authors state that GPT-4's accuracy on this task is insufficient, and during final training the completions were manually checked.
- Number of repetitions: not reported in the paper.
Main results
Figure 5 gives the familiarity scores and benchmark scores of Llama2-7b at different fine-tuning steps (0 steps is the baseline):
Swipe horizontally to read the table
Metric (Figure 5) 0 steps 40 steps 80 steps 120 steps Familiarity (completion) 0.290 0.020 0.007 0.007 Familiarity (probabilities) 0.244 0.022 0.011 0.006 ARC-challenge 0.440 0.420 0.416 0.414 ARC-easy 0.744 0.740 0.728 0.724 BoolQ 0.807 0.801 0.798 0.796 HellaSwag 0.577 0.565 0.560 0.557 OpenBookQA 0.338 0.332 0.334 0.328 PIQA 0.767 0.773 0.762 0.760 WinoGrande 0.663 0.669 0.665 0.657 - The authors state that after fine-tuning, the model does not show familiarity with the forgetting target in its answers to the vast majority of benchmark prompts, and that general benchmark scores are close to the baseline.
- Figure 3 shows how the next-token distribution for the prompt "Harry Potter studies" changes with fine-tuning: the probability of "magic" drops from 0.2241 at baseline through 0.0764 at 80 steps to 0.0000 at 120 steps, while "the" rises from 0.0859 to 0.5735.
- Figure 1 compares completions of the baseline and the fine-tuned model on 9 prompts: the fine-tuned model no longer gives characters and plot points from the books, and instead gives generic or fictional substitute content.
Residual leakage
- The authors report finding a small amount of leakage: for example, when asked to list fictional schools the model answers "Hogwarts", and when asked for "the word the wizarding world uses to insult those of non-magical origin" it still answers the original word (the last two examples in Figure 6).
- The authors state that this leakage amounts only to Wikipedia-level knowledge, rather than information obtainable only by reading the books; they speculate that the reason is that the forgetting target does not cover content outside the books (merchandise, theme parks, etc.), and that they cannot access the original model's training data.
Ablation experiments (Section 4.1)
- Reinforcement bootstrapping only (no anchoring): the drop in completion familiarity does not exceed a factor of 0.3 under any parameter combination, and it is completely ineffective on several basic prompts.
- Anchored terms only (α = 0): more effective than the former, but does not reach the level of the combined method; the authors performed a parameter search to find a model with the same familiarity as the combined method, and its general benchmarks are worse (e.g., ARC-challenge 0.40 vs. 0.416, WinoGrande 0.61 vs. 0.665, Section 4.1 compared with Figure 5).
Other analyses
- Open evaluation: the authors consider forgetting verification to be similar to jailbreaking and adversarial in nature, and that automated benchmarks and internal evaluations have limitations, so they open-sourced the fine-tuned model and invited the community to conduct adversarial testing (Section 3.3); the paper does not report the results of community testing.
- Token probability dynamics: Appendix Figures 7–10 give the next-token probability changes with steps for another 4 prompts, e.g., after "the scar on his" "fore" drops from 1.0000 to 0.1897 at 120 steps, while "hand" rises to 0.6210 (Figure 8).
What are some points that can be further explored?
The authors acknowledge that the evaluation may not detect adversarial extraction, that the method relies on GPT-4's prior knowledge, and that its applicability to non-fiction content is unknown.
Limitations and future directions noted by the authors
- Blind spots in evaluation (Conclusion): prompt- and completion-based evaluation may be ineffective against more adversarial ways of extracting information; for example, non-traditional means such as token probability distributions may expose the model's latent familiarity; the authors believe the best validation is adversarial probing and therefore release the model to the community for evaluation.
- Dependence on GPT-4's prior knowledge (Conclusion and footnote in Section 2.2): extracting anchor terms draws to some extent on GPT-4's existing knowledge of Harry Potter; the authors state that preliminary experiments show entity extraction remains effective without this knowledge, and speculate that n-gram frequency analysis could be used instead, leaving deeper study to future work.
- Applicability to content types (Introduction and Conclusion): the authors state that the technique may show limitations on other types of content such as non-fiction and textbooks—such content lacks high-density specific expressions and contains more abstract elements such as ideas and concepts, and whether it can be unlearned is uncertain and would require adapting the method.
- Unlearning scope may exceed the target (Section 2.3): the method may unlearn a superset of the target (e.g., Wikipedia entries discussing the original books); the authors believe this can be recovered by further fine-tuning on related content.
- Particularity of the target work itself (Conclusion): the authors note that Harry Potter is full of specific expressions and unique names, which in hindsight may have favored their unlearning strategy, and that the topic is widely present in the training data, so a slight prompt may elicit related completions.
Scope of experiments
- The models tested are Llama-7b-chat-hf and a modified Phi-1.5, 2 in total; the main text reports results only for the former (Section 4).
- There is only one unlearning target, the Harry Potter series (including 1M tokens of synthetic discussion text) (Section 2.4).
- Unlearning evaluation consists of 300 completion prompts plus 30 probability prompts; completion scoring is performed by GPT-4, and the authors state that manual checks were done for the final training; the paper does not report agreement figures between GPT-4 scoring and manual checks (Sections 3.2.1 and 6.2).
- The paper does not report the number of repetitions or variance of the experiments.
- The authors state that they open-sourced the fine-tuned model for community adversarial testing; the paper does not include results of community testing (Section 3.3).
Summarize the main content of the paper
A three-component approximate unlearning method that makes Llama2-7b forget *Harry Potter* in about 1 GPU hour with almost no change in general capabilities.
This is a methods paper on approximate unlearning for LLMs, with two authors from Microsoft Research and Microsoft Azure.
- Problem: Copyrighted and other content in training corpora brings legal and ethical risks, and retraining from scratch is too costly; the authors study whether generative models can approximately unlearn a specified subset using compute commensurate with the size of the unlearning target.
- Method: Three components—(1) continue training on the unlearning target to obtain a reinforced model, and use Equation 1 to compare its logits with the baseline's to locate target-related tokens; (2) use GPT-4 to extract about 1,500 anchor terms and replace them with generic paraphrases, taking the baseline model's predictions on the replaced text as generic labels; (3) fine-tune with the original text as input and the generic labels as targets (α = 5, about 150 steps).
- Main results: Unlearning Harry Potter on Llama2-7b reduces completion familiarity from 0.290 to 0.007 (100 steps, Figure 5) and probability familiarity from 0.244 to 0.006 (120 steps); general benchmarks are almost unchanged (e.g., WinoGrande 0.663→0.665, Figure 2); fine-tuning takes about 1 GPU hour, compared with 184K GPU-hours for pretraining (abstract).
- Negative results: The authors report a small amount of residual leakage (e.g., it can answer Hogwarts), which they speculate is because the unlearning target does not cover content outside the books; ablations show that with reinforcement bootstrapping alone familiarity drops by no more than a factor of 0.3, and with anchored terms alone general benchmarks are worse.
- Authors' conclusion: The authors state that this is, to their knowledge, the first effective unlearning technique for generative language models, but acknowledge that the evaluation may not detect adversarial extraction, that the method depends on GPT-4's prior knowledge, that applicability to non-fiction content is unknown, and they open-source the model and invite the community to conduct adversarial validation.