Abstract
Software libraries are dynamic, with APIs frequently being introduced, modified, or deprecated. Most existing code generation benchmarks fail to account for this evolution, leading to "version mismatch" errors in Large Language Model (LLM) outputs. We introduce LibEvolutionEval, a benchmark designed to evaluate version-specific code completion. Our study shows that while LLMs struggle with temporal changes, providing version-correct documentation via Retrieval-Augmented Generation (RAG) can significantly bridge the performance gap.
1. Introduction
Most code generation benchmarks treat programming libraries as static entities. However, popular libraries like PyTorch or Matplotlib are "rapidly evolving" entities. This creates a significant challenge for LLMs: a model trained on a 2024 crawl of GitHub might suggest a modern API (like torch.linalg.solve) to a developer working on a legacy project where only torch.solve is available. Conversely, models with older knowledge cutoffs cannot predict newly released features.
This paper addresses the lack of evaluation frameworks that account for the temporal dimension of software development by introducing the LibEvolutionEval benchmark.
2. The LibEvolutionEval Benchmark
LibEvolutionEval evaluates models on their ability to perform version-specific code completion across eight major Python libraries, including torch, scipy, and matplotlib. The dataset includes over 34,000 evaluation examples and spans multiple years of library evolution, incorporating 29.4K API documentations for PyTorch alone.
The benchmark utilizes two primary evaluation strategies:
- Realistic Scenario: Sampling code from GitHub repositories and using
requirements.txtfiles to precisely match snippets with specific library versions. - Controlled Scenario: Using library documentation to synthetically create "clean" evaluation examples, isolating API evolution from confounding variables like coding style.
3. Key Insights and Results
Our analysis reveals several critical behaviors in modern Code LLMs regarding temporal knowledge:
3.1 API Forgetting and Version Bias
Models exhibit an inherent bias toward the library versions most prevalent in their training data. As libraries evolve, newer models tend to "forget" deprecated APIs, while older models are physically incapable of knowing about newly introduced ones. Interestingly, models performed better on "indirect" completions (inferring APIs based on an object's type) than "direct" completions (using explicit prefixes).
3.2 The Impact of Documentation
Providing version-specific documentation via RAG consistently improves performance. For StarCoder2-7B, RAG improved the F1 score on PyTorch tasks from 68.8 to 73.3. However, models still struggle significantly with deprecated APIs; for instance, StarCoder2's score on Matplotlib's deprecated APIs was nearly 23 points lower than its overall score for that version. This suggests that while documentation helps, it does not entirely eliminate deep-seated version biases.
4. Conclusion and Future Work
LibEvolutionEval demonstrates that "context" (via RAG) is a powerful but partial cure for version bias. Future research should focus on specialized training techniques that incorporate temporal data, teaching models the lifecycle of APIs to better support developers working across different software versions and legacy codebases.
Summary updated