mlsanityData to 14 Oct 2026

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

arXiv 2509.13755 ↗First posted 17 Sep 2025cs.SE cs.AI cs.CRcited by 7

On the map: LLM safety and security → Machine unlearning

Abstract (arXiv)

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.

Key facts. Cited by 7 papers in the map (data through 14 Oct 2026). Placed in Machine unlearning, one of 12 directions in LLM safety and security. Builds on 47 of its 73 references that are in the map. First posted on arXiv 17 Sep 2025.

Builds on

47 of 73 references.

Closest ancestors · 8

Same direction, newest first

  1. 2024Machine Unlearning of Pre-trained Large Language Models23 Feb
  2. 2024Selective Forgetting: Advancing Machine Unlearning Techniques and Evaluation in Language Models8 Feb
  3. 2023Unlearn What You Want to Forget: Efficient Unlearning for LLMs31 Oct
  4. 2023Large Language Model Unlearning14 Oct
  5. 2023Who's Harry Potter? Approximate Unlearning in LLMs3 Oct
  6. 2023Towards Unbounded Machine Unlearning20 Feb
  7. 2022Knowledge Unlearning for Mitigating Privacy Risks in Language Models4 Oct
  8. 2022A Survey of Machine Unlearning6 Sep

Other references · 39

  1. 2020Language Models are Few-Shot Learnerscited by 32,419
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  3. 2016Overcoming catastrophic forgetting in neural networkscited by 4,787
  4. 2021Program Synthesis with Large Language Modelscited by 3,637
  5. 2016Deep Learning with Differential Privacycited by 2,728
  6. 2020Extracting Training Data from Large Language Modelscited by 2,189
  7. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  8. 2023Pythia: A Suite for Analyzing Large Language Models Across Training and Scalingcited by 1,786
  9. 2019Machine Unlearningcited by 1,061
  10. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
  11. 2018The Secret Sharer: Evaluating and Testing Unintended Memorization in Neural Networkscited by 864
  12. 2021Deduplicating Training Data Makes Language Models Bettercited by 714
27 more
  1. 2019Eternal Sunshine of the Spotless Net: Selective Forgetting in Deep Networkscited by 618
  2. 2019Certified Data Removal from Machine Learning Modelscited by 535
  3. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
  4. 2020What Neural Networks Memorize and Why: Discovering the Long Tail via Influence Estimationcited by 497
  5. 2019Making AI Forget You: Data Deletion in Machine Learningcited by 465
  6. 2019Does Learning Require Memorization? A Short Tale about a Long Tailcited by 460
  7. 2022A Systematic Evaluation of Large Language Models of Codecited by 363
  8. 2017Measuring Catastrophic Forgetting in Neural Networkscited by 360
  9. 2022Deduplicating Training Data Mitigates Privacy Risks in Language Modelscited by 314
  10. 2022Memorization Without Overfitting: Analyzing the Training Dynamics of Large Language Modelscited by 220
  11. 2021Counterfactual Memorization in Neural Language Modelscited by 156
  12. 2023Emergent and Predictable Memorization in Large Language Modelscited by 148
  13. 2021Graph Unlearningcited by 138
  14. 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
  15. 2023Self-planning Code Generation with Large Language Modelscited by 124
  16. 2018Improving Automatic Source Code Summarization via Deep Reinforcement Learningcited by 100
  17. 2018Algorithms that Remember: Model Inversion Attacks and Data Protection Lawcited by 55
  18. 2022What Do They Capture? -- A Structural Analysis of Pre-Trained Language Models for Source Codecited by 50
  19. 2023Unveiling Memorization in Code Modelscited by 30
  20. 2023Traces of Memorisation in Large Language Models for Codecited by 29
  21. 2023Extending Source Code Pre-Trained Language Models to Summarise Decompiled Binariescited by 26
  22. 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
  23. 2023Your Code Secret Belongs to Me: Neural Code Completion Tools Can Memorize Hard-Coded Credentialscited by 17
  24. 2023Exploring Distributional Shifts in Large Language Models for Code Analysiscited by 14
  25. 2024Decoding Secret Memorization in Code LLMs Through Token-Level Characterizationcited by 9
  26. 2025CODESYNC: Synchronizing Large Language Models with Dynamic Code Evolution at Scalecited by 8
  27. 2023SecretBench: A Dataset of Software Secretscited by 5

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 2; 2026: 5.

7 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025Mitigating Sensitive Information Leakage in LLMs4Code through Machine Unlearning
  2. 2026On the Recoverability of Private Information Unlearning in Large Language Models
  3. 2025Unlearning Isn't Invisible: Detecting Unlearning Traces in LLMs from Model Outputs
  4. 2024The Frontier of Data Erasure: Machine Unlearning for Large Language Models
  5. 2026From Anchors to Supervision: Memory-Graph Guided Corpus-Free Unlearning for Large Language Models
  6. 2024Protecting Privacy Through Approximating Optimal Parameters for Sequence Unlearning in Language Models
  7. 2025OpenUnlearning: Accelerating LLM Unlearning via Unified Benchmarking of Methods and Metrics
  8. 2025Keeping an Eye on LLM Unlearning: The Hidden Risk and Remedy