TL;DR
This paper introduces CodeEditorBench, a new benchmark designed to rigorously evaluate the code editing capabilities of Large Language Models (LLMs). It addresses the gap in existing benchmarks that primarily focus on code generation, and their findings reveal that while LLMs are improving, they still struggle with tasks like code polishing and rewriting.
What Problem Does This Paper Address?
The rapid advancement of Large Language Models (LLMs) has led to impressive capabilities in code generation. However, a crucial aspect of software development is code editing – tasks like debugging, refactoring, and adapting code to new requirements. Existing benchmarks, such as HumanEval and MBPP, largely overlook these editing capabilities, focusing instead on generating code from scratch. This leaves a significant gap in our understanding of how well LLMs can perform real-world code modification tasks. The authors aim to bridge this gap by introducing a comprehensive evaluation framework specifically for code editing.
Methods
The core contribution is the CodeEditorBench framework. This framework is designed to evaluate LLMs across four key code editing scenarios:
- Code Debug: Identifying and fixing errors in code.
- Code Translate: Converting code from one programming language to another.
- Code Polish: Optimizing code for efficiency or readability without changing its functionality.
- Code Requirement Switch: Adapting code to meet new or modified requirements.
The benchmark is built by curating diverse coding challenges from five sources, covering various programming languages, complexity levels, and editing tasks. They also developed an online judge system to facilitate rigorous evaluation. The evaluation involves crafting prompts for zero-shot, three-shot, and chain-of-thought settings.
Datasets
The primary dataset introduced is CodeEditorBench. It was constructed by gathering data from five sources: LeetCode, CodeContests, CodeXGLUE, CodeNet, and Taco. To ensure LLM compatibility, questions exceeding 800 lines or 1000 tokens were filtered out. The dataset was further refined into CodeEditorBench_Primary and CodeEditorBench_Plus, with the latter being a refined version to mitigate potential data pollution issues. The dataset contains 7,961 code editing tasks, each with an average of 44 test cases.
Key Insights and Ideas
- Code Editing is Distinct from Generation: While LLMs show some consistency between their code editing and generation abilities, the results highlight that these are not interchangeable skills. Models that excel at generation don't automatically excel at editing.
- Polishing and Rewriting Remain Challenges: LLMs still struggle with tasks that require nuanced understanding and modification for optimization or adaptation, such as code polishing and requirement switching.
- Specialized Models Show Promise: Models specifically fine-tuned for code feedback or editing tasks demonstrate significant improvements in their code editing performance.
- Data Leakage is a Concern: The study observed significant differences in performance between the primary and refined datasets, suggesting potential data leakage in the original dataset, which is a common issue in LLM evaluation.
Key Results
The authors evaluated 19 LLMs on CodeEditorBench. Key findings include:
- Closed-source models generally outperform open-source models: GPT-4 and Gemini-Ultra showed strong performance across most tasks.
- Code Requirement Switch is the most challenging: This scenario had the lowest pass rate (11.18%) across all models.
- Debug and Translate are more achievable: These tasks had pass rates of approximately 20% and 30%, respectively.
- Code Polish also presents difficulties: Even with correct original code, only 37.47% of solutions met the criteria for improved efficiency.
- Model performance varies by task: For instance, GPT-4 excelled in zero-shot tasks for Debug, Translate, and Switch, while Gemini-Ultra led in few-shot Polish tasks.
Limitations and Future Work
The authors acknowledge several limitations:
- Model Coverage: The evaluation of 19 LLMs may not fully represent the vast landscape of available models.
- Bias in Task Selection: The benchmark might still exhibit a preference for certain languages or tasks.
- Evaluation Metrics: Current metrics might not fully capture the intricacies of code editing.
- Real-world Relevance: The simulated environment may not perfectly mirror the complexity of real-world software development.
- Dynamic LLM Landscape: The rapid evolution of LLMs means findings may become obsolete quickly, necessitating continuous updates.
Future work will focus on expanding the benchmark with new problems, scenarios, and models, and incorporating more sophisticated evaluation metrics.
Summary updated