Large Language Model Unlearning for Source Code

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Jiang, Xue, Dong, Yihong, Zhang, Huangzhao, Wang, Tangxinyu, Fang, Zheng, Ma, Yingwei, Cao, Rongyu, Li, Binhua, Jin, Zhi, Jiao, Wenpin, Li, Yongbin, Li, Ge
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866918215622328320
author Jiang, Xue
Dong, Yihong
Zhang, Huangzhao
Wang, Tangxinyu
Fang, Zheng
Ma, Yingwei
Cao, Rongyu
Li, Binhua
Jin, Zhi
Jiao, Wenpin
Li, Yongbin
Li, Ge
author_facet Jiang, Xue
Dong, Yihong
Zhang, Huangzhao
Wang, Tangxinyu
Fang, Zheng
Ma, Yingwei
Cao, Rongyu
Li, Binhua
Jin, Zhi
Jiao, Wenpin
Li, Yongbin
Li, Ge
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2506_17125
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Large Language Model Unlearning for Source Code
Jiang, Xue
Dong, Yihong
Zhang, Huangzhao
Wang, Tangxinyu
Fang, Zheng
Ma, Yingwei
Cao, Rongyu
Li, Binhua
Jin, Zhi
Jiao, Wenpin
Li, Yongbin
Li, Ge
Software Engineering
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.
title Large Language Model Unlearning for Source Code
topic Software Engineering
url https://arxiv.org/abs/2506.17125