Mitigating Sensitive Information Leakage in LLMs4Code through Machine Unlearning
Ruotong Geng, Mingyang Geng, Shangwen Wang, Haotian Wang, Zhipeng Lin, Dezun Dong
TL;DR
This paper tackles privacy leakage in LLMs for code (LLMs4Code) caused by memorization and evaluates machine unlearning (MU) as an efficient post-training forgetting approach. It benchmarks three MU strategies on three LLMs4Code using a forget set of 5K synthetic privacy prompts and a 5K-code retain set, demonstrating substantial reductions in leak rate with only modest declines in code-generation quality. A key finding is that unlearning shifts leakage from direct disclosures to indirect, contextually related content, highlighting a new risk area for privacy protection. Overall, MU shows promise for privacy governance in LLMs4Code, but future work must address indirect leakage to ensure comprehensive protection.
Abstract
Large Language Models for Code (LLMs4Code) excel at code generation tasks, yielding promise to release developers from huge software development burdens. Nonetheless, these models have been shown to suffer from the significant privacy risks due to the potential leakage of sensitive information embedded during training, known as the memorization problem. Addressing this issue is crucial for ensuring privacy compliance and upholding user trust, but till now there is a dearth of dedicated studies in the literature that focus on this specific direction. Recently, machine unlearning has emerged as a promising solution by enabling models to "forget" sensitive information without full retraining, offering an efficient and scalable approach compared to traditional data cleaning methods. In this paper, we empirically evaluate the effectiveness of unlearning techniques for addressing privacy concerns in LLMs4Code.Specifically, we investigate three state-of-the-art unlearning algorithms and three well-known open-sourced LLMs4Code, on a benchmark that takes into consideration both the privacy data to be forgotten as well as the code generation capabilites of these models. Results show that it is feasible to mitigate the privacy concerns of LLMs4Code through machine unlearning while maintain their code generation capabilities at the same time. We also dissect the forms of privacy protection/leakage after unlearning and observe that there is a shift from direct leakage to indirect leakage, which underscores the need for future studies addressing this risk.
