OOP: Object-Oriented Programming Evaluation Benchmark
for Large Language Models
Abstract
Advancing automated programming necessitates robust and comprehensive code generation benchmarks, yet current evaluation frameworks largely neglect object-oriented programming (OOP) in favour of functional programming (FP), e.g., HumanEval and MBPP. To address this, ❶ our study introduces a pioneering OOP-focused benchmark, featuring 431 Python programs that encompass essential OOP concepts and features like classes and encapsulation methods. ❷ We propose a novel evaluation metric, pass@, tailored for OOP, enhancing traditional pass@ metric. ❸ Our evaluation of leading large language models (LLMs), including both general and code-specialized models, reveals three key insights: 1) pass@ offers a more relevant and comprehensive assessment for OOP code generation; 2) Despite excelling in FP, code-specialized LLMs like WizardCoder lag in OOP compared to models like ChatGPT; 3) The poor performance of all advanced LLMs on our OOP benchmark highlights a critical need for improvements in this field. Our benchmark and scripts are publicly released at: https://github.com/alphadl/OOP-eval.
1 Introduction
Large language models (LLMs, Ouyang et al., 2022a; Touvron et al., 2023), consisting of billions or even trillions of parameters’ Transformer blocks Vaswani et al. (2017), have emerged like mushrooms after the rain, especially since the emergence of ChatGPT111https://chat.openai.com. In comparison to small models, LLMs exhibit stronger generalization and reasoning capabilities Wei et al. (2022). Currently, LLMs are playing a crucial role in various tasks, e.g., code generation Chen et al. (2021); Li et al. (2022); Roziere et al. (2023), language understanding Zhong et al. (2023), human-computer interaction Tolomei et al. (2023); Moslem et al. (2023), and translation Peng et al. (2023); Lu et al. (2023).
![Refer to caption](x1.png)
Benchmark Number NL PL Task Type HumanEval Chen et al. (2021) en Python Function Programming MBPP Austin et al. (2021) en Python Function Programming APPS Hendrycks et al. (2021) en Python Function Programming CodeContests Li et al. (2022) en Multi Function Programming MultiPL-MBPP Cassano et al. (2023) Multi Multi Function Programming HumanEval-X Zheng et al. (2023) en Multi Function Programming MultiPL-HumanEval Cassano et al. (2023) en Multi Function Programming MTPB Nijkamp et al. (2022) en Python Function Programming ODEX Wang et al. (2022) Multi Python Function Programming PandasEval Zan et al. (2022) en Python Function Programming BIG-Bench Srivastava et al. (2022) en Python Function Programming CodeApex Fu et al. (2023) zh&en C++ Function Programming OOP (Our) en Python Object-Oriented Programming
The process of code generation entails crafting code in a suitable programming language from natural language descriptions of problems or requirements, aiming to effectively solve the problems or fulfill the requirements. Given that hiring professional programmers to write code consumes a significant amount of human and material resources, the importance of automated programming becomes particularly evident. Currently, the question of how to use the rising LLMs to generate more accurate automated programming codes based on problems or requirements stated by actual natural language has become an important research topic Liu et al. (2023); Zhong and Wang (2023). In the research process, code generation evaluation is crucial. Code generation evaluation not only needs to objectively and impartially reflect the current performance of LLMs in programming but also should disclose the shortcomings in LLM programming to further enhance its potential.
[Importance of OOP] According to the November programming language rankings by TIOBE 222https://www.tiobe.com/tiobe-index/, four out of the top five programming languages are OOP, which reflects the importance of OOP languages. OOP is centred on designing code around data or objects rather than organizing it based on functionality and logic Stroustrup (1988); Stefik and Bobrow (1985). OOP focuses more on the programming paradigm of class and object Wegner (1990). Functions are commonly referred to as methods in OOP.
[Motivation] However, existing code generation evaluation benchmarks primarily focus on the evaluation of FP, and lack the evaluation of relevant concepts and features of OOP, e.g., class, inheritance, encapsulation methods, etc. If using existing benchmarks in Table 1 for evaluation can only show the performance of LLMs in FP, it fails to reflect their potential in OOP, as illustrated in Figure 1.
[OOP benchmark and metric] Considering the limitations of current code generation evaluation FP benchmarks and the widespread use of the Python programming language, we propose the first OOP evaluation benchmark based on Python. OOP benchmark consists of Python programs, covering key concepts and features of OOP, including class, inheritance, encapsulation methods, etc. Furthermore, to prevent the issue where LLMs may not generate concepts and features of OOP, we have optimized the pass@ Kulal et al. (2019); Chen et al. (2021) metric by matching key points in natural language with key points in the programming language, i.e., the class names and private function names, etc, for natural language requirements are matched with the class names and private function names, etc., in the programming language. Our main contributions are summarized as follows:
-
1.
We construct and release the first OOP evaluation benchmark, which encompasses concepts and features of OOP, e.g., class, polymorphism, encapsulation methods, etc.
-
2.
We devise a new metric pass@ based on conventional pass@, tailored for the OOP code generation task, by matching key points in natural language and programming language.
-
3.
We extensively evaluated our OOP with advanced LLMs, demonstrating that i) there is still significant room for improving the OOP tasks, ii) our benchmark could serve as a robust and fair indicator that helps the community quantify LLMs’ OOP performance.
2 Related work
Code Evaluation Benchmark
In the early days of LLMs, researchers from Google and OpenAI launched artificial handwritten code evaluation benchmarks, namely MBPP Austin et al. (2021) and HumanEval Chen et al. (2021), respectively. MBPP and HumanEval are currently the mainstream code generation evaluation benchmarks, but both of them are based on the Python programming language. Subsequently, MultiPL-MBPP Cassano et al. (2023) and MultiPL-HumanEval Cassano et al. (2023) expanded upon these two benchmarks by translating the Python programming language into eighteen other programming languages, e.g., Java, C++, PHP, etc, to evaluate the performance of LLMs across others programming languages. Additionally, HumanEval-X Zheng et al. (2023) incorporated multiple test cases into the HumanEval benchmark. Apart from the extensions made to these two benchmarks, other benchmarks like CodeApex Fu et al. (2023) and ODEX Wang et al. (2022) exhibit distinctive features across different natural languages and task types. Unlike existing code evaluation benchmarks, our proposed OOP benchmark primarily focuses on the concepts and features of OOP, e.g., class, inheritance, etc. These works are summarized in Table 1.
Code Evaluation Metrics
Existing evaluation metrics can be broadly categorized into two types: dynamic evaluation metrics and static evaluation metrics. Dynamic evaluation metrics evaluate the executability of generated codes by using test cases, with pass@ Kulal et al. (2019); Chen et al. (2021) serving as the primary representative. The calculation process for pass@ is shown in Appendix A. Additionally, this category of metrics includes @ Li et al. (2022). Static evaluation metrics calculate BLUE Papineni et al. (2002), ROUGE Lin (2004), Codescore Dong et al. (2023) and CodeBLEU Ren et al. (2020) among manually written examples and generated programs. However, these code evaluation metrics do not specifically focus on evaluating the concepts and features of OOP. Therefore, we further optimized the pass@ metric based on the evaluation benchmark for OOP.
![Refer to caption](x2.png)
3 Evaluation Framework
3.1 Overview
Existing code generation benchmarks in Table 1 for are confined to FP and do not involve essential concepts and features of OOP. We take the frequently used benchmarks, HumanEval Chen et al. (2021) and MBPP Austin et al. (2021) in Table 1, as examples. They primarily evaluate the capabilities of LLMs in FP. The detailed descriptions of HumanEval and MBPP are provided in Appendix B. If we use existing benchmarks in Table 1 for evaluation, it does not show the capability of LLMs in OOP, as illustrated in Figure 1, that is, the seemingly decent LLMs (on FP tasks) perform relatively worse on OOP tasks. In addition, existing code generation evaluation metrics primarily use pass@ to evaluate the executability of the generated code. However, using the pass@ metric can not reflect whether LLMs generate concepts and features related to OOP, as illustrated in Figure 2. Therefore, pass@ can not objectively and fairly reflect the OOP capabilities of LLMs.
![Refer to caption](x3.png)
As a result, we established an OOP benchmark and proposed the evaluation metric pass@ for OOP. The process for constructing the OOP benchmark is illustrated in Figure 3.
3.2 Building OOP Benchmarks
Data Filtering.
The training data for current LLMs mostly comes from the internet. If we directly evaluate LLMs using existing OOP data from the web, it would not reflect the OOP capabilities of LLMs. Therefore, we first rigorously selected natural language description-based problems or requirements based on Python from platforms like LeetCode 333https://leetcode.com/, open-source repositories on GitHub 444https://github.com/, Stack Overflow 555https://stackoverflow.com/, and Codewars 666https://www.codewars.com/. These questions or requirements only are limited to FP and do not involve concepts and features related to OOP.
Human Rewritten.
Subsequently, we manually rewrite the collected 500 questions or requirements by adhering to the following rules:
-
1.
Designing, based on the problems or requirements, with relevant OOP concepts and features, e.g., class names, inheritance name (i.e., parent class name), encapsulation methods name (i.e., public function name and private function names), etc.
-
2.
Related problems or requirements are implemented within the public function and private function of the class while ensuring the encapsulation of that implementation.
-
3.
Convert the variables associated with problems or requirements into class attribute variables, ensuring that these variables are accessible in both public and private functions.
-
4.
If the implementation of problems or requirements is placed within the private function of the class, it is necessary to design a corresponding public function for access.
-
5.
The rewritten OOP relevant problems or requirements can be successfully implemented and accessed through objects.
Following the five rules mentioned above, we conducted a standardized rewriting of the Python-based problems or requirements.
Case Design.
Level Classification.
Given the difficulty nature of programming, we divided the designed OOP benchmark into three levels: Simple-level OOP, Moderate-level OOP, and Difficult-level OOP, as shown in Figure 7.
Simple-level OOP has program samples, and includes only class, and public function. Moderate-level OOP builds upon simple-level OOP by adding attribute variables and private functions, and has program samples. Nevertheless, the difficult-level OOP is based on the Simple-level of OOP, and adds inheritance, polymorphism and other related concepts and features of OOP. There are a total of program samples for difficult-level OOP. Although private functions are not involved in the difficulty level, the problems or requirements in difficult-level OOP are more complex and varied. Using such a level of classification, we can not only evaluate the performance of existing LLMs in OOP but also analyze the shortcomings of LLMs, which allows us to better unearth the potential of LLMs in OOP. Using this approach makes it more convenient for us to improve the OOP performance of LLMs.
3.3 Evaluation Metrics Pass@
To evaluate whether LLMs generate concepts and features related to OOP, i.e., generated subclass name, parent class name, private function name and public function name, etc, in the programming language, we proposed a pass@ metric based on OOP. The pass@ metric adds keyword points matching between natural language with programming language based on the pass@, i.e.,
(1) | ||||
pass@ | (2) |
In Eq. (3.3), represents the number of code generations for a given problem; represents the - generated program code; represents the quantity of generated codes passing tests and matches; denotes the unit test function; represents the number of keyword points in the current ; and represents the - keyword points in natural language. In Eq. (2), .
The pass@ metric not only optimizes the limitations of pass@ evaluation but also objectively and fairly reflects the OOP performance of LLMs.
4 Experiments
4.1 Experimental Setup
Evaluated LLMs
In the OOP task, we conduct experiments on mainstream LLMs. These models include both general LLMs, i.g., ChatGPT Ouyang et al. (2022b); OpenAI (2023), Llama2 Touvron et al. (2023), InternLm Team (2023a), MPT Team (2023b), DeepSeek Team (2024), Falcon Almazrouei et al. (2023), Qwen Bai et al. (2023), Yi 777https://01.ai/cn and code-specialized LLMs, e.g., CodeLlama Roziere et al. (2023), WizardCoder Luo et al. (2023), StarCoder Li et al. (2023), as shown in Table 6. The details description of LLMs are shown in Appendix D.
Parameter Settings.
In the experiment, we followed the settings on Llama2 Touvron et al. (2023), configuring the temperature to and for code generation. The remaining parameters , consistently remained unchanged. We evaluate the OOP benchmark on eight NVIDIA A100 GPUs using the vllm Kwon et al. (2023) 0.2.1.post1 framework 888https://github.com/vllm-project/vllm.
Metrics.
In terms of evaluation metrics, we use for pass@ and the proposed pass@ metrics.
Model | 1 | 80 | 100 | |||||||
pass@ | pass@ | pass@ | pass@ | pass@ | pass@ | |||||
General | Falcon-7b | -0.01 | -0.18 | -0.24 | ||||||
Falcon-40b | -0.01 | -1.79 | -2.16 | |||||||
Llama2-7b | -0.00 | -2.30 | -2.68 | |||||||
InternLm-7b | -0.01 | -0.52 | -0.64 | |||||||
Yi-6b | -0.06 | -3.40 | -4.02 | |||||||
Llama2-13b | -0.03 | -5.11 | -5.83 | |||||||
MPT-7b | -0.26 | -3.50 | -4.04 | |||||||
Qwen-7b | -0.33 | -9.34 | -10.52 | |||||||
Qwen-14b | -0.77 | -15.70 | -16.62 | |||||||
DeepSeek-7b | -1.03 | -9.11 | -10.00 | |||||||
Yi-34b | -1.11 | -13.53 | -14.46 | |||||||
Llama2-70b | -2.30 | -11.04 | -11.98 | |||||||
DeepSeek-67b | -3.95 | |||||||||
Qwen-72b | -6.58 | -21.78 | -21.69 | |||||||
ChatGPT | 42.88 | 15.69 | 75.71 | 58.28 | -17.43 | 76.20 | 59.80 | -16.40 | ||
\hdashlineSpecialized | GPT_BigCode | -0.04 | -4.42 | -5.09 | ||||||
CodeLlama-7b | -1.47 | -14.93 | -15.80 | |||||||
CodeLlama-13b-Python | -1.77 | -19.12 | -19.79 | |||||||
StarCoder | -3.35 | -18.62 | -19.56 | |||||||
CodeLlama-7b-Python | -3.41 | -15.78 | -16.26 | |||||||
CodeLlama-34b | 46.31 | 22.59 | 49.01 | 24.68 | ||||||
WizardCoder-15b | 3.02 | -3.81 | -18.60 | -19.40 | ||||||
CodeLlama-13b | 6.87 | -3.95 | -20.49 | -21.42 |
4.2 Overall Evaluation Result
The evaluation results of the LLMs with temperatures set to 0.1 and 0.8 are presented in Table 2, respectively. From the experimental results, We have obtained the following conclusions:
The OOP capabilities of the existing LLMs fall far short of the ideal state
In Table 2, we can observe that LLMs with strong coding capabilities (e.g., WizardCoder-15b, CodeLlama-7b-Python, and CodeLlama-13b, achieved scores of , , and , respectively, in the HumanEval code leaderboard 999https://huggingface.co/spaces/bigcode/bigcode-models-leaderboard), exhibit performance in OOP benchmarks that falls significantly short of the ideal state. WizardCoder-15b, CodeLlama-7b-Python, and CodeLlama-13b scored , , and , respectively, on the OOP benchmark at pass@. Their scores on pass@ were also , , and , respectively. Even the current ChatGPT model with strong general capabilities scores on pass@ and on pass@. The results indicate that the untapped potential of existing LLMs in OOP has not been fully explored.
Limitations of pass@ evaluated OOP
The scores from Table 2 indicate that using pass@ does not objectively reflect the OOP performance of LLMs, e.g., the WizardCoder-15b model achieves scores of , , and using pass@, while its scores drop to , , and when using pass@. The evaluation scores of other LLMs using pass@ in Table 2 showed a decline, once again proving the limitations of pass@ in evaluation OOP.
In addition, we also observed a significant phenomenon, e.g., when evaluated using pass@, Qwen-14b (score ) scored lower than WizardCoder-15b (score ) on pass@. However, when evaluated using pass@, Qwen-14b (score ) scored higher than WizardCoder-15b (score ) on pass@. Analyzing the experimental results of Qwen-14b and WizardCoder-15b, we observed that when evaluated using pass@, Qwen-14b outperforms WizardCoder-15b in terms of the ability to correctly generate OOP concepts and feature keywords, as illustrated in Figure 4. It also reiterates that pass@ cannot objectively and fairly reflect the evaluation results of OOP.
A larger model scale does not necessarily perform better on pass@
In Table 2, when evaluated using pass@, CodeLlama-34b scores on pass@, whereas CodeLlama-13b scores on pass@. Additionally, CodeLlama-13b-Python scores on pass@, while the corresponding CodeLlama-7b-Python scores on pass@. However, CodeLlama-7b scores on pass@, which is lower than the score achieved by CodeLlama-13b. The scores of CodeLlama-7b, CodeLlama-13b, CodeLlama-34b, CodeLlama-7b-Python, and CodeLlama-13b-Python on pass@ indicate that a larger model scale does not necessarily result in the highest scores on pass@.
![Refer to caption](x4.png)
4.3 Different-level Evaluation Results
Following the classification of OOP benchmarks in Section 3.2, we conducted evaluations for three levels of OOP benchmarks, and the results are presented in Tables 3, 4, and 5, respectively. we have drawn the following conclusions:
LLMs perform better at the simple-level OOP compared to the moderate-level and difficult-level OOP
From the simple-level OOP evaluation results in Table 3, we can see that the evaluation results using pass@ and pass@ are the same. It also indicates that LLMs can comprehend the fundamental concepts and features of OOP, e.g., class, and encapsulation methods (i.e., public function). However, in Tables 4 and 5, LLMs exhibit a weaker understanding of concepts and features related to OOP, e.g., encapsulation methods (i.e., private function), inheritance, and polymorphism, and are unable to generate corresponding code accurately. Detailed descriptions are in Appendix E.
ChatGPT has large gap in moderate-level usage using pass@ and pass@
From the results in Table 4, We observe that with pass@ evaluation, ChatGPT scores are , , and , but with pass@ evaluation, ChatGPT only achieves scores of , , and . We analyzed the moderate-level OOP results for ChatGPT, and found that its understanding of private functions is relatively poor. When evaluated using pass@, a total of codes can pass the test cases correctly. However, when evaluated using pass@, only codes can successfully pass the test cases. Among them, codes fail to match the pass@ criteria. Upon careful examination, we found that all these codes resulted from errors generated by private functions To further validate the authenticity of the experimental results, we randomly selected prompts corresponding to three error results. Subsequently, we input prompts of the erroneous results into the web version of ChatGPT for code generation, as illustrated in Figure 13, 14 and 15. We found that the code generated by online ChatGPT 101010https://chat.openai.com/ is also private function error.
ChatGPT outperforms moderate-level in difficult-level evaluation results
According to the evaluation results from Tables 3 and 4, we observe that the performance of ChatGPT at the difficult level is stronger than at the moderate level. At the difficult-level OOP, ChatGPT scores are , , and , whereas at the moderate-level OOP, ChatGPT scores are only , , and .
![Refer to caption](x5.png)
5 Discussion
In this section, we will explore the reasons behind the generally lower scores of LLMs in OOP, as well as the applicability of the Chain-of-Thoughts (CoT) method to OOP.
Why LLMs score lower in OOP benchmarks?
We use the experimental results of ChatGPT and CodeLlama-34b on pass@ as examples for analysis. As we instruct LLMs to generate relevant class names, private function names, public function names, etc., We conducted searches using simple keywords, e.g., “class”, “def _”, “def __”, “def __init__”, and “def” on both CodeLlama-34b and ChatGPT results. A detailed description of the retrieval process is provided in Appendix F. We compiled and analyzed the distribution of retrieval “class”, “def _”, “def __”, “def __init__”, and “def”, as shown in Figure 5, concluding that: 1) Weak knowledge, e.g., class, encapsulation methods, etc, of OOP in LLMs; 2) LLMs particularly lack cognition of private functions; 3) There is a certain degree of gap between CodeLlama-34b and ChatGPT. Specific example is shown in Figure 11.
The applicability of CoT in OOP.
Taking CodeLlama-13b, StarCoder, and WizardCoder-15b as examples, we respectively incorporate the few-shot, zero-shot CoT, and few-shot CoT methods to validate whether CoT approaches demonstrate applicability in OOP, as shown in Table 7. We observed a significant improvement in the scores of LLMs in OOP when using the few-shot approach, e.g., CodeLlama-13b achieved scores of , , and using the few-shot method, representing improvements of , , and , respectively, compared to the zero-shot method. In Table 7, we also observe that CodeLlama-13b achieves scores of , , and in zero-shot CoT, but its score at pass@ is lower at compared to zero-shot. Additionally, StarCoder scores , , and in zero-shot CoT, which are lower than StarCoder scores in zero-shot at , , and , respectively. The scores of the CodeLlama-13b, StarCoder, and WizardCoder-15b models on few-shot CoT are also lower than their scores on few-shot. We analyzed the experimental results of zero-shot and zero-shot CoT and found that using the CoT method introduces an illusion to the model, preventing it from directly generating the corresponding code, as illustrated in Figure 12. Therefore, it is necessary to integrate the concepts and features of OOP to design appropriate CoT strategies in order to enhance the effectiveness of generating OOP by LLMs. Appendix G provides detailed prompts for few-shot, zero-shot CoT, and few-shot CoT.
6 Conclusion
In this paper, we propose the first OOP evaluation benchmark based on Python, consisting of Python programs, encompassing key concepts and features of OOP, e.g., class, encapsulation methods, etc. Simultaneously, we propose the evaluation metric pass@ for the OOP benchmark. pass@ improves upon the limitations of pass@ by matching keyword points between natural language with program language. We evaluate mainstream LLMs using the proposed OOP benchmark and pass@ metric. Experimental results show that the current OOP of LLMs is far from ideal, which also reveals that LLMs have room for further improvement. Furthermore, Existing LLMs have a certain gap with ChatGPT in OOP. Moreover, we also investigate that applying some of the current improvement strategies directly to the OOP benchmark does not show significant improvement. In the future, we need to further strengthen the OOP knowledge of LLMs, especially regarding private functions. At the same time, we also hope that more researchers can contribute to the advancement of research in OOP.
Limitations
Our OOP benchmark has several limitations: (1) Our proposed OOP benchmark is based on the Python programming language and does not cover other OOP languages. (2) Given the incorporation of crucial concepts like polymorphism and inheritance in the OOP benchmark, it does not specifically address challenges associated with more intricate scenarios, e.g., multiple inheritance and overloading. (3) While OOP languages hold a significant share, non-OOP languages, e.g., C and Go languages, also play irreplaceable roles. In future work, we plan to consider expanding the OOP benchmark to cover a broader spectrum. Additionally, we encourage researchers to explore the potential of LLMs through evaluations based on the OOP benchmark.
Ethics Statement
We take ethical considerations very seriously. This paper focuses on establishing benchmarks for OOP to analyze the performance of existing LLMs. Our research reveals that existing LLMs fall far short of ideal performance in OOP. We conducted experiments on open and publicly available LLMs and accurately and objectively report the findings and conclusions of this paper. Therefore, we believe that this study does not raise ethical concerns.
References
- Allal et al. (2023) Loubna Ben Allal, Raymond Li, Denis Kocetkov, Chenghao Mou, Christopher Akiki, Carlos Munoz Ferrandis, Niklas Muennighoff, Mayank Mishra, Alex Gu, Manan Dey, et al. 2023. Santacoder: don’t reach for the stars! arXiv preprint.
- Almazrouei et al. (2023) Ebtesam Almazrouei, Hamza Alobeidli, Abdulaziz Alshamsi, Alessandro Cappelli, Ruxandra Cojocaru, Mérouane Debbah, Étienne Goffinet, Daniel Hesslow, Julien Launay, Quentin Malartic, Daniele Mazzotta, Badreddine Noune, Baptiste Pannier, and Guilherme Penedo. 2023. The falcon series of open language models. arXiv preprint.
- Austin et al. (2021) Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. 2021. Program synthesis with large language models. arXiv preprint.
- Bai et al. (2023) **ze Bai, Shuai Bai, Yunfei Chu, Zeyu Cui, Kai Dang, Xiaodong Deng, Yang Fan, Wenbin Ge, Yu Han, Fei Huang, et al. 2023. Qwen technical report. arXiv preprint.
- Cassano et al. (2023) Federico Cassano, John Gouwar, Daniel Nguyen, Sydney Nguyen, Luna Phipps-Costin, Donald Pinckney, Ming-Ho Yee, Yangtian Zi, Carolyn Jane Anderson, Molly Q Feldman, et al. 2023. Multipl-e: a scalable and polyglot approach to benchmarking neural code generation. IEEE TSE.
- Chen et al. (2021) Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. 2021. Evaluating large language models trained on code. arXiv preprint.
- Dong et al. (2023) Yihong Dong, Jiazheng Ding, Xue Jiang, Zhuo Li, Ge Li, and Zhi **. 2023. Codescore: Evaluating code generation by learning code execution. arXiv preprint.
- Fu et al. (2023) Lingyue Fu, Huacan Chai, Shuang Luo, Kounianhua Du, Weiming Zhang, Longteng Fan, Jiayi Lei, Renting Rui, Jianghao Lin, Yuchen Fang, et al. 2023. Codeapex: A bilingual programming evaluation benchmark for large language models. arXiv preprint.
- Hendrycks et al. (2021) Dan Hendrycks, Steven Basart, Saurav Kadavath, Mantas Mazeika, Akul Arora, Ethan Guo, Collin Burns, Samir Puranik, Horace He, Dawn Song, et al. 2021. Measuring coding challenge competence with apps. arXiv preprint.
- Kulal et al. (2019) Sumith Kulal, Panupong Pasupat, Kartik Chandra, Mina Lee, Oded Padon, Alex Aiken, and Percy S Liang. 2019. Spoc: Search-based pseudocode to code. In NeurIPS.
- Kwon et al. (2023) Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. 2023. Efficient memory management for large language model serving with pagedattention. In SOSP.
- Li et al. (2023) Raymond Li, Loubna Ben Allal, Yangtian Zi, Niklas Muennighoff, Denis Kocetkov, et al. 2023. Starcoder: may the source be with you! arXiv preprint.
- Li et al. (2022) Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, et al. 2022. Competition-level code generation with alphacode. Science.
- Lin (2004) Chin-Yew Lin. 2004. Rouge: A package for automatic evaluation of summaries. In ACL.
- Liu et al. (2023) Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. 2023. Is your code generated by chatgpt really correct? rigorous evaluation of large language models for code generation. arXiv preprint.
- Lu et al. (2023) Qingyu Lu, Baopu Qiu, Liang Ding, Li** Xie, and Dacheng Tao. 2023. Error analysis prompting enables human-like translation evaluation in large language models: A case study on chatgpt. arXiv preprint.
- Luo et al. (2023) Ziyang Luo, Can Xu, Pu Zhao, Qingfeng Sun, Xiubo Geng, Wenxiang Hu, Chongyang Tao, **g Ma, Qingwei Lin, and Daxin Jiang. 2023. Wizardcoder: Empowering code large language models with evol-instruct. arXiv preprint.
- Moslem et al. (2023) Yasmin Moslem, Rejwanul Haque, John D. Kelleher, and Andy Way. 2023. Adaptive machine translation with large language models. In EAMT.
- Nijkamp et al. (2022) Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, and Caiming Xiong. 2022. Codegen: An open large language model for code with multi-turn program synthesis. arXiv preprint.
- OpenAI (2023) OpenAI. 2023. Gpt-4 technical report. arXiv preprint.
- Ouyang et al. (2022a) Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. 2022a. Training language models to follow instructions with human feedback. NeurIPS.
- Ouyang et al. (2022b) Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, et al. 2022b. Training language models to follow instructions with human feedback. In NeurIPS.
- Papineni et al. (2002) Kishore Papineni, Salim Roukos, Todd Ward, and Wei-**g Zhu. 2002. Bleu: a method for automatic evaluation of machine translation. In ACL.
- Peng et al. (2023) Keqin Peng, Liang Ding, Qihuang Zhong, Li Shen, Xuebo Liu, Min Zhang, Yuanxin Ouyang, and Dacheng Tao. 2023. Towards making the most of chatgpt for machine translation. arxiv preprint.
- Ren et al. (2020) Shuo Ren, Daya Guo, Shuai Lu, Long Zhou, Shujie Liu, Duyu Tang, Neel Sundaresan, Ming Zhou, Ambrosio Blanco, and Shuai Ma. 2020. Codebleu: a method for automatic evaluation of code synthesis. arXiv preprint.
- Roziere et al. (2023) Baptiste Roziere, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi, **gyu Liu, Tal Remez, Jérémy Rapin, et al. 2023. Code llama: Open foundation models for code. arXiv preprint.
- Srivastava et al. (2022) Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R Brown, Adam Santoro, Aditya Gupta, Adrià Garriga-Alonso, et al. 2022. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. arXiv preprint.
- Stefik and Bobrow (1985) Mark Stefik and Daniel G Bobrow. 1985. Object-oriented programming: Themes and variations. AI magazine.
- Stroustrup (1988) Bjarne Stroustrup. 1988. What is object-oriented programming? IEEE software.
- Team (2024) DeepSeek-AI Team. 2024. Deepseek llm: Scaling open-source language models with longtermism. arXiv preprint.
- Team (2023a) InternLM Team. 2023a. Internlm: A multilingual language model with progressively enhanced capabilities.
- Team (2023b) MosaicML NLP Team. 2023b. Introducing mpt-7b: A new standard for open-source, commercially usable llms. Accessed: 2023-05-05.
- Tolomei et al. (2023) Gabriele Tolomei, Cesare Campagnano, Fabrizio Silvestri, and Giovanni Trappolini. 2023. Prompt-to-os (p2os): Revolutionizing operating systems and human-computer interaction with integrated ai generative models. arXiv preprint.
- Touvron et al. (2023) Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, et al. 2023. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint.
- Vaswani et al. (2017) Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need.
- Wang et al. (2022) Zhiruo Wang, Shuyan Zhou, Daniel Fried, and Graham Neubig. 2022. Execution-based evaluation for open-domain code generation. arXiv preprint.
- Wegner (1990) Peter Wegner. 1990. Concepts and paradigms of object-oriented programming. ACM Sigplan Oops Messenger.
- Wei et al. (2022) Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. 2022. Emergent abilities of large language models. arXiv preprint.
- Xu et al. (2023) Can Xu, Qingfeng Sun, Kai Zheng, Xiubo Geng, Pu Zhao, Jiazhan Feng, Chongyang Tao, and Daxin Jiang. 2023. Wizardlm: Empowering large language models to follow complex instructions. arXiv preprint.
- Zan et al. (2022) Daoguang Zan, Bei Chen, Dejian Yang, Zeqi Lin, Minsu Kim, Bei Guan, Yongji Wang, Weizhu Chen, and Jian-Guang Lou. 2022. Cert: Continual pre-training on sketches for library-oriented code generation. In IJCAI.
- Zheng et al. (2023) Qinkai Zheng, Xiao Xia, Xu Zou, Yuxiao Dong, Shan Wang, Yufei Xue, Zihan Wang, Lei Shen, Andi Wang, Yang Li, et al. 2023. Codegeex: A pre-trained model for code generation with multilingual evaluations on humaneval-x. arXiv preprint.
- Zhong and Wang (2023) Li Zhong and Zilong Wang. 2023. Can chatgpt replace stackoverflow? a study on robustness and reliability of large language model code generation. arXiv preprint.
- Zhong et al. (2023) Qihuang Zhong, Liang Ding, Juhua Liu, Bo Du, and Dacheng Tao. 2023. Can chatgpt understand too? a comparative study on chatgpt and fine-tuned bert. arXiv preprint.
![Refer to caption](x6.png)
![Refer to caption](x7.png)
![Refer to caption](x8.png)
![Refer to caption](x9.png)
![Refer to caption](x10.png)
![Refer to caption](x11.png)
Model | 1 | 80 | 100 | |||||||
---|---|---|---|---|---|---|---|---|---|---|
pass@ | pass@ | pass@ | pass@ | pass@ | pass@ | |||||
General | Falcon-7b | -0.00 | -0.00 | -0.00 | ||||||
Falcon-40b | -0.00 | -0.00 | -0.00 | |||||||
Yi-6b | -0.00 | -0.00 | -0.00 | |||||||
Llama2-7b | -0.00 | -0.00 | -0.00 | |||||||
InternLm-7b | -0.00 | -0.00 | -0.00 | |||||||
MPT-7b | -0.00 | -0.00 | -0.00 | |||||||
Llama2-13b | -0.00 | -0.00 | -0.00 | |||||||
DeepSeek-7b | -0.00 | -0.00 | -0.00 | |||||||
Qwen-7b | -0.00 | -0.00 | -0.00 | |||||||
Yi-34b | -0.00 | -0.00 | -0.00 | |||||||
Llama2-70b | -0.00 | -0.00 | -0.00 | |||||||
Qwen-14b | -0.00 | -0.00 | -0.00 | |||||||
DeepSeek-67b | -0.00 | -0.00 | -0.00 | |||||||
Qwen-72b | -0.00 | -0.00 | 54.66 | 54.66 | -0.00 | |||||
ChatGPT | 37.34 | 37.34 | -0.00 | 54.21 | 54.21 | -0.00 | -0.00 | |||
\hdashlineSpecialized | GPT_BigCode | -0.00 | -0.00 | -0.00 | ||||||
CodeLlama-34b | -0.00 | -0.00 | 48.99 | 48.99 | -0.00 | |||||
CodeLlama-13b-Python | -0.00 | -0.00 | -0.00 | |||||||
CodeLlama-7b | -0.00 | -0.00 | -0.00 | |||||||
CodeLlama-7b-Python | -0.00 | -0.00 | -0.00 | |||||||
StarCoder | -0.00 | -0.00 | -0.00 | |||||||
CodeLlama-13b | -0.00 | 47.72 | 47.72 | -0.00 | -0.00 | |||||
WizardCoder-15b | 16.79 | 16.79 | -0.00 | -0.00 | -0.00 |
Model | 1 | 80 | 100 | |||||||
pass@ | pass@ | pass@ | pass@ | pass@ | pass@ | |||||
General | Falcon-7b | -0.02 | -0.22 | -0.28 | ||||||
Falcon-40b | -0.02 | -0.23 | -0.72 | |||||||
Llama2-7b | -0.02 | -5.51 | -6.41 | |||||||
InternLm-7b | -0.03 | -1.03 | -1.26 | |||||||
Llama2-13b | -0.08 | -11.78 | -13.39 | |||||||
Yi-6b | -0.08 | -5.87 | -6.97 | |||||||
MPT-7b | -0.61 | -8.16 | -9.38 | |||||||
Qwen-7b | -0.80 | -20.79 | -23.27 | |||||||
DeepSeek-7b | -1.51 | -15.02 | -16.58 | |||||||
Qwen-14b | -1.82 | -32.46 | -33.98 | |||||||
Yi-34b | -2.10 | -25.03 | -27.09 | |||||||
Llama2-70b | -5.01 | -20.60 | -22.59 | |||||||
DeepSeek-67b | -7.89 | -36.76 | -37.13 | |||||||
Qwen-72b | -12.74 | -36.44 | -35.50 | |||||||
ChatGPT | 51.71 | 2.53 | -49.18 | 83.30 | 51.54 | -31.76 | 83.67 | 54.78 | -28.89 | |
\hdashlineSpecialized | GPT_BigCode | -0.08 | -8.55 | -9.71 | ||||||
CodeLlama-7b | -3.46 | -33.19 | -34.75 | |||||||
CodeLlama-13b-Python | -4.30 | -32.06 | -33.23 | |||||||
StarCoder | -8.00 | -40.12 | -41.63 | |||||||
CodeLlama-7b-Python | -8.12 | -34.68 | -35.41 | |||||||
WizardCoder-15b | -9.10 | -43.96 | -45.91 | |||||||
CodeLlama-13b | -9.46 | 51.73 | -44.11 | 54.55 | -45.43 | |||||
CodeLlama-34b | 10.23 | -10.23 | 11.41 | -40.27 | 13.48 | -40.74 |
Model | 1 | 80 | 100 | |||||||
pass@ | pass@ | pass@ | pass@ | pass@ | pass@ | |||||
General | Llama2-7b | -0.00 | -0.00 | -0.00 | ||||||
Falcon-7b | -0.00 | -0.22 | -0.28 | |||||||
MPT-7b | -0.00 | -0.23 | -0.29 | |||||||
Llama2-13b | -0.00 | -0.47 | -0.58 | |||||||
Qwen-7b | -0.00 | -1.62 | -1.96 | |||||||
InternLm-7b | -0.01 | -0.23 | -0.29 | |||||||
Falcon-40b | -0.01 | -0.23 | -0.72 | |||||||
Qwen-14b | -0.01 | -5.07 | -5.73 | |||||||
Yi-6b | -0.06 | -2.36 | -2.75 | |||||||
DeepSeek-7b | -1.51 | -15.02 | -16.58 | |||||||
Yi-34b | -0.57 | -7.61 | -7.79 | |||||||
Llama2-70b | -0.52 | -5.95 | -6.24 | |||||||
Qwen-72b | -3.11 | -16.72 | -17.44 | |||||||
DeepSeek-67b | -7.89 | -36.76 | -37.13 | |||||||
ChatGPT | 36.52 | 19.70 | -16.82 | 78.94 | 71.83 | -7.11 | 79.95 | 73.37 | -6.58 | |
\hdashlineSpecialized | WizardCoder-15b | -0.00 | -0.70 | -0.72 | ||||||
CodeLlama-13b | -0.00 | -4.62 | -5.44 | |||||||
StarCoder | -0.00 | -4.60 | -5.34 | |||||||
GPT_BigCode | -0.01 | -1.85 | -2.25 | |||||||
CodeLlama-7b-Python | -0.02 | -3.09 | -3.53 | |||||||
CodeLlama-13b-Python | -0.00 | -10.13 | -7.11 | |||||||
CodeLlama-7b | -0.05 | -2.88 | -3.46 | |||||||
CodeLlama-34b | 3.08 | 2.13 | -0.95 | 40.26 | 27.83 | -12.43 | 43.59 | 30.51 | -13.08 |
![Refer to caption](x12.png)
![Refer to caption](x13.png)
![Refer to caption](x14.png)
![Refer to caption](x15.png)
![Refer to caption](x16.png)
![Refer to caption](x17.png)
![Refer to caption](x18.png)
![Refer to caption](x19.png)
Appendix A Pass@ calculation process
The calculation process for pass@ is:
(3) |
In Eq. (3), represents the number of code generations for a given problem; represents the quantity of generated codes passing tests.
Appendix B Limitations of HumanEval and MBPP benchmarks
Appendix C Detailed construction process of OOP.
In the process of establishing the OOP benchmark, we hired a total of nine fourth-year undergraduate computer science students. Among them, two students were involved in the data collection process, four students participated in the rewriting process, and two students contributed to the use case construction phase, as shown in Figure 3.
During the data collection process, problems or requirements described in Non-English natural language are translated using the Google API, followed by manual verification. In the use case construction phase, we begin by inputting the rewritten prompt into ChatGPT to generate the corresponding code. Subsequently, the generated code is used for input testing. Finally, the output results are saved along with the input tests to serve as test cases. However, the code generated by ChatGPT may not always be correct, requiring manual inspection and correction. During the process of building the benchmark for OOP, we spent a total of $200.
Model name | Size | Years | Open-source | Task type |
---|---|---|---|---|
Falcon | 7b, 40b | ✔ | General | |
DeepSeek | 7b, 67b | ✔ | General | |
Llama2 | 7b, 13b, 70b | ✔ | General | |
Yi | 6b, 34b | ✔ | General | |
InternLm | 7b | ✔ | General | |
MPT | 7b | ✔ | General | |
Qwen | 7b, 14b, 72b | ✔ | General | |
ChatGPT | N/A | ✗ | General | |
GPT_BigCode | 1.12b | ✔ | Code-specialized | |
CodeLlama | 7b, 13b, 34b | ✔ | Code-specialized | |
CodeLlama-Python | 7b, 13b | ✔ | Code-specialized | |
StarCoder | 15b | ✔ | Code-specialized | |
WizardCoder | 15b | ✔ | Code-specialized |
Appendix D The details of LLMs
We have selected a total of mainstream LLMs, including both code-specialized models and general models, e.g.,
ChatGPT Ouyang et al. (2022b); OpenAI (2023): ChatGPT was released by OpenAI in November and has been widely recognized for its astonishing conversational generation capabilities. In March , OpenAI released ChatGPT . In our experiments, we chose to use ChatGPT (gpt-3.5-turb) to explore its OOP.
GPT_BigCode Allal et al. (2023): GPT_BigCode, derived from the BigCode project, is a billion parameter model trained on subsets of Java, JavaScript, and Python from The Stack.
CodeLlama Roziere et al. (2023): CodeLlama is a series of large-scale code language models based on Llama2 that offers state-of-the-art performance in open modeling, function completion, support for large input contexts, and zero-shot instruction following capabilities for programming tasks. CodeLlama includes the base model (CodeLlama), the Python specialized model (CodeLlama-Python), and the instruction-following model (CodeLlama-Instruct), each available with 7b, 13b, and 34b parameters. In our experiments, we selected the base models with 7b, 13b, and 34b parameters, as well as the Python-specialized models with 7b and 13b parameters.
WizardCoder Luo et al. (2023): WizardCoder is a model fine-tuned using the Evol-Instruct Xu et al. (2023) method based on CodeLlama. WizardCoder includes the base model and the Python specialized model (WizardCoder-Python). The base model comes in 1b, 3b, and 15b variants, while the Python specialized model is available in 7b, 13b, and 34b. In our experiments, we selected the 15b version of the base model.
StarCoder Li et al. (2023): StarCoderBase is trained on The Stack (v1.2) 111111https://huggingface.co/datasets/bigcode/the-stack data in the GitHub repository. The StarCoder model is fine-tuned based on the StarCoderBase model.
Llama2 Touvron et al. (2023): The Llama2 model was released by the Meta team in July 2023. Llama2 is a large language model (LLM) that has undergone pre-training and fine-tuning, with a range of parameters from 7 billion to 70 billion. In our experiments, we selected models with 7b, 13b, and 70b parameters.
InternLm Team (2023a): InternLM encompasses models designed for practical scenarios. The InternLM model includes both a base model and a chat model with 7b and 20b parameters. In our experiments, we selected the base model with 7b parameters.
MPT Team (2023b): The MPT model is a decoder-style transformer trained by MosaicML. In our experiments, we selected the base model with 7b parameters.
DeepSeek Team (2024): DeepSeek is an LLM based on the power-law scaling, encompassing models with 7b and 67b parameters. In our experiments, we opted to utilize the foundational models with 7b and 67b parameters.
Falcon Almazrouei et al. (2023): The Falcon series models are primarily trained on diverse and high-quality corpora assembled from web data, including the 7b, 40b, and 180b parameter models. In our experiments, we opted to use models with 7b and 40b parameters.
Qwen Bai et al. (2023): The Qwen model is a large language model based on the Transformer architecture, trained on a vast and diverse dataset for pre-training. The dataset encompasses a wide range of types, including extensive web text, professional books, code, and more. During our experiments, we selected the base models with 7b, 14b, and 72b parameters.
Yi 121212https://01.ai/cn: The Yi series models are developed as bilingual language models with a focus on Chinese and English. Yi models are trained on a 3T multilingual corpus and demonstrate promising prospects in language understanding, common sense reasoning, and reading comprehension. In our experiments, we selected models with 6 billion and 34 billion parameters.
We use mainstream code-specialized and general models with the aim of better illustrating the performance of existing LLMs in OOP. The overview of the evaluated models is presented in Table 6.
Appendix E Analysis of results
In simple-level OOP of Table 3, ChatGPT scored at pass@. However, in the difficult-level and Moderate-level OOP, ChatGPT scored only and at pass@, respectively. CodeLlama-13b scored at pass@ in the simple-level OOP. In the difficult-level and Moderate-level OOP, CodeLlama-13b scored only and at pass@, respectively. Additionally, WizardCoder-15b scored at pass@ in the simple-level OOP., while in the difficult-level and Moderate-level OOP, it scored only and at pass@, respectively. It indicates that LLMs can comprehend and execute simple class, and public functions. However, their understanding of private functions, inheritance, and polymorphism is relatively weak. It also provides us with room for improvement.
Appendix F Detailed description of the retrieval process
During the retrieval process, we first search for the class class and attribute variables def __init__. Subsequently, we replace def __init__ in the generated code snippets with <endoftext>, and finally, we search for private functions def _ and def __. Using this approach helps prevent the inadvertent retrieval of attribute variables as private functions during the search for private functions. The process of searching for public functions def follows a similar method.
Model | CodeLlama_13b | WizardCoder_15b | StarCoder | ||||||
---|---|---|---|---|---|---|---|---|---|
pass@ | |||||||||
zero-shot CoT | |||||||||
few-shot | |||||||||
few-shot CoT |
Appendix G Details of using the CoT strategy.
zero-shot CoT. We incorporate "Let’s think step by step" on top of the zero-shot, enabling LLMs to stepwise infer and thus complete the entire code generation process, as shown in Figure 8.
few-shot. We randomly selected three samples from MBPP Austin et al. (2021), but these three samples are limited to functions and do not involve relevant concepts and features of OOP. Subsequently, we manually re-write the selected three samples into examples of OOP based on the five major principles. Finally, the constructed samples were integrated into zero-shot to form a few-shot, as shown in Figure 9.
few-shot CoT. On the foundation of a few-shot, we first instruct the LLMs to generate corresponding steps based on the question and then proceed step by step to complete the entire code generation process, as shown in Figure 10.