让大模型根据上下文决定是否遗忘特定信息,仅在需要时才假装忘记。
Answer When Needed, Forget When Not: Language Models Pretend to Forget via In-Context Knowledge Unlearning
- 通过上下文提示实现测试时选择性遗忘,保留无关知识。
- 遗忘准确率达95%,无关知识保留率80%以上,优于现有方法。
- 揭示模型在最后一层才决定遗忘,为安全可控的遗忘机制提供新思路。
随着大语言模型(LLMs)在多个领域应用,选择性遗忘特定信息的能力变得日益重要。例如,模型需向授权内部用户(如员工或可信伙伴)提供机密信息,而对公众及未经授权实体则隐藏该信息。为此,我们提出一种名为「上下文知识遗忘」的新方法,使模型能基于查询上下文在测试阶段选择性遗忘。该方法微调预训练的LLM,使其能在上下文中提示遗忘目标知识,同时保留无关信息。在TOFU、AGE和RWKU数据集上使用Llama2-7B/13B与Mistral-7B模型的实验表明,该方法在域内和域外场景中均显著优于基线,遗忘准确率达95%,无关知识保留率达80%以上。进一步分析发现,微调后的模型在中间层仍生成正确预测并保持结果,但遗忘决策仅在最后层做出,即「大模型假装遗忘」。这一发现为提升模型遗忘机制的鲁棒性提供了关键洞察,为未来研究奠定基础。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。