Abstract
Selective forgetting in Large Language Models (LLMs) is critical for privacy and safety, yet current methods often suffer from high computational costs or increased hallucinations. This paper introduces In-Context Knowledge Unlearning, a technique that enables models to selectively "forget" information at test-time using specialized prompt tokens. Crucially, we demonstrate that models do not physically erase this knowledge but rather "pretend to forget." Using logit lens analysis, we show that the correct answer is computed in intermediate layers and suppressed only at the final processing stage. This method achieves up to 95% forget accuracy while maintaining 80% retention of unrelated knowledge.
Introduction
As LLMs are integrated into corporate and sensitive environments, the ability to selectively withhold proprietary information becomes paramount. Traditional unlearning—erasing weights—is often permanent and expensive. Conversely, simple in-context label flipping often results in hallucinations, where the model provides a plausible but incorrect answer instead of admitting it cannot share the information.
Methodology: In-Context Knowledge Unlearning
The proposed method utilizes a two-step approach to achieve flexible, test-time unlearning:
- Unlearning Tokens: Information to be disregarded is wrapped in special tags, such as
«UNL»Paris«/UNL». - Dual Loss Fine-Tuning: Models are fine-tuned (often via LoRA) using a combined objective:
- Forgetting Loss: Queries regarding tagged information must result in a "forgot" output.
- Retention Loss: Queries unrelated to the tagged information must preserve the original correct response.
The "Pretend to Forget" Phenomenon
The most significant finding is that the model's internal state still contains the "forgotten" information. By applying the Logit Lens to inspect internal layers, researchers found that the model continues to calculate the correct answer in its middle layers.
As shown in Figure 6, the probability of the correct "answer" token remains high in the middle layers (around layer 20-28), while the "forgot" token only dominates at the very final layers (30-32). This suggests that unlearning acts as a behavioral mask rather than a fundamental deletion of knowledge.
Key Results and Generalization
- Accuracy and Reliability: The method achieves 95% forget accuracy and effectively suppresses hallucinations by consistently outputting the "forgot" token.
- Retention: Models retain approximately 80% of unrelated knowledge, outperforming standard Gradient Ascent baselines.
- Out-of-Domain Generalization: The unlearning behavior generalizes to facts not seen during the fine-tuning phase, indicating the model learns a high-level rule for handling the
«UNL»tags.
Conclusion and Future Work
While In-Context Knowledge Unlearning provides a powerful tool for flexible information control, the "pretending" mechanism introduces risks. Since the knowledge persists internally, adversarial "jailbreaks" might bypass the final-layer suppression. Future research must address how to push unlearning deeper into the model's architecture to ensure robust information security.
Summary updated