Large Language Models (LLMs) have transformed software development, yet evaluating their performance remains a challenge. Traditional benchmarks often focus on single-file "fill-in-the-blank" tasks in a handful of popular languages. However, real-world development happens at the repository level, where understanding cross-file dependencies is crucial.
Bridging the Gap in Code Completion
Researchers from Nanjing University and Alibaba Group have introduced M2RC-EVAL, a benchmark designed to evaluate LLMs on repository-level code completion across 18 diverse programming languages. This benchmark addresses the "language monoculture" of previous evaluations and provides granular insights into model performance.
Methodology: Fine-Grained Repository Awareness
M2RC-EVAL moves beyond random masking. It uses Abstract Syntax Tree (AST) parsing via Tree-sitter to identify meaningful completion targets like function definitions and expressions.
The benchmark introduces two primary axes for evaluation:
- Bucket-level (Structural Depth): Completion targets are categorized by their depth in the AST (1-10), testing if models struggle more with top-level declarations or deep nested logic.
- Semantic-level (Functional Category): Code is mapped to 11 categories, such as Program Structure or Control Flow, to identify specific functional weaknesses.
To simulate a developer's environment, the benchmark employs Retrieval-Augmented Generation (RAG), providing the model with relevant snippets from other files in the repository.
M2RC-INSTRUCT: Training for Repository Context
Alongside the benchmark, the authors released M2RC-INSTRUCT, a dataset of 50,000 files per language. This dataset is specifically designed for Supervised Fine-Tuning (SFT) to teach models how to effectively utilize cross-file context.
Key Insights and Results
The evaluation of models like StarCoder, DeepSeekCoder, and Code Llama yielded several critical findings:
- "Shallow" Structures are Challenging: Models often find top-level declarations (shallow AST nodes) harder to complete than deep logic. This is because shallow nodes frequently depend on global repository knowledge (imports, configurations) rather than local context.
- The Impact of Instruction Tuning: Fine-tuning on M2RC-INSTRUCT significantly boosted performance. A 3B model fine-tuned on this data could outperform a 7B base model using only retrieval.
- Performance Gains: The combination of retrieval and instruction tuning achieved an average Exact Match (EM) of 46.8% and an Edit Similarity (ES) of 74.1% across all 18 languages. Syntax accuracy also improved to 96.9%.
Conclusion
M2RC-EVAL sets a new standard for evaluating general code intelligence. By providing a massively multilingual, repository-level benchmark with fine-grained annotations, it allows researchers to pinpoint exactly where LLMs succeed or fail in complex software environments. Future work will expand this framework to include more diverse tasks like debugging and refactoring.
Summary updated