Skip to main content
QUICK REVIEW

[Paper Review] Towards Generating Functionally Correct Code Edits from Natural Language Issue Descriptions

Sarah Fakhoury, Saikat Chakraborty|arXiv (Cornell University)|Apr 7, 2023
Software Engineering ResearchComputer Science7 citations
TL;DR

This paper introduces Defects4J-Nl2fix, a benchmark dataset of 283 Java bug fixes annotated with natural language descriptions of required code changes, to evaluate large language models (LLMs) on generating functionally correct code edits. It demonstrates that state-of-the-art LLMs achieve up to 21.20% top-1 and 35.68% top-5 accuracy on this task, highlighting progress and limitations in LLM-based code repair from natural language intent.

ABSTRACT

Large language models (LLMs), such as OpenAI's Codex, have demonstrated their potential to generate code from natural language descriptions across a wide range of programming tasks. Several benchmarks have recently emerged to evaluate the ability of LLMs to generate functionally correct code from natural language intent with respect to a set of hidden test cases. This has enabled the research community to identify significant and reproducible advancements in LLM capabilities. However, there is currently a lack of benchmark datasets for assessing the ability of LLMs to generate functionally correct code edits based on natural language descriptions of intended changes. This paper aims to address this gap by motivating the problem NL2Fix of translating natural language descriptions of code changes (namely bug fixes described in Issue reports in repositories) into correct code fixes. To this end, we introduce Defects4J-NL2Fix, a dataset of 283 Java programs from the popular Defects4J dataset augmented with high-level descriptions of bug fixes, and empirically evaluate the performance of several state-of-the-art LLMs for the this task. Results show that these LLMS together are capable of generating plausible fixes for 64.6% of the bugs, and the best LLM-based technique can achieve up to 21.20% top-1 and 35.68% top-5 accuracy on this benchmark.

Motivation & Objective

  • To address the lack of benchmarks for evaluating LLMs on generating functionally correct code edits from natural language descriptions of code changes.
  • To introduce Defects4J-Nl2fix, a dataset of 283 real-world Java bug fixes with high-level natural language descriptions of the intended changes.
  • To evaluate state-of-the-art LLMs on the nl2fix task—translating issue descriptions into correct code patches—using hidden regression and trigger tests.
  • To distinguish this task from automated program repair (APR) by using only hidden test suites, simulating real-world CI environments where tests are expensive to run.

Proposed method

  • Augment the Defects4J dataset with natural language descriptions of bug fixes extracted from Jira issue reports, focusing on localized method-level changes.
  • Construct a prompt template that combines the buggy method, the natural language issue description, and system instructions to guide LLMs in generating candidate code patches.
  • Use hidden trigger tests to validate if a generated patch fixes the specific defect and hidden regression tests to ensure no new regressions are introduced.
  • Evaluate LLM-generated patches using two metrics: top-1 accuracy (whether the first generated patch is correct) and top-5 accuracy (whether the correct patch appears in the top five outputs).
  • Apply the evaluation pipeline to multiple SOTA LLMs, including Codex and GPT-3.5-turbo, under controlled conditions with fixed prompts and test sets.
Figure 1 . Overview of the NL2Fix problem setting. Illustrated is the issue title, description, and plausible fix for the JXPATH-149 bug. The figure demonstrates the standard LLM prompt used to generate candidate patches, and the evaluation of the patches using ground truth trigger and regression te
Figure 1 . Overview of the NL2Fix problem setting. Illustrated is the issue title, description, and plausible fix for the JXPATH-149 bug. The figure demonstrates the standard LLM prompt used to generate candidate patches, and the evaluation of the patches using ground truth trigger and regression te

Experimental results

Research questions

  • RQ1Can existing large language models generate functionally correct code edits when prompted with natural language descriptions of code changes from real-world issue reports?
  • RQ2How does the performance of LLMs vary across different model architectures and temperature settings on the nl2fix task?
  • RQ3To what extent do LLM-generated patches preserve functionality while fixing defects, as measured by hidden regression tests?
  • RQ4How does the performance of LLMs on nl2fix compare to traditional automated program repair (APR) techniques, given the use of hidden test suites?

Key findings

  • The best-performing LLM achieved 21.20% top-1 accuracy and 35.68% top-5 accuracy on the Defects4J-Nl2fix benchmark, indicating that while progress is being made, significant room for improvement remains.
  • Overall, LLMs generated plausible fixes for 64.6% of the 283 bugs in the dataset, demonstrating non-trivial capability in understanding and acting on natural language change requests.
  • The performance of LLMs varied significantly across different models, with Codex-based models outperforming GPT-3.5-turbo in both top-1 and top-5 accuracy.
  • The use of hidden test suites—only accessible during evaluation—ensured a realistic assessment of functional correctness, distinguishing this benchmark from traditional APR tasks that rely on known test suites.
  • The study reveals that LLMs often generate syntactically valid but semantically incorrect patches, highlighting challenges in reasoning about program behavior from natural language.
  • The results suggest that while LLMs can understand high-level intent from issue descriptions, they still struggle with precise semantic reasoning required for correct code transformation.
(a) Temp=0.8
(a) Temp=0.8

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.