The Impact of Prompt Programming on Function-Level Code Generation

Ranim Khojah, Francisco Gomes de Oliveira Neto, Mazen Mohamad, Philipp Leitner
12/29/2024
cs.SEcs.CLcs.HC

No official code found. Best implementation: icetlab/CodePromptEval (3 stars, MIT, last commit 2026-01-11).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

MIT

Dataset to evaluate the impact of five prompt programming techniques on the code generated by LLMs. This repository also includes the replication package for the study "The Impact of Prompt Programming on Function-Level Code Generation" by Khojah et al.

31R, PythonDec 11, 20249 months agoMIT

Similar Papers

Cite this paper

@article{khojah2024impact,
  title  = {The Impact of Prompt Programming on Function-Level Code Generation},
  author = {Ranim Khojah and Francisco Gomes de Oliveira Neto and Mazen Mohamad and Philipp Leitner},
  year   = {2024},
  eprint = {2412.20545},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.20545v2}
}

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/2412.20545.svg)](https://codeofpaper.com/paper/2412.20545)

Discussion