arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2305.08360cs.SE
收藏

改进用于代码生成的ChatGPT提示词

Improving ChatGPT Prompt for Code Generation

Chao Liu, Xuanlin Bao, Hongyu Zhang, Neng Zhang, Haibo Hu, Xiaohong Zhang, Meng Yan

AI总结:

本研究通过思维链策略和多步优化设计提示词,在CodeXGlue数据集上显著提升了ChatGPT在文本到代码和代码到代码生成任务中的性能。

摘要:

自动化代码生成可以成为软件开发中的一项强大技术,通过根据需求自动生成代码,显著减少开发人员创建新代码所需的精力和时间。近期,OpenAI的语言模型ChatGPT已成为一种强大的工具,能够对广泛的文本输入(即提示词)生成类似人类的响应,包括与代码生成相关的输入。然而,ChatGPT在代码生成方面的有效性尚未得到充分理解,且生成性能可能受到提示词选择的显著影响。为回答这些问题,我们使用CodeXGlue数据集进行了实验,评估ChatGPT在两项代码生成任务(包括文本到代码和代码到代码生成)上的能力。我们利用思维链策略并经过多步优化来设计提示词。结果表明,通过精心设计提示词来引导ChatGPT,可以大幅提升生成性能。我们还分析了影响提示词设计的因素,并提供了可为未来研究提供指导的见解。

英文摘要:

Automated code generation can be a powerful technique for software development, significantly reducing developers' efforts and time required to create new code by generating it automatically based on requirements. Recently, OpenAI's language model ChatGPT has emerged as a powerful tool for generating human-like responses to a wide range of textual inputs (i.e., prompts), including those related to code generation. However, the effectiveness of ChatGPT for code generation is not well understood, and the generation performance could be heavily influenced by the choice of prompt. To answer these questions, we conducted experiments using the CodeXGlue dataset to evaluate ChatGPT's capabilities for two code generation tasks, including text-to-code and code-to-code generation. We designed prompts by leveraging the chain-of-thought strategy with multi-step optimizations. Our results showed that by carefully designing prompts to guide ChatGPT, the generation performance can be improved substantially. We also analyzed the factors that influenced the prompt design and provided insights that could guide future research.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑