Large Language Models for Code (LLMs4Code) have achieved strong performance in code generation, but recent studies reveal that they may memorize and leak sensitive information contained in training data, posing serious privacy risks. To address this gap, this work presents the first comprehensive empirical study on applying machine unlearning to mitigate sensitive information leakage in LLMs4Code. We first construct a dedicated benchmark that includes: (i) a synthetic forget set containing diverse forms of personal information, and (ii) a retain set designed to evaluate whether code-generation capability is preserved after unlearning. Using this benchmark, we systematically assess three representative unlearning algorithms (GA, GA+GD, GA+KL) across three widely used open-source LLMs4Code models (AIXCoder-7B, CodeLlama-7B, CodeQwen-7B). Experimental results demonstrate that machine unlearning can substantially reduce direct memorization-based leakage: on average, the direct leak rate drops by more than 50% while retaining about over 91% of the original code-generation performance. Moreover, by analyzing post-unlearning outputs, we uncover a consistent shift from direct to indirect leakage, revealing an underexplored vulnerability that persists even when the target data has been successfully forgotten. Our findings show that machine unlearning is a feasible and effective solution for enhancing privacy protection in LLMs4Code, while also highlighting the need for future techniques capable of mitigating both direct and indirect leakage simultaneously.


翻译:代码大语言模型(LLMs4Code)在代码生成任务中已展现出强大性能,但近期研究表明,它们可能记忆并泄露训练数据中包含的敏感信息,从而带来严重的隐私风险。为填补这一研究空白,本文首次对应用机器遗忘技术缓解LLMs4Code中敏感信息泄露问题进行了全面的实证研究。我们首先构建了一个专用基准测试集,包含:(i)涵盖多种个人信息形式的合成遗忘数据集,以及(ii)用于评估遗忘后代码生成能力是否得以保持的保留数据集。基于该基准,我们系统评估了三种代表性遗忘算法(GA、GA+GD、GA+KL)在三个广泛使用的开源LLMs4Code模型(AIXCoder-7B、CodeLlama-7B、CodeQwen-7B)上的表现。实验结果表明,机器遗忘能显著降低基于直接记忆的泄露:平均而言,直接泄露率下降超过50%,同时保留了约91%以上的原始代码生成性能。此外,通过分析遗忘后的输出,我们发现泄露模式存在从直接泄露向间接泄露的一致性转变,揭示了即使目标数据已被成功遗忘,仍持续存在的未充分探索的安全漏洞。我们的研究证明,机器遗忘是增强LLMs4Code隐私保护的可行且有效的解决方案,同时也指出未来需要开发能够同时缓解直接与间接泄露的新型技术。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
大语言模型机器遗忘综述
专知会员服务
18+阅读 · 2025年11月2日
揭示生成式人工智能 / 大型语言模型(LLMs)的军事潜力
专知会员服务
31+阅读 · 2024年9月26日
大语言模型中的提示隐私保护
专知会员服务
24+阅读 · 2024年7月24日
【ICLR2024】能检测到LLM产生的错误信息吗?
专知会员服务
25+阅读 · 2024年1月23日
【GNN】MPNN:消息传递神经网络
深度学习自然语言处理
17+阅读 · 2020年4月11日
放弃 RNN/LSTM 吧,因为真的不好用!望周知~
人工智能头条
19+阅读 · 2018年4月24日
【推荐】用TensorFlow实现LSTM社交对话股市情感分析
机器学习研究会
11+阅读 · 2018年1月14日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员