Answer When Needed, Forget When Not: Language Models Pretend to Forget via In-Context Knowledge Unlearning
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
- 2024TOFU: A Task of Fictitious Unlearning for LLMs11 Jan
- 2023In-Context Unlearning: Language Models as Few Shot Unlearners11 Oct
Other references · 12
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2016Deep Learning with Differential Privacycited by 2,682
- 2022Locating and Editing Factual Associations in GPTcited by 2,609
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
- 2022A Survey on In-context Learningcited by 717
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2019Eternal Sunshine of the Spotless Net: Selective Forgetting in Deep Networkscited by 599
- 2017Differentially Private Federated Learning: A Client Level Perspectivecited by 451
- 2023A Comprehensive Survey on Test-Time Adaptation under Distribution Shiftscited by 353
- 2024Security and Privacy Challenges of Large Language Models: A Surveycited by 179
Built on by
Citing papers per year: 2025: 3; 2026: 4.
7 papers.
- 2025A Comprehensive Survey in LLM(-Agent) Full Stack Safety: Data, Training and Deploymentcited by 110
- 2025SoK: Machine Unlearning for Large Language Modelscited by 9
- 2025A Survey on Unlearning in Large Language Modelscited by 2
- 2026Suppression Is Not Forgetting: Residual Recoverability in Visual Concept Unlearning for VLMscited by 1
- 2026Harmonizing Multi-Objective LLM Unlearning via Unified Domain Representation and Bidirectional Logit Distillationcited by 0
- 2026CBD: API-Only LLM Black-Box Unlearning through Controlled Behavioral Divergencecited by 0
- 2026When Context Changes: Understanding Update Failures in LLMscited by 0
- 2026When Context Changes: Understanding Update Failures in LLMs30 Sep 2026
- 2026CBD: API-Only LLM Black-Box Unlearning through Controlled Behavioral Divergence26 Jun 2026
- 2026Harmonizing Multi-Objective LLM Unlearning via Unified Domain Representation and Bidirectional Logit Distillation16 Apr 2026
- 2026Suppression Is Not Forgetting: Residual Recoverability in Visual Concept Unlearning for VLMs3 Apr 2026
- 2025A Survey on Unlearning in Large Language Models29 Oct 2025
- 2025SoK: Machine Unlearning for Large Language Models10 Jun 2025
- 2025A Comprehensive Survey in LLM(-Agent) Full Stack Safety: Data, Training and Deployment22 Apr 2025