In-Context Unlearning: Language Models as Few Shot Unlearners

Martin Pawelczyk, Seth Neel, Himabindu Lakkaraju
2/12/2026

No official code found. Best implementation: MartinPawelczyk/In-Context-Unlearning (30 stars, last commit 2023-10-18). 1 more below.

Abstract

Machine unlearning, the study of efficiently removing the impact of specific training instances on a model, has garnered increased attention in recent years due to regulatory guidelines such as the \emph{Right to be Forgotten}. Achieving precise unlearning typically involves fully retraining the model and is computationally infeasible in case of very large models such as Large Language Models (LLMs). To this end, recent work has proposed several algorithms which approximate the removal of training data without retraining the model. These algorithms crucially rely on access to the model parameters in order to update them, an assumption that may not hold in practice due to computational constraints or having only query access to the LLMs. In this work, we propose a new class of unlearning methods for LLMs called ``In-Context Unlearning.'' This method unlearns instances from the model by simply providing specific kinds of inputs in context, without the need to update model parameters. To unlearn specific training instances, we present these instances to the LLMs at inference time along with labels that differ from their ground truth. Our experimental results demonstrate that in-context unlearning performs on par with, or in some cases outperforms other state-of-the-art methods that require access to model parameters, effectively removing the influence of specific instances on the model while preserving test accuracy.

View on arXivView PDF

Code Implementations(2)

"In-Context Unlearning: Language Models as Few Shot Unlearners". Martin Pawelczyk, Seth Neel* and Himabindu Lakkaraju*; ICML 2024.

302Shell, PythonOct 17, 20233 years ago

"In-Context Unlearning: Language Models as Few Shot Unlearners". Martin Pawelczyk, Seth Neel* and Himabindu Lakkaraju*; arXiv preprint: arXiv:2310.07579; 2023.

30Shell, PythonOct 18, 20233 years ago

Similar Papers

Cite this paper

@article{pawelczyk2026incontext,
  title  = {In-Context Unlearning: Language Models as Few Shot Unlearners},
  author = {Martin Pawelczyk and Seth Neel and Himabindu Lakkaraju},
  year   = {2026},
  eprint = {2310.07579},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/pdf/2310.07579},
  journal = {ICML 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.07579.svg)](https://codeofpaper.com/paper/2310.07579)

Discussion