Abstract
Large language models (LLMs) have manifested strong ability to generate codes for productive activities. However, current benchmarks for code synthesis, such as HumanEval, MBPP, and DS-1000, are predominantly oriented towards introductory tasks on algorithm and data science, insufficiently satisfying challenging requirements prevalent in real-world coding. To fill this gap, we propose NaturalCodeBench (NCB), a challenging code benchmark designed to mirror the complexity and variety of scenarios in real coding tasks. NCB comprises 402 high-quality problems in Python and Java, meticulously selected from natural user queries from online coding services, covering 6 different domains. Noting the extraordinary difficulty in creating testing cases for real-world queries, we also introduce a semi-automated pipeline to enhance the efficiency of test case construction. Comparing with manual solutions, it achieves an efficiency increase of more than 4 times. Our systematic experiments on 39 LLMs find that performance gaps on NCB between models with close HumanEval scores could still be significant, indicating a lack of focus on practical code synthesis scenarios or over-specified optimization on HumanEval. On the other hand, even the best-performing GPT-4 is still far from satisfying on NCB.
Introduction
While LLMs are increasingly touted as "expert-level" coders based on high scores (80-90%) on benchmarks like HumanEval, developers often encounter a "performance mismatch" in practice. A model that effortlessly solves an algorithmic puzzle may struggle with real-world tasks like parsing complex XML files or managing specific data science pipelines.
Existing benchmarks are often limited to "Intro to CS" problems—basic algorithms and data structures with simple inputs like integer lists. In contrast, real-world coding involves messy file formats, library integrations, and varied user intent. Furthermore, there is a growing concern regarding benchmark contamination, where models may be inadvertently trained on the test cases used to evaluate them, leading to inflated scores that don't reflect actual utility.
Methodology: A Semi-Automated Pipeline
To bridge the gap between synthetic puzzles and real-world utility, the authors developed a rigorous pipeline to transform "wild" user queries into a clean, executable benchmark. This process began with collecting real user queries from the CodeGeeX online service, followed by a two-step filtering process (GPT-3.5 filtering and manual review) to ensure problems were testable and deterministic.
Creating test cases for complex tasks is labor-intensive. To scale, the authors utilized a semi-automated, human-in-the-loop approach. GPT-4 generated initial reference solutions and test cases (6 for coverage, 4 for corner cases), which were then corrected and verified by expert programmers. This pipeline increased construction efficiency by more than four times compared to purely manual efforts.
The NaturalCodeBench Dataset
NaturalCodeBench (NCB) consists of 402 high-quality problems (201 in Python, 201 in Java) across six key domains: Software Engineering, Data Science, Algorithms, System Administration, AI Systems, and Front-End. Unlike HumanEval, which focuses on simple data types, NCB includes complex types such as XML/PDF files, tensors, and data frames. To ensure models follow the required naming conventions for automated evaluation, each prompt includes a representative test case.
Results and the "HumanEval Trap"
Systematic evaluation of 39 LLMs revealed a significant performance gap. While GPT-4 remains the leader, its pass@1 score on NCB is 52.8%—a sharp decline from its ~80% performance on HumanEval. This suggests a "difficulty ceiling" in NCB that current models have yet to overcome.
One of the most striking findings is the "HumanEval Trap." As shown in the figure above, models with nearly identical HumanEval scores show massive disparities on NCB. For instance, models like Phi-2 and WizardCoder-34B rank high on HumanEval but fall significantly behind on NCB. This suggests these models may be over-optimized for simple algorithmic puzzles or have suffered from benchmark contamination. Conversely, general-purpose models like GPT-3.5-Turbo showed greater robustness, jumping 10 places in rank when moving from HumanEval to NCB.
In the open-source space, DeepSeek-Coder-33B-Instruct emerged as the top performer with a score of 43.0%, notably outperforming GPT-3.5-Turbo (40.7%). The study also noted a language bias; most models performed better on English versions of queries than the original Chinese versions, despite the underlying logic being identical.
Conclusion
NaturalCodeBench serves as a vital reality check for the LLM coding community. By moving beyond simple puzzles toward the complex requirements of real-world software engineering, NCB reveals that many models are currently over-specialized. While the benchmark continues to evolve to include more difficult-to-test domains like UI/Web services, it already provides a more accurate blueprint for evaluating the practical utility of coding assistants.
Summary updated