TL;DR
This paper introduces REPOEXEC, a novel execution-based benchmark designed to evaluate how effectively Large Language Models (CodeLLMs) handle repository-level code generation. Along with the benchmark, the authors propose the Dependency Invocation Rate (DIR) metric to measure whether models actually utilize existing codebase dependencies or wastefully reinvent the wheel. Their findings reveal a stark contrast between pretrained and instruction-tuned models, showing that while pretrained models excel at passing tests, instruction-tuned models are far better at leveraging existing context to write clean, maintainable code.
What Problem Does This Paper Address?
Most standard code generation benchmarks (like HumanEval or MBPP) evaluate LLMs on standalone, isolated functions. However, real-world software engineering happens within complex repositories where code relies heavily on internal dependencies—like custom classes, utility functions, and cross-file imports.
Existing repository-level benchmarks suffer from major gaps:
- Lack of execution environments: Many rely on match-based metrics (like BLEU or token similarity), which fail to verify if the code actually runs or works correctly.
- Ignoring "Code Smells": A model might generate code that passes a unit test by completely reimplementing an existing helper function from scratch. While functionally correct, this introduces duplicate code, technical debt, and maintainability nightmares.
The authors address this by creating an evaluation paradigm that tests both functional correctness (via execution) and dependency utilization (ensuring the model respects developer intent and reuses existing code).
Methods
The authors developed a comprehensive data processing pipeline to build REPOEXEC and improve model performance:
- Automated Dependency Extraction: Using a custom tool called
pydepcall, the pipeline performs static analysis on repository call graphs to map out exact in-file and cross-file dependencies for target functions. - Test Case Generation & Enhancement: To ensure robust evaluation without relying on sparse pre-existing repo tests, they use LLMs to automatically generate high-coverage test cases, filtering out syntax errors and using an automated "Assertion Fixer" to resolve minor discrepancies.
- Dependency Invocation Rate (DIR): They introduce this new metric, calculated as the ratio of successfully invoked dependencies in the generated code ($D_g$) to the total dependencies present in the ground-truth solution ($Ds$): $$\text{DIR} = \frac{|D_g \cap D_s|}{|Ds|}$$
- Context-Size Prompts: They evaluate models across three context granularities: Full context (complete implementation of dependencies), Medium context (signatures and docstrings only), and Small context (signatures only).
- Mitigation Strategies: They explore multi-round debugging (feeding error logs back to the model) and instruction tuning (training models specifically to handle dependency contexts).
Datasets
- REPOEXEC Benchmark: A newly introduced evaluation dataset consisting of 355 highly curated, executable code generation problems featuring an average of 99 test cases per problem and a high average line coverage of 96.25%.
- Dependency-Enhanced Instruction-Tuning Dataset: A new training dataset containing 154,818 functions extracted from 1,555 highly-starred GitHub repositories, designed to teach models how to effectively incorporate provided repository context.
Key Insights and Ideas
- The Pretrained vs. Instruction-Tuned Trade-off: Pretrained foundation models are great at generating runnable code (high pass@k), but they frequently reimplement existing dependencies. Instruction-tuned models are much better at utilizing the provided context (high DIR) but occasionally hallucinate or overcomplicate implementations.
- Match-Based Metrics are Deceptive: The authors show that token-matching metrics like CodeBLEU show a high statistical correlation with functional correctness overall, but their score distributions heavily overlap between correct and incorrect code, making them unreliable for precise evaluation.
- The "Medium Context" Trap: Surprisingly, providing models with Medium context (signatures + docstrings) often caused a performance drop compared to Small context (signatures only). The authors discovered that the formatting of Medium context prompts frequently misled models into treating dependency definitions as few-shot examples, resulting in empty function generations.
Key Results
- Top Performers: Advanced reasoning models like DeepSeek-R1 and DeepSeek-V3 achieved the best balance, leading the benchmark with the highest pass@1 rates (42.57% and 42.00% respectively) and exceptionally high DIR scores (up to 80.35%).
- Impact of Debugging: Multi-round debugging significantly boosted performance. For instance, GPT-3.5’s pass@1 score jumped from 27.04% to 41.97% after three rounds of iterative bug-fixing based on test execution logs.
- Instruction Tuning Success: Fine-tuning base models on the authors' dependency dataset (DepIT) significantly closed the gap between Small and Full context performance. For example,
phi-2_DepITachieved a 20.31% pass@1 score with minimal context, nearly matching its full-context capability while drastically saving prompt token costs.
Limitations and Future Work
Currently, REPOEXEC only considers one level of direct dependency context (i.e., modules directly called by the target function). It does not account for deeper, transitive dependencies (a dependency calling another dependency) or indirect, complex class hierarchies.
The authors note that expanding the context to include multi-level dependency graphs will be a critical next step, though it introduces significant challenges regarding prompt length management and long-context processing efficiency.
Summary updated