Search papers, labs, and topics across Lattice.
This paper introduces CURE, a contrastive unlearning approach designed to enhance the adaptability of code LLMs by not only suppressing deprecated APIs but also promoting their correct replacements. By addressing the limitations of existing fine-tuning methods, CURE effectively mitigates the generation of outdated API usages while improving the accuracy of code generation in line with evolving software libraries. Experimental results demonstrate that CURE significantly outperforms state-of-the-art baselines, achieving a dual benefit of reducing deprecated API usage and enhancing correct API replacements without sacrificing overall code generation quality.
CURE not only eliminates deprecated API usage but also ensures that code LLMs generate accurate replacements, achieving a balance that was previously unattainable.
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.