Understanding Defects in Generated Codes by Language Models

Ali Mohammadi Esfahani, Nafiseh Kahani, Samuel A. Ajila
8/23/2024
cs.SEcs.AI

No confident code implementation found for this paper.

Abstract

This study investigates the reliability of code generation by Large Language Models (LLMs), focusing on identifying and analyzing defects in the generated code. Despite the advanced capabilities of LLMs in automating code generation, ensuring the accuracy and functionality of the output remains a significant challenge. By using a structured defect classification method to understand their nature and origins this study categorizes and analyzes 367 identified defects from code snippets generated by LLMs, with a significant proportion being functionality and algorithm errors. These error categories indicate key areas where LLMs frequently fail, underscoring the need for targeted improvements. To enhance the accuracy of code generation, this paper implemented five prompt engineering techniques, including Scratchpad Prompting, Program of Thoughts Prompting, Chain-of-Thought Prompting, Chain of Code Prompting, and Structured Chain-of-Thought Prompting. These techniques were applied to refine the input prompts, aiming to reduce ambiguities and improve the models' accuracy rate. The research findings suggest that precise and structured prompting significantly mitigates common defects, thereby increasing the reliability of LLM-generated code.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{esfahani2024understanding,
  title  = {Understanding Defects in Generated Codes by Language Models},
  author = {Ali Mohammadi Esfahani and Nafiseh Kahani and Samuel A. Ajila},
  year   = {2024},
  eprint = {2408.13372},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2408.13372v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2408.13372.svg)](https://codeofpaper.com/paper/2408.13372)

Discussion