Understanding Defects in Generated Codes by Language Models

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Esfahani, Ali Mohammadi, Kahani, Nafiseh, Ajila, Samuel A.
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914922188767232
author Esfahani, Ali Mohammadi
Kahani, Nafiseh
Ajila, Samuel A.
author_facet Esfahani, Ali Mohammadi
Kahani, Nafiseh
Ajila, Samuel A.
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2408_13372
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Understanding Defects in Generated Codes by Language Models
Esfahani, Ali Mohammadi
Kahani, Nafiseh
Ajila, Samuel A.
Software Engineering
Artificial Intelligence
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.
title Understanding Defects in Generated Codes by Language Models
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2408.13372