mlsanityData to 7 Oct 2026

Answer When Needed, Forget When Not: Language Models Pretend to Forget via In-Context Knowledge Unlearning

arXiv 2410.00382 ↗First posted 1 Oct 2024cs.CLcited by 7

On the map: LLM safety and security → Machine unlearning

Abstract (arXiv)

As large language models (LLMs) are applied across diverse domains, the ability to selectively unlearn specific information is becoming increasingly essential. For instance, LLMs are expected to selectively provide confidential information to authorized internal users, such as employees or trusted partners, while withholding it from external users, including the general public and unauthorized entities. Therefore, we propose a novel method termed ``in-context knowledge unlearning'', which enables the model to selectively forget information in test-time based on the query context. Our method fine-tunes pre-trained LLMs to enable prompt unlearning of target knowledge within the context, while preserving unrelated information. Experiments on TOFU, AGE and RWKU datasets using Llama2-7B/13B and Mistral-7B models demonstrate that our method achieves up to 95% forget accuracy while retaining 80% of unrelated knowledge, significantly outperforming baselines in both in-domain and out-of-domain scenarios. Further investigation of the model's internal behavior revealed that while fine-tuned LLMs generate correct predictions in the middle layers and preserve them up to the final layer. However, the decision to forget is made only at the last layer, i.e. ``LLMs pretend to forget''. Our findings offer valuable insight into the improvement of the robustness of the unlearning mechanisms in LLMs, laying a foundation for future research in the field.

Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). Placed in Machine unlearning, one of 12 directions in LLM safety and security. Builds on 14 of its 32 references that are in the map. First posted on arXiv 1 Oct 2024.

Builds on

14 of 32 references.

Closest ancestors · 2

Same direction, newest first

  1. 2024TOFU: A Task of Fictitious Unlearning for LLMs11 Jan
  2. 2023In-Context Unlearning: Language Models as Few Shot Unlearners11 Oct

Other references · 12

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  3. 2016Deep Learning with Differential Privacycited by 2,682
  4. 2022Locating and Editing Factual Associations in GPTcited by 2,609
  5. 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
  6. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
  7. 2022A Survey on In-context Learningcited by 717
  8. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  9. 2019Eternal Sunshine of the Spotless Net: Selective Forgetting in Deep Networkscited by 599
  10. 2017Differentially Private Federated Learning: A Client Level Perspectivecited by 451
  11. 2023A Comprehensive Survey on Test-Time Adaptation under Distribution Shiftscited by 353
  12. 2024Security and Privacy Challenges of Large Language Models: A Surveycited by 179

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 3; 2026: 4.

7 papers.