TL;DR
CodeApex is a new bilingual (Chinese and English) benchmark designed to rigorously evaluate Large Language Models (LLMs) across three critical programming dimensions: comprehension, generation, and correction. While top-tier models like GPT-4 lead the pack, the benchmark reveals that LLMs still struggle significantly with multi-hop reasoning and scenario-based "narrative" coding tasks compared to human experts.
What Problem Does This Paper Address?
As LLMs become ubiquitous in software engineering, the need for robust evaluation grows. However, existing benchmarks suffer from several limitations:
- Uni-lingual Focus: Most benchmarks are English-only, failing to test how models handle programming concepts across different natural languages.
- Task Narrowness: Many focus solely on code generation (e.g., HumanEval), ignoring comprehension and the vital real-world skill of code correction.
- Data Leakage: Because many benchmarks use public problems (like LeetCode), there is a high risk that these problems were included in the models' training data.
- Lack of Granularity: Existing tools often fail to distinguish between simple syntax tasks and complex algorithmic reasoning.
CodeApex tackles these by using "fresh" data from university exams and internal Online Judge (OJ) platforms, providing a more comprehensive and "leak-proof" assessment of a model's true logical reasoning and programming prowess.
Methods
The researchers structured CodeApex into three distinct tasks, as shown in the overview diagram:
- Programming Comprehension: 250 multiple-choice questions from university exams, categorized by reasoning depth: Conceptual Understanding, Commonsense Reasoning, and Multi-hop Reasoning.
- Code Generation: 476 C++ coding problems. The authors distinguish between explicit questions (e.g., "implement a quicksort") and narrative questions (scenario-based problems where the model must first extract the underlying algorithm).
- Code Correction: 1,330 erroneous code segments sampled from real student submissions. Models are tasked with fixing bugs (Wrong Answer, Time Limit Exceeded, or Runtime Error) with varying levels of metadata (code-only vs. code-with-error-message).
To ensure fair evaluation in code generation, the authors used GPT-4 to generate functional templates, preventing models from failing simply because they included "extra" conversational output (like "Here is your code:") that would break standard automated testers.
Datasets
The paper introduces the CodeApex benchmark. It stands out from predecessors like MBPP and HumanEval by being bilingual and covering all three programming tasks with fine-grained categorization.
The data is sourced from:
- University Exams: For comprehension questions, ensuring the content is less likely to be in the pre-training corpus.
- Internal OJ Platforms: For generation and correction tasks, providing a diverse range of algorithmic challenges and real-world student errors.
Key Insights and Ideas
- The "Narrative" Hurdle: Models perform significantly better on explicit prompts than on narrative ones. This suggests that the bottleneck isn't just writing code, but the "translation" step from complex natural language scenarios to algorithmic logic.
- Multi-hop Reasoning is the Ceiling: In comprehension tasks, accuracy drops sharply as the number of reasoning steps increases. While models grasp basic concepts, they struggle to trace complex execution flows.
- Bilingual Disparity: Models generally performed better on the Chinese version of the benchmark. The authors attribute this to the source questions being originally written in Chinese; even with high-quality translation, subtle language habits can introduce noise that affects model encoding.
- CoT is a Double-Edged Sword: Chain-of-Thought (CoT) prompting helped larger models (like GPT-3.5 and GPT-4) on complex reasoning but actually decreased performance for smaller models by introducing additional noise.
Key Results
The researchers evaluated 14 LLMs, including general-purpose models (GPT-4, Llama) and code-specialized ones (StarCoder, WizardCoder).
- GPT-4 is the Benchmark Leader: It achieved the highest scores across the board: ~69% in comprehension, ~54% in generation, and ~66% in correction.
- Human Superiority: Despite GPT-4's performance, it still lags behind human experts, particularly in code generation and narrative problem-solving.
- Fine-tuned Models Punch Above Their Weight: Specialized models like WizardCoder-15B often outperformed much larger general-purpose models in pure generation tasks, highlighting the value of code-specific instruction tuning.
Examples of the comprehension categories used to find these results are shown below:
Limitations and Future Work
The authors acknowledge several areas for growth:
- Language Diversity: Currently, the benchmark focuses on C++ for generation and correction. Future versions aim to include Python, Java, and other popular languages.
- Natural Language Expansion: While bilingual, adding more natural languages would provide a more global perspective on model capabilities.
- Dynamic Updating: To combat future data leakage, the benchmark will require continuous updates with new, non-public problem sets.
CodeApex serves as a challenging new yardstick, proving that while LLMs are becoming competent coders, the path to human-level algorithmic reasoning remains long.
Summary updated