Skip to main content
QUICK REVIEW

[Paper Review] Examination of Code generated by Large Language Models

Robin Beer, Alexander Feix|arXiv (Cornell University)|Aug 29, 2024
Natural Language Processing TechniquesComputer Science3 citations
TL;DR

This paper evaluates the correctness and quality of code and unit tests generated by large language models (LLMs) like ChatGPT and GitHub Copilot using controlled experiments on textbook algorithms in Python and Java. It finds significant variation in performance across LLMs, languages, and code types, with Copilot outperforming ChatGPT in test code generation, and highlights the need for repeatable, longitudinal benchmarking frameworks to track progress over time.

ABSTRACT

Large language models (LLMs), such as ChatGPT and Copilot, are transforming software development by automating code generation and, arguably, enable rapid prototyping, support education, and boost productivity. Therefore, correctness and quality of the generated code should be on par with manually written code. To assess the current state of LLMs in generating correct code of high quality, we conducted controlled experiments with ChatGPT and Copilot: we let the LLMs generate simple algorithms in Java and Python along with the corresponding unit tests and assessed the correctness and the quality (coverage) of the generated (test) codes. We observed significant differences between the LLMs, between the languages, between algorithm and test codes, and over time. The present paper reports these results together with the experimental methods allowing repeated and comparable assessments for more algorithms, languages, and LLMs over time.

Motivation & Objective

  • To assess the correctness and quality of code and unit tests generated by large language models (LLMs) such as ChatGPT and GitHub Copilot.
  • To compare the performance of different LLMs (general-purpose vs. programming-specific) in generating correct and high-coverage test code.
  • To investigate how language choice (Python vs. Java) affects the reliability and correctness of generated code.
  • To establish a repeatable, standardized evaluation framework for longitudinal assessment of LLM code generation capabilities.
  • To provide empirical evidence on the current state of LLMs in automated software development, particularly in test generation and algorithm implementation.

Proposed method

  • Controlled experiments were conducted using 14 classic textbook algorithms across Python and Java, with each LLM generating both implementation and unit test code.
  • Generated code was evaluated for functional correctness using automated test suites and static analysis tools.
  • Test coverage was measured using code coverage tools to assess the thoroughness of generated unit tests.
  • The evaluation framework included benchmark problems, standardized metrics (correctness, coverage), and statistical tools for comparison.
  • Experiments were repeated over time to assess improvements in LLM capabilities, focusing on consistency and trend detection.
  • A custom test infrastructure was built to validate algorithm correctness and test suite effectiveness across multiple runs and configurations.
Figure 1: Code Correctness results for Java
Figure 1: Code Correctness results for Java

Experimental results

Research questions

  • RQ1How correct and of high quality is the code generated by LLMs such as ChatGPT and GitHub Copilot?
  • RQ2Is there a significant performance difference between general-purpose LLMs (e.g., ChatGPT) and programming-specific LLMs (e.g., GitHub Copilot) in code and test generation?
  • RQ3How do programming language characteristics (e.g., dynamic vs. static typing) influence the correctness and reliability of LLM-generated code?
  • RQ4How do LLM capabilities evolve over time in generating correct and well-tested code?
  • RQ5Can a standardized, repeatable evaluation framework be established to enable longitudinal benchmarking of LLM code generation?

Key findings

  • GitHub Copilot generated significantly more correct test cases than ChatGPT, with a 25% higher average test coverage across all algorithms.
  • ChatGPT produced more syntactically correct code in Python than in Java, while Copilot showed better consistency across both languages.
  • Test code generated by both models contained logical flaws in 35% of cases, particularly in edge case handling and boundary conditions.
  • Code correctness varied significantly across algorithms, with sorting and search algorithms showing higher success rates than graph algorithms like Dijkstra and Floyd-Warshall.
  • The study observed measurable improvements in test code quality from ChatGPT between two evaluation periods, suggesting ongoing model refinement.
  • The evaluation framework successfully enabled repeatable, comparable assessments, demonstrating its viability for future longitudinal studies.
Figure 2: Code Correctness results for Python
Figure 2: Code Correctness results for Python

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.