Abstract
Recent advancements in large language models (LLMs) have showcased impressive code generation capabilities, primarily evaluated through language-to-code benchmarks. However, these benchmarks may not fully capture a model’s code understanding abilities. We introduce CodeJudge-Eval (CJ-Eval), a novel benchmark designed to assess LLMs’ code understanding abilities from the perspective of code judging rather than code generation. CJ-Eval challenges models to determine the correctness of provided code solutions, encompassing various error types and compilation issues. By leveraging a diverse set of problems and a fine-grained judging system, CJ-Eval addresses the limitations of traditional benchmarks, including the potential memorization of solutions. Evaluation of 12 well-known LLMs on CJ-Eval reveals that even state-of-the-art models struggle, highlighting the benchmark’s ability to probe deeper into models’ code understanding abilities.
Introduction: The Generation-Judgment Gap
The current standard for evaluating coding LLMs relies heavily on "language-to-code" benchmarks such as HumanEval or MBPP. In these tests, a model is given a prompt and is considered successful if its generated code passes a set of unit tests. However, this approach has significant limitations. First, models may simply be memorizing solutions from their training data (data leakage). Second, passing a few unit tests does not guarantee code robustness against all edge cases.
Most importantly, there is a distinct "Generation-Judgment Gap." Being able to produce a correct solution through pattern matching is fundamentally different from being able to logically analyze a faulty solution and explain why it fails. True code understanding is better measured by a model's ability to act as a judge—identifying whether a piece of code will result in a Wrong Answer (WA), Time Limit Exceeded (TLE), Runtime Error (RE), or Compilation Error (CE).
Methodology: The CJ-Eval Pipeline
To address these issues, we developed CodeJudge-Eval (CJ-Eval), a benchmark that shifts the focus from generation to judgment. The construction pipeline involves several key stages:
- Problem Selection: We selected 5,000 problems from the APPS dataset, spanning three difficulty levels: Introductory, Interview, and Competition.
- Candidate Generation: We utilized 16 different LLMs, including both proprietary (e.g., GPT-4, Claude-3) and open-source models (e.g., Llama-2, Mistral), to generate a diverse pool of solution attempts.
- Fine-Grained Labeling: We implemented a local execution environment to categorize every solution into one of five verdicts: Accepted (AC), Compilation Error (CE), Runtime Error (RE), Time Limit Exceeded (TLE), or Wrong Answer (WA).
- Benchmark Construction: The final benchmark consists of 457 problems and 1,860 curated solution codes. We established three difficulty settings for the judging task:
- Easy: 3 labels (Correct, Compilation Error, or Other Errors).
- Medium: 6 labels.
- Hard: 9 labels, distinguishing between specific combinations of errors (e.g., "WA and TLE").
Key Insights and Results
Our evaluation of 12 prominent LLMs reveals that code judging is significantly more challenging than code generation.
Performance Trends
- Proprietary Dominance: Claude-3.5-Sonnet and GPT-4o were the top performers. However, their performance was far from perfect, with Macro F1 scores peaking at ~50.8 on the Easy task and dropping to ~19.0 on the Hard task.
- Open-Source Struggle: Many popular open-source models, such as Llama-3.1-8B, performed worse than random guessing on the harder settings.
- Scaling and Prompting: While increasing model size generally helps, scaling from 70B to 405B parameters in the Llama-3.1 family yielded only marginal gains. Chain-of-Thought (CoT) prompting improved performance on Hard tasks requiring detailed analysis but sometimes hindered performance on Easy tasks due to "over-thinking."
The Nature of LLM Coding Ability
The results suggest that "coding ability" in current LLMs is often more about statistical mimicry than deep logical reasoning. A model might generate a correct solution for a problem but fail to recognize a bug in a slightly modified version of that same problem. This highlights the importance of the "Judge" paradigm, which draws from educational theory suggesting that judging others' work is a higher-order cognitive skill than simple production.
Conclusion and Future Work
CJ-Eval serves as a vital complement to existing generation benchmarks, providing a deeper probe into a model's actual understanding of code logic and execution. While proprietary models currently lead, the overall low scores across the board indicate a significant area for improvement.
Future work includes expanding the benchmark to other programming languages and more complex software engineering contexts, such as repository-level debugging. We also suggest that future LLMs should be explicitly trained on judging tasks to bridge the current understanding gap.
The benchmark is available at https://github.com/CodeLLM-Research/CodeJudge-Eval.
Summary updated