arXiv:2509.13755cs.SEcs.AI2025-09中稿 · the 48th IEEE/ACM …被引 7

提出无需重训练即可清除代码模型敏感记忆的高效擦除方法。

Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearning

  • 通过机器反学习技术,选择性移除代码模型中的敏感记忆片段。
  • 在3类代码模型上验证,可有效擦除5万条敏感样本且保持代码功能正确。
  • 适合需快速修复隐私漏洞但无法重训练的部署场景。

尽管代码语言模型(CLMs)在代码生成和摘要等任务中表现优异,但近期研究揭示其存在严重隐私风险:模型会意外记忆训练数据,导致在特定提示下复现机密信息。现有方法如数据去重和差分隐私需全模型重训练,成本高昂。本文首次探索通过机器反学习,在不重训练的前提下擦除敏感记忆。我们量化了训练数据中的记忆风险,构建包含5万条高风险敏感样本的数据集作为目标。研究两种基于梯度上升的反学习方法,并提出CodeEraser——一种能选择性擦除代码中敏感片段、同时保留上下文结构与功能正确性的改进方法。在CodeParrot、CodeGen-Mono和Qwen2.5-Coder三类模型上的实验证明,CodeEraser能高效、有效地消除目标敏感记忆,同时维持模型可用性。

原文摘要 · Abstract (English)

While Code Language Models (CLMs) have demonstrated superior performance in software engineering tasks such as code generation and summarization, recent empirical studies reveal a critical privacy vulnerability: these models exhibit unintended memorization of sensitive training data, enabling verbatim reproduction of confidential information when specifically prompted. To address this issue, several approaches, including training data de-duplication and differential privacy augmentation, have been proposed. However, these methods require full-model retraining for deployed CLMs, which incurs substantial computational costs. In this paper, we aim to answer the following research question: Can sensitive information memorized by CLMs be erased effectively and efficiently? We conduct a pioneering investigation into erasing sensitive memorization in CLMs through machine unlearning - a post-hoc modification method that removes specific information from trained models without requiring full retraining. Specifically, we first quantify the memorization risks of sensitive data within CLM training datasets and curate a high-risk dataset of 50,000 sensitive memorized samples as unlearning targets. We study two widely used gradient ascent-based unlearning approaches: the vanilla and constraint-based methods, and introduce CodeEraser, an advanced variant that selectively unlearns sensitive memorized segments in code while preserving the structural integrity and functional correctness of the surrounding code. Extensive experiments on three families of CLMs, i.e., CodeParrot, CodeGen-Mono, and Qwen2.5-Coder, validate the effectiveness and efficiency of CodeEraser in erasing targeted sensitive memorization while maintaining model utility.

代码模型隐私保护反学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。