Skip to main content
QUICK REVIEW

[论文解读] ChatGPT Prompt Patterns for Improving Code Quality, Refactoring, Requirements Elicitation, and Software Design

Jules White, Sam Hays|arXiv (Cornell University)|Mar 11, 2023
Software Engineering ResearchComputer Science被引用 39
一句话总结

本文提出了使用 ChatGPT 的软件工程任务提示模式目录,详细描述了可提升需求获取、系统设计、代码质量和重构的模式,以及模式如何组合以实现高效的 LLM 辅助开发。

ABSTRACT

This paper presents prompt design techniques for software engineering, in the form of patterns, to solve common problems when using large language models (LLMs), such as ChatGPT to automate common software engineering activities, such as ensuring code is decoupled from third-party libraries and simulating a web application API before it is implemented. This paper provides two contributions to research on using LLMs for software engineering. First, it provides a catalog of patterns for software engineering that classifies patterns according to the types of problems they solve. Second, it explores several prompt patterns that have been applied to improve requirements elicitation, rapid prototyping, code quality, refactoring, and system design.

研究动机与目标

  • 介绍一套可重复使用的提示模式目录,用于通过像 ChatGPT 这样的 LLM 解决的软件工程任务。
  • 按问题类型对模式进行分类,以指导在软件生命周期内的实际用法。
  • 演示模式如何组合(patterns compounds)以提升需求获取、设计、代码质量和测试。

提出的方法

  • 为提示模式定义正式结构(名称、分类、意图、动机、结构、实现、后果)。
  • 提供一个共分为四大类别的 13 种模式的目录(Requirements Elicitation, System Design and Simulation, Code Quality, Refactoring)。
  • 描述具体的提示模式实现(例如 Requirements Simulator, Specification Disambiguation, API Generator, API Simulator, Few-shot Code Example Generation, DSL Creation)。
  • 说明模式如何交互并可以结合以应对 token 限制和迭代设计。
  • 以在 ChatGPT 中测试的示例为基础来验证模式的适用性。

实验结果

研究问题

  • RQ1哪些提示模式能够在使用 LLM 时实现对系统需求的有效获取和规范?
  • RQ2提示模式如何支持探索性系统设计、API 设计以及软件行为的仿真(由 LLMs)?
  • RQ3在使用 LLM 时哪些技术能提升代码质量和重构效果,且如何组合以获得更好的结果?

主要发现

  • 提出了一个包含 13 种提示模式的目录,分为四个面向 LLM 的软件工程任务领域。
  • 模式支持需求获取、系统设计、API 生成/仿真、代码质量和重构。
  • 模式可以组合成 compounds 以应对设计挑战和 token 限制。
  • API Generator 和 API Simulator 模式使早期 API 设计探索和交互测试成为可能。
  • Requirements Simulator 与 Visualization Generator 可以通过可视化引导的探索来共同提升需求的保真度。
  • 提示模式可以充当自动化的中间推理(如 Specification Disambiguation),以减少规格中的歧义。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。