Analyzing Prompt Influence on Automated Method Generation: An Empirical Study with CopilotICPCICPC Full paper
Generative AI is changing the way developers interact with software systems, providing services that are able to produce and deliver new content, crafted to satisfy the actual needs of developers. For instance, developers can ask for new code directly from within their IDEs by writing natural language prompts, and integrated services based on generative AI, such as Copilot, immediately respond to a prompt by providing a ready-to-use code snippet. Indeed, formulating the prompt appropriately, incorporating all the useful information, can be an important factor towards obtaining the right piece of code. The task of designing good prompts is known as prompt engineering.
In this paper, we systematically investigate the influence of seven prompt features, about the style and the content of the prompt, on the level of correctness of the resulting code. We specifically consider the task of using Copilot to obtain the body of 200 Java methods with 124,800 prompts obtained by systematically combining the seven considered prompt features. Results show how some elements, such as the presence of examples and the summary of the semantic of the method in the prompt. can significantly influence the quality of the result.