Abstract
Recent advances in Code Large Language Models (CodeLLMs) have primarily focused on open-ended code generation, often overlooking the crucial aspect of code understanding and reasoning. To bridge this gap, we introduce CodeMMLU, a comprehensive multiple-choice benchmark designed to evaluate the depth of software and code comprehension in LLMs. CodeMMLU includes nearly 20,000 questions spanning diverse domains, including code analysis, defect detection, and software engineering principles across multiple programming languages. Unlike traditional benchmarks that emphasize code generation, CodeMMLU assesses a model's ability to reason about programs across a wide-range of tasks such as code repair, execution reasoning, and fill-in-the-blank challenges. Our extensive evaluation reveals that even state-of-the-art models struggle with CodeMMLU, highlighting significant gaps in comprehension beyond generation.
Introduction
In the current landscape of AI development, the primary metric for a model's coding proficiency has been its ability to generate functional code snippets. However, passing a few test cases on benchmarks like HumanEval does not necessarily equate to a deep understanding of programming logic. CodeMMLU is a massive new benchmark of nearly 20,000 multiple-choice questions designed to move beyond simple code generation and test whether Large Language Models (LLMs) actually understand the logic, syntax, and ecosystem of programming. The results serve as a critical wake-up call: even top-tier models struggle with basic execution reasoning, and common techniques like Chain-of-Thought (CoT) prompting can actually hinder performance on these tasks.
The Challenge of Code Understanding
The industry has leaned heavily on "open-ended generation" benchmarks, but this approach has flaws. Models can often "parrot" memorized training data or stumble into a working solution without truly understanding the underlying logic. Furthermore, existing benchmarks are increasingly susceptible to data leakage and rely on expensive, hard-to-scale execution environments. There is a critical need for a robust, scalable way to assess the depth of a model's software engineering knowledge and its ability to reason about code behavior without just generating it.
Methodology: The CodeMMLU Framework
CodeMMLU utilizes a multiple-choice question (MCQ) format to allow for a highly controlled evaluation of specific reasoning paths. The framework is split into two primary categories: knowledge-based tasks (testing syntactic and semantic understanding) and fundamental coding skills (including code repair, execution prediction, and fill-in-the-blank challenges).
To ensure quality, the authors implemented a rigorous pipeline:
- LLM-based Filtering: Models like GPT-3.5 were used to rate questions on clarity and relevance.
- Execution-based Verification: For coding tasks, LLMs generated "plausible but incorrect" distractors. These were executed against test cases to ensure they were genuinely wrong, forcing the model to understand the logic to find the right answer.
- Permutation Testing: Answer choices were swapped to detect and mitigate "selection bias," where models might favor a specific position (e.g., always picking 'A').
Key Insights: The "Over-reasoning" Trap
One of the most surprising findings from the CodeMMLU evaluation is that Chain-of-Thought (CoT) prompting often hurts performance. While CoT is a staple for improving performance in complex mathematical reasoning, it appears to cause models to "over-reason" on knowledge-based coding questions, leading them away from the correct, direct answer.
Other key insights include:
- Generation ≠ Understanding: There is a significant discrepancy between a model's ability to generate code and its ability to complete it in an MCQ format. This suggests many models rely on probabilistic pattern matching rather than deep comprehension.
- Selection Bias: Many models exhibit a strong positional bias. Only the most advanced models, such as GPT-4o and Claude 3.5, showed robustness against this phenomenon.
Key Results and Benchmarking
Proprietary models currently lead the pack, with GPT-4o and Claude 3.7 Sonnet consistently delivering the highest average performance across all tasks. In the open-source domain, the DeepSeek and Meta-Llama 3.1 families are the strongest contenders, with Llama 3.1 405B rivaling some closed-source models.
Execution Prediction remains the "final boss" for CodeLLMs. Even the best models struggle to accurately trace the state of a program and predict its final output, highlighting a major gap in symbolic reasoning. Interestingly, "native" reasoning models like GPT o3-mini performed exceptionally well because they could effectively decide when to apply deep reasoning versus when to provide a direct answer for knowledge-seeking tasks.
Conclusion
CodeMMLU reveals that while we have made great strides in code generation, the path to true code understanding is still long. The benchmark highlights the need for better decision-making mechanisms in models to determine when to use expensive reasoning (CoT) and when to rely on internal knowledge. Future work will focus on expanding the benchmark to include more complex, real-world software engineering scenarios like system design and multi-file debugging.
Summary updated