Mitigating Sensitive Information Leakage in LLMs4Code through Machine Unlearning
On the map: LLM safety and security → Machine unlearning
Abstract (arXiv)
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.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in Machine unlearning, one of 12 directions in LLM safety and security. Builds on 34 of its 44 references that are in the map. First posted on arXiv 9 Feb 2025.
Builds on
34 of 44 references.
Closest ancestors · 7
Same direction, newest first
- 2024Machine Unlearning in Generative AI: A Survey30 Jul
- 2023Unlearn What You Want to Forget: Efficient Unlearning for LLMs31 Oct
- 2023Who's Harry Potter? Approximate Unlearning in LLMs3 Oct
- 2022Knowledge Unlearning for Mitigating Privacy Risks in Language Models4 Oct
- 2022A Survey of Machine Unlearning6 Sep
- 2022Continual Learning and Private Unlearning24 Mar
- 2022Zero-Shot Machine Unlearning14 Jan
Other references · 27
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 7,916
- 2020Extracting Training Data from Large Language Modelscited by 2,144
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023A Survey on Large Language Model (LLM) Security and Privacy: The Good, the Bad, and the Uglycited by 380
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
- 2023Analyzing Leakage of Personally Identifiable Information in Language Modelscited by 278
- 2023Self-collaboration Code Generation via ChatGPTcited by 255
- 2020IntelliCode Compose: Code Generation Using Transformercited by 225
- 2020Auditing Differentially Private Machine Learning: How Private is Private SGD?cited by 213
15 more
- 2022Are Large Pre-Trained Language Models Leaking Your Personal Information?cited by 195
- 2022Multi-lingual Evaluation of Code Generation Modelscited by 158
- 2024Attacks, Defenses and Evaluations for LLM Conversation Safety: A Surveycited by 124
- 2023Automatic Semantic Augmentation of Language Model Prompts (for Code Summarization)cited by 72
- 2023Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learningcited by 71
- 2023CodeScore: Evaluating Code Generation by Learning Code Executioncited by 66
- 2024Exploring and Unleashing the Power of Large Language Models in Automated Code Translationcited by 57
- 2024AgentFL: Scaling LLM-based Fault Localization to Project-Level Contextcited by 47
- 2023ToolCoder: Teach Code Generation Models to use API search toolscited by 37
- 2024Robustness, Security, Privacy, Explainability, Efficiency, and Usability of Large Language Models for Codecited by 26
- 2022What Makes a Good Commit Message?cited by 19
- 2023Your Code Secret Belongs to Me: Neural Code Completion Tools Can Memorize Hard-Coded Credentialscited by 17
- 2024IRCoCo: Immediate Rewards-Guided Deep Reinforcement Learning for Code Completioncited by 13
- 2023The (ab)use of Open Source Code to Train Large Language Modelscited by 9
- 2025Cracks in The Stack: Hidden Vulnerabilities and Licensing Risks in LLM Pre-Training Datasetscited by 4
Built on by
Citing papers per year: 2025: 1.
1 paper.
- 2025A Survey on Unlearning in Large Language Modelscited by 2
- 2025A Survey on Unlearning in Large Language Models29 Oct 2025