Introduction
As Large Language Models (LLMs) increasingly serve as the primary engines for automated code generation, the ability to reliably evaluate their output has become a critical bottleneck. Current evaluation methodologies generally fall into two categories: test-based metrics and token-based metrics. Test-based metrics, such as pass@k, require comprehensive unit tests that are often expensive to author or unavailable for complex real-world tasks. Token-based metrics, like BLEU or CodeBLEU, measure syntactic similarity to a reference solution but fail to capture functional correctness; a logically perfect solution using different control structures may receive a poor score.
To address these challenges, we introduce CodeJudge, a framework designed for semantic code evaluation without the necessity of manual test cases. CodeJudge leverages the reasoning capabilities of LLMs to judge if code aligns with user intent through structured analysis rather than simple pattern matching.
Methodology: The "Slow Thinking" Approach
CodeJudge is inspired by the concept of "slow thinking" (System 2 reasoning), forcing the evaluator model to reason through two distinct pipelines instead of providing a quality score in a single step.
1. Analyze then Summarize (Binary Assessment)
To determine binary correctness, the framework first prompts the LLM to identify required functionalities from the task description and examine the logic of the generated code. Only after this detailed analysis does the model summarize its findings into a final "Yes/No" decision.
2. Taxonomy-Guided Fault Localization (Scoring)
For more nuanced scoring, CodeJudge utilizes a taxonomy of common coding errors categorized by severity:
- Negligible: Inefficient statements or missing imports.
- Small: Poor edge-case handling.
- Major: Logical errors leading to incorrect outputs.
- Fatal: Hallucinated functions or incomplete code that causes crashes.
The LLM identifies these specific inconsistencies, and CodeJudge calculates a final correctness score based on a weighted sum of these identified faults.
Experimental Setup
CodeJudge was evaluated across five programming languages (Python, C++, Java, JavaScript, and Go) using four major benchmarks:
- HumanEval-X: A multi-language version of the classic HumanEval set.
- CoNaLa: Python snippets from StackOverflow with human-annotated usefulness scores.
- APPS: Challenging competition-level coding problems.
- BigCodeBench: Practical tasks requiring the invocation of multiple library functions.
Key Results and Insights
CodeJudge demonstrates a significantly higher correlation with ground-truth correctness than existing methods. In binary classification tasks, it achieved an average accuracy of 80.56%. Notably, a relatively small 8-billion parameter model (Llama-3-8B) using the CodeJudge framework outperformed GPT-3.5-based state-of-the-art evaluators like ICE-Score, suggesting that the structure of the evaluation prompt is as critical as the model's scale.
One surprising insight was that providing a "ground truth" reference code sometimes decreased performance. Models occasionally focused too heavily on syntactic differences rather than high-level logic. CodeJudge maintained strong performance even in reference-free settings, outperforming many token-based methods that had access to references.
Limitations and Future Work
Despite its state-of-the-art performance, CodeJudge faces challenges in logical inference; approximately 52.83% of its errors stem from the evaluator failing to correctly infer the logic of the code it is judging. Additionally, the model can be overly conservative, penalizing code for missing error handling not explicitly requested in the prompt. Performance also tends to scale inversely with problem complexity, showing lower reliability on competition-level tasks (APPS). Future work will focus on improving the backbone reasoning capabilities to mitigate these inference gaps.
Summary updated