mlsanityData to 14 Oct 2026

Large Language Model Unlearning for Source Code

arXiv 2506.17125 ↗First posted 20 Jun 2025cs.SEcited by 4

On the map: LLM safety and security → Machine unlearning

Abstract (arXiv)

While Large Language Models (LLMs) excel at code generation, their inherent tendency toward verbatim memorization of training data introduces critical risks like copyright infringement, insecure emission, and deprecated API utilization, etc. A straightforward yet promising defense is unlearning, ie., erasing or down-weighting the offending snippets through post-training. However, we find its application to source code often tends to spill over, damaging the basic knowledge of programming languages learned by the LLM and degrading the overall capability. To ease this challenge, we propose PROD for precise source code unlearning. PROD surgically zeroes out the prediction probability of the prohibited tokens, and renormalizes the remaining distribution so that the generated code stays correct. By excising only the targeted snippets, PROD achieves precise forgetting without much degradation of the LLM's overall capability. To facilitate in-depth evaluation against PROD, we establish an unlearning benchmark consisting of three downstream tasks (ie., unlearning of copyrighted code, insecure code, and deprecated APIs), and introduce Pareto Dominance Ratio (PDR) metric, which indicates both the forget quality and the LLM utility. Our comprehensive evaluation demonstrates that PROD achieves superior overall performance between forget quality and model utility compared to existing unlearning approaches across three downstream tasks, while consistently exhibiting improvements when applied to LLMs of varying series. PROD also exhibits superior robustness against adversarial attacks without generating or exposing the data to be forgotten. These results underscore that our approach not only successfully extends the application boundary of unlearning techniques to source code, but also holds significant implications for advancing reliable code generation.

Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Placed in Machine unlearning, one of 12 directions in LLM safety and security. Builds on 39 of its 54 references that are in the map. First posted on arXiv 20 Jun 2025.

Builds on

39 of 54 references.

Closest ancestors · 10

Same direction, newest first

  1. 2024LLM Unlearning via Loss Adjustment with Only Forget Data14 Oct
  2. 2024Towards Robust Knowledge Unlearning: An Adversarial Framework for Assessing and Improving Unlearning Robustness in Large Language Models20 Aug
  3. 2024Negative Preference Optimization: From Catastrophic Collapse to Effective Unlearning8 Apr
  4. 2024Rethinking Machine Unlearning for Large Language Models13 Feb
  5. 2024TOFU: A Task of Fictitious Unlearning for LLMs11 Jan
  6. 2023Large Language Model Unlearning14 Oct
  7. 2023Right to be Forgotten in the Era of Large Language Models: Implications, Challenges, and Solutions8 Jul
  8. 2022Zero-Shot Machine Unlearning14 Jan
  9. 2021Fast Yet Effective Machine Unlearning17 Nov
  10. 2021Remember What You Want to Forget: Algorithms for Machine Unlearning4 Mar

Other references · 29

  1. 2023GPT-4 Technical Reportcited by 18,396
  2. 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
  3. 2020Scaling Laws for Neural Language Modelscited by 6,586
  4. 2019The Curious Case of Neural Text Degenerationcited by 2,916
  5. 2023G-Eval: NLG Evaluation using GPT-4 with Better Human Alignmentcited by 2,276
  6. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  7. 2017Decoupled Weight Decay Regularizationcited by 1,831
  8. 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,651
  9. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  10. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  11. 2019Machine Unlearningcited by 1,061
  12. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
17 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. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
  4. 2024Safety Alignment Should Be Made More Than Just a Few Tokens Deepcited by 472
  5. 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
  6. 2020Descent-to-Delete: Gradient-Based Methods for Machine Unlearningcited by 311
  7. 2024CodeGemma: Open Code Models Based on Gemmacited by 150
  8. 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 138
  9. 2024Generalization or Memorization: Data Contamination and Trustworthy Evaluation for Large Language Modelscited by 122
  10. 2020Machine Unlearning: Linear Filtration for Logit-based Classifierscited by 95
  11. 2024Instruction Tuning for Secure Code Generationcited by 68
  12. 2022Backdoor Defense with Machine Unlearningcited by 65
  13. 2023A Perceptual Quality Assessment Exploration for AIGC Imagescited by 55
  14. 2023Security Weaknesses of Copilot-Generated Code in GitHub Projects: An Empirical Studycited by 38
  15. 2024Can We Trust Large Language Models Generated Code? A Framework for In-Context Learning, Security Patterns, and Code Evaluations Across Diverse LLMscited by 19
  16. 2024VersiCode: Towards Version-controllable Code Generationcited by 17
  17. 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generationcited by 14

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 4.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025Mitigating Sensitive Information Leakage in LLMs4Code through Machine Unlearning
  2. 2024A Closer Look at Machine Unlearning for Large Language Models
  3. 2025LLM Unlearning Should Be Form-Independent
  4. 2024Catastrophic Failure of LLM Unlearning via Quantization
  5. 2026Unlearning in LLMs: Methods, Evaluation, and Open Challenges
  6. 2025A Comprehensive Survey of Machine Unlearning Techniques for Large Language Models
  7. 2024Does Unlearning Truly Unlearn? A Black Box Evaluation of LLM Unlearning Methods
  8. 2024Improving the Ability of Pre-trained Language Model by Imparting Large Language Model's Experience ↗