The Impact of Prompt Programming on Function-Level Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Khojah, Ranim, Neto, Francisco Gomes de Oliveira, Mohamad, Mazen, Leitner, Philipp
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911043601563648
author Khojah, Ranim
Neto, Francisco Gomes de Oliveira
Mohamad, Mazen
Leitner, Philipp
author_facet Khojah, Ranim
Neto, Francisco Gomes de Oliveira
Mohamad, Mazen
Leitner, Philipp
contents Large Language Models (LLMs) are increasingly used by software engineers for code generation. However, limitations of LLMs such as irrelevant or incorrect code have highlighted the need for prompt programming (or prompt engineering) where engineers apply specific prompt techniques (e.g., chain-of-thought or input-output examples) to improve the generated code. While some prompt techniques have been studied, the impact of different techniques -- and their interactions -- on code generation is still not fully understood. In this study, we introduce CodePromptEval, a dataset of 7072 prompts designed to evaluate five prompt techniques (few-shot, persona, chain-of-thought, function signature, list of packages) and their effect on the correctness, similarity, and quality of complete functions generated by three LLMs (GPT-4o, Llama3, and Mistral). Our findings show that while certain prompt techniques significantly influence the generated code, combining multiple techniques does not necessarily improve the outcome. Additionally, we observed a trade-off between correctness and quality when using prompt techniques. Our dataset and replication package enable future research on improving LLM-generated code and evaluating new prompt techniques.
format Preprint
id arxiv_https___arxiv_org_abs_2412_20545
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle The Impact of Prompt Programming on Function-Level Code Generation
Khojah, Ranim
Neto, Francisco Gomes de Oliveira
Mohamad, Mazen
Leitner, Philipp
Software Engineering
Computation and Language
Human-Computer Interaction
Machine Learning
Large Language Models (LLMs) are increasingly used by software engineers for code generation. However, limitations of LLMs such as irrelevant or incorrect code have highlighted the need for prompt programming (or prompt engineering) where engineers apply specific prompt techniques (e.g., chain-of-thought or input-output examples) to improve the generated code. While some prompt techniques have been studied, the impact of different techniques -- and their interactions -- on code generation is still not fully understood. In this study, we introduce CodePromptEval, a dataset of 7072 prompts designed to evaluate five prompt techniques (few-shot, persona, chain-of-thought, function signature, list of packages) and their effect on the correctness, similarity, and quality of complete functions generated by three LLMs (GPT-4o, Llama3, and Mistral). Our findings show that while certain prompt techniques significantly influence the generated code, combining multiple techniques does not necessarily improve the outcome. Additionally, we observed a trade-off between correctness and quality when using prompt techniques. Our dataset and replication package enable future research on improving LLM-generated code and evaluating new prompt techniques.
title The Impact of Prompt Programming on Function-Level Code Generation
topic Software Engineering
Computation and Language
Human-Computer Interaction
Machine Learning
url https://arxiv.org/abs/2412.20545