Abstract
Traditional code benchmarks for Large Language Models (LLMs), such as HumanEval and MBPP, focus almost exclusively on code generation from docstrings. However, real-world software engineering encompasses a much broader lifecycle, including understanding legacy code, modifying existing logic, and performing rigorous code reviews. We present CoCo-Bench, a comprehensive benchmark designed to evaluate LLMs across four key dimensions: Code Understanding (CU), Code Generation (CG), Code Modification (CM), and Code Review (CR). Our analysis reveals that a model's ability to generate code does not inherently translate to proficiency in editing or reviewing it, highlighting a critical "capability gap" in current AI coding assistants.
Introduction
The rapid advancement of LLMs has transformed software development, yet our methods for evaluating these models remain limited. Most existing benchmarks are "narrow-spectrum," testing only the ability to write standalone functions. This approach ignores the complexities of professional development, such as debugging and architectural analysis. Furthermore, the simplicity of these benchmarks often leads to "data contamination," where models may appear performant simply by memorizing training data.
To address these issues, we introduce CoCo-Bench. This framework serves as a "stress test" for LLMs, moving beyond simple generation to reflect the holistic needs of developers. By evaluating models on their ability to understand, modify, and review code, we provide a more accurate measure of their utility in a production environment.
The CoCo-Bench Framework
CoCo-Bench evaluates models across four distinct but interrelated tasks that mirror the software development lifecycle:
- Code Understanding (CU): Models must demonstrate "Forward Reasoning" (predicting output from input) and "Reverse Reasoning" (deducing input from a desired output).
- Code Generation (CG): This includes both function-level creation and sentence-level completion (filling in specific lines).
- Code Modification (CM): Models are tasked with detecting errors or updating code to accommodate new API changes or requirements.
- Code Review (CR): A multi-label classification task where models identify security vulnerabilities, performance bottlenecks, and logical errors.
Methodology and Dataset
The benchmark consists of 705 high-quality samples across four major programming languages: Python (54.6%), Java (20.4%), C++ (19.0%), and SQL (6.0%). Data was sourced from LeetCode and various open-source repositories to ensure practical relevance and "freshness."
To maintain a high level of difficulty, over 50% of the tasks are categorized as "Hard." For modification and review tasks, the authors employed a "bug implantation" process, creating realistic scenarios where models must identify and fix specific issues. The final "CoCo-Score" is calculated using the TrueSkill2 algorithm, which weights performance based on task difficulty.
Key Insights
Our evaluation of state-of-the-art models yielded several critical insights:
- The Foundation of Understanding: We found a high correlation (0.94) between Code Understanding and Code Generation. This suggests that a model's ability to "mentalize" code execution is a prerequisite for writing it effectively.
- The Modification Paradox: Conversely, there is a much lower correlation (0.36) between Code Generation and Code Modification. This indicates that being a "prolific writer" of code does not make a model a good "editor." Fixing existing code requires distinct latent capabilities.
- The Complexity of Review: Code Review performance showed a low correlation with basic execution logic, implying that high-quality review requires specialized knowledge of security best practices and style guides.
- Instruction Tuning: Instruction-tuned models significantly outperformed base models, demonstrating a superior ability to follow the complex, multi-step constraints inherent in modification and review tasks.
Results and Discussion
OpenAI’s o1-mini and GPT-4 currently lead the CoCo-Bench leaderboard. Among open-weight models, DeepSeek-Coder-V2-Instruct showed exceptional performance. However, even top-tier models struggle with "Reverse Reasoning" and "Code Review" tasks. For instance, while DeepSeek-Coder-33b-instruct performs well in generation (39.53), its score drops precipitously in reverse reasoning (10.74).
We also observed that "Structured" tasks (like Understanding) benefit from deterministic decoding settings, whereas "Creative" tasks (like Modification) benefit from higher diversity in decoding.
Conclusion and Future Work
CoCo-Bench provides a more nuanced "physical exam" for AI coding assistants. While current models excel at simple generation, significant gaps remain in their ability to handle the full software lifecycle. Future iterations of CoCo-Bench will expand to include a wider array of programming languages and introduce multimodal tasks, such as interpreting system architecture diagrams, to further challenge the next generation of LLMs.
Summary updated