Towards Knowledge Alignment in Code LLMs: Contrastive Unlearning for Evolving APIs
On the map: LLM safety and security → Machine unlearning
Abstract (arXiv)
Large Language Models (LLMs) have recently achieved strong performance in code generation. However, due to knowledge cut-off and the rapid evolution of software libraries, they often generate deprecated API usages that lead to unreliable and incompatible code. Existing fine-tuning methods lack selectivity when only a small portion of model knowledge requires modification. Recent model-level approaches, such as machine unlearning and model editing, offer a promising direction for modifying parametric knowledge. However, their use for deprecated API mitigation remains largely unexplored. Moreover, existing methods primarily suppress outdated APIs, but do not explicitly steer models toward correct replacements, often leading to mismatched or incomplete generations. To address this limitation, we developed CURE, a contrastive unlearning approach that shifts unlearning from purely suppressing outdated knowledge to explicitly promoting correct API replacements. Concretely, CURE jointly discourages deprecated APIs while encouraging their valid alternatives, enabling more reliable adaptation to evolving software libraries. The experiments on recent deprecated API benchmark dataset show that CURE not only reduces deprecated API usage but also improves correct API replacement, while preserving general code generation performance. CURE substantially outperforms two SOTA baselines with respect to different quality metrics. These findings highlight the importance of combining suppression with replacement when adapting LLMs to evolving software ecosystems.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Machine unlearning, one of 12 directions in LLM safety and security. Builds on 26 of its 32 references that are in the map. First posted on arXiv 29 Jun 2026.
Builds on
26 of 32 references.
Closest ancestors · 5
Same direction, newest first
- 2025Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearning17 Sep
- 2025Large Language Model Unlearning for Source Code20 Jun
- 2024Simplicity Prevails: Rethinking Negative Preference Optimization for LLM Unlearning9 Oct
- 2024Negative Preference Optimization: From Catastrophic Collapse to Effective Unlearning8 Apr
- 2022Knowledge Unlearning for Mitigating Privacy Risks in Language Models4 Oct
Other references · 21
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2024The WMDP Benchmark: Measuring and Reducing Malicious Use With Unlearningcited by 509
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2024RepairAgent: An Autonomous, LLM-Based Agent for Program Repaircited by 232
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 181
- 2023CodeGen2: Lessons for Training LLMs on Programming and Natural Languagescited by 125
- 2025Can LLMs Replace Human Evaluators? An Empirical Study of LLM-as-a-Judge in Software Engineeringcited by 67
- 2024On the Evaluation of Large Language Models in Unit Test Generationcited by 34
9 more
- 2024LLMs Meet Library Evolution: Evaluating Deprecated API Usage in LLM-based Code Completioncited by 32
- 2024HumanEvo: An Evolution-aware Benchmark for More Realistic Evaluation of Repository-level Code Generationcited by 28
- 2024Is Your LLM Outdated? A Deep Look at Temporal Generalizationcited by 26
- 2025Mutation-Guided LLM-based Test Generation at Metacited by 25
- 2024LibEvolutionEval: A Benchmark and Study for Version-Specific Code Generationcited by 12
- 2025ReCode: Updating Code API Knowledge with Reinforcement Learningcited by 12
- 2024Model Editing for LLMs4Code: How Far are We?cited by 10
- 2017An Empirical Study on the Impact of Refactoring Activities on Evolving Client-Used APIscited by 3
- 2025Don't Use a Cannon to Kill a Fly: Lightweight Model Editing for LLMs to Correct Deprecated API Recommendationscited by 2
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2026When LLMs Lag Behind: Knowledge Conflicts from Evolving APIs in Code Generation
- 2026Diagnosing Knowledge Gaps in LLM Tool Use: An Agentic Benchmark for Novel API Acquisition
- 2025CODESYNC: Synchronizing Large Language Models with Dynamic Code Evolution at Scale
- 2023SelfEvolve: A Code Evolution Framework via Large Language Models
- 2024De-Hallucinator: Mitigating LLM Hallucinations in Code Generation Tasks via Iterative Grounding
- 2026UNBIND: UNlearning By INference-time Directional Steering for Code LLMs
- 2025RustEvo^2: An Evolving Benchmark for API Evolution in LLM-based Rust Code Generation
- 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?