Prompt engineering is an increasingly important skill set needed to converse effectively with large language models (LLMs), such as ChatGPT. Prompts are instructions given to an LLM to enforce rules, automate processes, and ensure specific qualities (and quantities) of generated output. Prompts are also a form of programming that can customize the outputs and interactions with an LLM. This paper describes a catalog of prompt engineering techniques presented in pattern form that have been applied to solve common problems when conversing with LLMs. Prompt patterns are a knowledge transfer method analogous to software patterns since they provide reusable solutions to common problems faced in a particular context, i.e., output generation and interaction when working with LLMs. This paper provides the following contributions to research on prompt engineering that apply LLMs to automate software development tasks. First, it provides a framework for documenting patterns for structuring prompts to solve a range of problems so that they can be adapted to different domains. Second, it presents a catalog of patterns that have been applied successfully to improve the outputs of LLM conversations. Third, it explains how prompts can be built from multiple patterns and illustrates prompt patterns that benefit from combination with other prompt patterns.
翻译:提示工程是一项日益重要的技能,用于有效与大型语言模型(如ChatGPT)进行对话。提示是向大型语言模型下达的指令,旨在强制执行规则、自动化流程,并确保生成输出的特定质量(和数量)。提示也是一种编程形式,可定制与大型语言模型的输出和交互。本文以模式形式描述了一系列提示工程技术目录,这些技术已应用于解决与大型语言模型对话时的常见问题。提示模式是一种知识迁移方法,类似于软件模式,因为它们提供了特定情境下(即与大型语言模型协作时的输出生成和交互)常见问题的可重用解决方案。本文对应用大型语言模型自动化软件开发任务的提示工程研究做出以下贡献:首先,提供了记录结构化提示模式的框架,以解决一系列问题,使其适应不同领域;其次,呈现了已成功应用于改善大型语言模型对话输出的模式目录;第三,解释了如何从多个模式构建提示,并展示了与其他提示模式组合受益的提示模式实例。