[Paper Review] LLMs Meet Library Evolution: Evaluating Deprecated API Usage in LLM-based Code Completion
This study evaluates deprecated API usage in LLM-based code completion across seven models, 145 API mappings from eight Python libraries, and 28,125 prompts. It identifies that LLMs frequently suggest outdated APIs due to training data biases and lack of deprecation knowledge, and proposes two lightweight fixes—ReplaceAPI and InsertPrompt—to mitigate this issue, offering foundational solutions for integrating library evolution into LLM-driven development.
Large language models (LLMs), pre-trained or fine-tuned on large code corpora, have shown effectiveness in generating code completions. However, in LLM-based code completion, LLMs may struggle to use correct and up-to-date Application Programming Interfaces (APIs) due to the rapid and continuous evolution of libraries. While existing studies have highlighted issues with predicting incorrect APIs, the specific problem of deprecated API usage in LLM-based code completion has not been thoroughly investigated. To address this gap, we conducted the first evaluation study on deprecated API usage in LLM-based code completion. This study involved seven advanced LLMs, 145 API mappings from eight popular Python libraries, and 28,125 completion prompts. The study results reveal the status quo (i.e., API usage plausibility and deprecated usage rate) of deprecated API and replacing API usage in LLM-based code completion from the perspectives of model, prompt, and library, and indicate the root causes behind. Based on these findings, we propose two lightweight fixing approaches, REPLACEAPI and INSERTPROMPT, which can serve as baseline approaches for future research on mitigating deprecated API usage in LLM-based completion. Additionally, we provide implications for future research on integrating library evolution with LLM-driven software development.
Motivation & Objective
- To investigate the prevalence and root causes of deprecated API usage in LLM-based code completion.
- To analyze how model architecture, prompt design, and library evolution influence deprecated API predictions.
- To propose practical, lightweight fixing approaches to reduce deprecated API suggestions in LLM-generated code.
- To provide actionable insights for integrating library evolution into LLM-driven software development pipelines.
Proposed method
- Collected 145 deprecated-to-replacement API mappings from eight popular Python libraries, including PyTorch, TensorFlow, and scikit-learn.
- Generated 28,125 line-level code completion prompts by extracting reference APIs from outdated and up-to-date function calls.
- Evaluated seven advanced LLMs—including CodeLlama and GPT-3.5—on their ability to predict plausible (deprecated or replacement) APIs.
- Annotated predictions as 'plausible' if they matched either the deprecated or replacement API; otherwise, 'irrelevant'.
- Proposed two lightweight fixing techniques: ReplaceAPI (replacing outdated API calls during decoding) and InsertPrompt (injecting context about API deprecation into prompts).
- Conducted qualitative and quantitative analysis across model, prompt, and library perspectives to identify key failure patterns.

Experimental results
Research questions
- RQ1RQ1: What is the status quo and root cause of deprecated API usage in LLM-based code completion from the model perspective?
- RQ2RQ2: How do different prompt designs affect the prediction of deprecated and plausible APIs?
- RQ3RQ3: How does library-specific evolution influence the likelihood of deprecated API usage across different libraries?
Key findings
- All seven evaluated LLMs exhibit significant challenges in predicting correct APIs, with a high frequency of deprecated API suggestions due to outdated training data and lack of deprecation awareness during inference.
- Model performance varies significantly based on architecture and training data, with larger models showing slightly better but still inadequate generalization to deprecation semantics.
- Prompts derived from outdated functions lead to higher rates of deprecated API predictions than those from up-to-date functions, indicating context-dependent model behavior.
- The study found that library-specific evolution patterns—such as multiple deprecation stages (e.g., torch.gels() → torch.lstsq() → torch.linalg.lstsq())—significantly increase the risk of incorrect suggestions.
- ReplaceAPI and InsertPrompt reduced deprecated API usage by up to 68% and 55% respectively in controlled evaluations, demonstrating their effectiveness as baseline fixes.
- The study reveals that current LLMs lack posterior knowledge of API deprecation, making retrieval-augmented generation and model editing promising future directions.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.