Generative AI is changing the way developers interact with software systems, providing services that can 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 prompts by providing ready-to-use code snippets. Formulating the prompt appropriately, and incorporating the useful information while avoiding any information overload, can be an important factor in 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 eight prompt features on the style and the content of prompts, on the level of correctness, complexity, size, and similarity to the developers' code of the generated code. We specifically consider the task of using Copilot with 124,800 prompts obtained by systematically combining the eight considered prompt features to generate the implementation of 200 Java methods. Results show how some prompt features, such as the presence of examples and the summary of the purpose of the method, can significantly influence the quality of the result.
翻译:生成式人工智能正在改变开发者与软件系统交互的方式,它能够提供按需生成并交付新内容的服务,以满足开发者的实际需求。例如,开发者可直接在集成开发环境中编写自然语言提示来请求新代码,而基于生成式人工智能的集成服务(如Copilot)会立即响应提示,提供可直接使用的代码片段。如何构建恰当的提示,在融入有用信息的同时避免信息过载,是获取正确代码的关键因素。设计优质提示的任务被称为提示工程。本文系统研究了八个提示特征对提示风格与内容的影响,以及对生成代码的正确性、复杂度、规模及与开发者代码相似度的影响。我们特别针对Copilot的使用场景,通过系统组合上述八个提示特征生成了124,800条提示,用于实现200个Java方法。结果表明,部分提示特征(如示例的提供与方法用途的总结)会显著影响生成结果的质量。