TL;DR
This paper introduces RepoMasterEval, a new benchmark for evaluating code completion models that uses real-world code repositories to better reflect actual development scenarios. By incorporating mutation testing and manual test case augmentation, RepoMasterEval provides a more robust and practical assessment of LLMs, showing that current benchmarks may not fully capture their real-world performance.
What Problem Does This Paper Address?
Automated code completion tools, powered by Large Language Models (LLMs), are becoming indispensable in software development. However, existing benchmarks used to evaluate these tools often fall short. They typically focus on simple, isolated code units (like functions) and rely on descriptive text prompts, which aren't always representative of real-world coding. In practice, code completion can happen anywhere within a codebase, often without explicit textual descriptions, and requires understanding broader context. This disconnect means that models performing well on current benchmarks might struggle in real-world scenarios, leading to a gap between evaluation results and actual utility. Furthermore, the quality and comprehensiveness of test suites used in existing benchmarks are often questionable, potentially leading to inaccurate assessments.
Methods
The authors propose RepoMasterEval, a novel benchmark designed to address these limitations. Here's how they built it:
- Real-World Repository Focus: Instead of synthetic datasets, RepoMasterEval is constructed from actual Python and TypeScript code repositories hosted on GitHub. This ensures the tasks reflect genuine development challenges.
- Fill-in-the-Middle Task: The benchmark simulates the "fill-in-the-middle" task, where a code snippet is masked, and the model must predict it using both preceding (prefix) and succeeding (suffix) code context, along with retrieved repository-level context (using BM25). This is more representative of how developers use code completion in practice.
- Test Suite Augmentation: To ensure accurate evaluation, they employ mutation testing. This involves creating slightly altered versions (mutants) of the ground truth code and checking if the existing test suite can detect these "faults." If test suites have low mutation scores (meaning they miss many faults), they manually craft additional test cases to improve their robustness and effectiveness.
- Data Collection and Filtering: Repositories are selected based on activity and community endorsement (e.g., stars) and are filtered to exclude those trained on by the models to mitigate data leakage.
Datasets
- Training Data: The paper doesn't explicitly detail the training datasets for the LLMs evaluated, but it mentions that the LLMs themselves are trained on massive corpora and code.
- Evaluation Benchmark: The core contribution is the RepoMasterEval benchmark. It's constructed from real-world Python and TypeScript repositories. The benchmark includes 288 tasks (115 Python, 173 TypeScript) spanning 13 categories.
Key Insights and Ideas
- Real-world context matters: Models that perform exceptionally well on simpler benchmarks like HumanEval can show a significant drop in performance on RepoMasterEval, highlighting that real-world code completion is more complex than isolated function generation.
- Test quality is crucial: The effectiveness of test suites is paramount. Augmenting tests, even if it slightly decreases model pass rates, makes the evaluation more robust and reveals true model capabilities.
- Instruct models vs. Base models: While instruct-tuned models often excel at following specific instructions (like in HumanEval), they might be less adept at the "fill-in-the-middle" task in a broader repository context compared to their base counterparts.
- Pass rates are more stable than similarity metrics: Pass rates (Pass@k) provide a more consistent and reliable measure of model performance across different models and scales compared to exact match or Jaccard similarity metrics.
- Benchmark performance correlates with real-world adoption: The study found a strong positive correlation between a model's performance on RepoMasterEval and its online acceptance rate, suggesting the benchmark is a good predictor of practical usability.
Key Results
- Model Performance Variance: Empirical evaluation on 10 state-of-the-art models showed significant performance differences, with models generally performing better on simpler tasks and struggling with more complex, context-rich scenarios presented by RepoMasterEval. For example, GPT-4 showed high scores on HumanEval but dropped on RepoMasterEval.
- Test Augmentation Impact: After test augmentation, mutation scores improved significantly (e.g., from 58% to 68.2% for TypeScript, and 73.6% to 84.5% for Python). While code coverage saw only slight increases, the pass rates of all evaluated models decreased, indicating the augmented tests were more challenging and effective.
- Correlation with Real-World Use: A Spearman correlation of 0.9601 was found between RepoMasterEval scores and online acceptance rates over a six-month deployment period, demonstrating the benchmark's relevance.
- Category-Specific Performance: Models showed varying strengths across different data categories. For instance, Python models excelled in "Data Management and Analysis" and "Programming Basics," while TypeScript models were strong in "Front-end Development" and "Language Features."
Limitations and Future Work
- Limitations:
- The paper acknowledges that while they try to mitigate data leakage by using recent repositories, it remains a challenging issue.
- The "instruct" versions of LLMs sometimes produced extra text, redundant imports, or repeated code, leading to syntax errors, which indicates potential issues with their ability to strictly adhere to the "fill-in-the-middle" task in complex contexts.
- Future Work:
- The authors suggest expanding RepoMasterEval to include more diverse evaluation metrics to further enhance its applicability and relevance.
- They call for the research community to build more practical and complicated code completion benchmarks.
Summary updated