Prompt Engineering 简明教程
Prompt Engineering - OUTLINE STEPS Prompt
通过使用 OUTLINE STEPS 指令,我们可以利用 ChatGPT 的功能为各种任务或流程生成结构清晰的大纲或分步程序。此技术使我们能够利用 ChatGPT 的知识和组织能力来提供清晰且简洁的指令。
Using the OUTLINE STEPS directive, we can leverage the capabilities of ChatGPT to generate structured outlines or step-by-step procedures for various tasks or processes. This technique enables us to tap into ChatGPT’s knowledge and organization abilities to provide clear and concise instructions.
Understanding the OUTLINE STEPS Directive
OUTLINE STEPS 指令允许我们提示 ChatGPT 为完成给定的任务或流程生成结构化的纲要或分步程序。通过在提示中加入 OUTLINE STEPS 指令,我们可以利用 ChatGPT 的组织技能和语言理解力来提供明确的指令。
The OUTLINE STEPS directive allows us to prompt ChatGPT to generate structured outlines or step-by-step procedures for completing a given task or process. By incorporating the OUTLINE STEPS directive in our prompts, we can harness ChatGPT’s organizational skills and language understanding to provide clear instructions.
OUTLINE STEPS 指令的基本 syntax 如下 −
The basic syntax for the OUTLINE STEPS directive is as follows −
User: Can you outline the steps to bake a cake?
ChatGPT: Absolutely! Here is an outline of the steps to bake a cake:
1. Gather the ingredients and preheat the oven.
2. Mix the dry ingredients together in a bowl.
3. Beat the wet ingredients in a separate bowl.
4. Gradually add the dry ingredients to the wet ingredients while stirring.
5. Pour the batter into a greased baking pan.
6. Bake in the preheated oven for the specified time.
7. Remove from the oven and let it cool before serving.
在这个示例中,用户请求烘焙蛋糕的步骤大纲。来自 ChatGPT 的响应包括一个结构化大纲,其中包含根据给定的提示生成的详细步骤。
In this example, the user asks for an outline of the steps to bake a cake. The response from ChatGPT includes a structured outline with step-by-step instructions generated based on the given prompt.
Best Practices for Using the OUTLINE STEPS Directive
为了充分利用 OUTLINE STEPS 指令,我们来考虑以下最佳实践 −
To make the most of the OUTLINE STEPS directive, let’s consider the following best practices −
-
Clearly Define the Task or Process − Provide a clear and concise description of the task or process for which we want an outline. This helps ChatGPT understand the context and generate relevant steps.
-
Use Action Verbs − Prompt ChatGPT to use action verbs in the steps to provide clear instructions. This ensures that each step is actionable and easily understandable.
-
Break Down Complex Tasks − If the task or process is complex, prompt ChatGPT to break it down into smaller, more manageable steps. This helps users follow the instructions easily.
-
Include Additional Details − Encourage ChatGPT to include any necessary details or specific requirements for each step. This ensures that the instructions are comprehensive and cover all essential aspects of the task or process.
Example Application − Python Implementation
让我们探索一个使用 OUTLINE STEPS 指令与 Python 脚本交互的实际示例,该脚本与 ChatGPT 交互。
Let’s explore a practical example of using the OUTLINE STEPS directive with a Python script that interacts with ChatGPT.
import openai
# Set your API key here
openai.api_key = 'YOUR_API_KEY'
def generate_chat_response(prompt):
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=100,
temperature=0.7,
n=1,
stop=None
)
return response
user_prompt = "User: Can you outline the steps to assemble a piece of furniture?\n"
chat_prompt = user_prompt + "ChatGPT: [OUTLINE STEPS: assemble a piece of furniture]"
response = generate_chat_response(chat_prompt)
print(response)
在这个示例中,我们定义了一个函数 generate_chat_response(),它接收一个提示并使用 OpenAI API 来生成一个使用 ChatGPT 生成的响应。chat_prompt 变量包含用户的提示和 ChatGPT 响应,包括 OUTLINE STEPS 指令,用于概述组装家具的步骤。
In this example, we define a function generate_chat_response() that takes a prompt and uses the OpenAI API to generate a response using ChatGPT. The chat_prompt variable contains the user’s prompt and the ChatGPT response, including the OUTLINE STEPS directive to outline the steps for assembling a piece of furniture.
Output
当我们运行脚本时,我们会收到来自 ChatGPT 的生成的响应,包括在 OUTLINE STEPS 指令中指定的具有分步说明的结构化概述。
When we run the script, we will receive the generated response from ChatGPT, including the structured outline with step-by-step instructions specified within the OUTLINE STEPS directive.
本处用户提示是“你能概述组装一件家具的步骤吗?”,而 ChatGPT 将响应内容如下:
Here the user prompt is "Can you outline the steps to assemble a piece of furniture?" and ChatGPT will respond with an output which would be similar to the following one −
1. Gather all necessary tools and parts.
2. Read through the instructions carefully.
3. Secure the frame and/or base of the furniture.
4. Attach the seat, back, and arms (if applicable).
5. Add any additional features such as cushions, drawers, etc.
6. Check all fasteners and screws for tightness.
7. Clean and inspect the finished product.
Conclusion
在本章中,我们探索了 ChatGPT 提示工程中的 OUTLINE STEPS 指令。使用 OUTLINE STEPS 指令,我们可以提示 ChatGPT 为各种任务或流程生成结构化概述或分步程序。
In this chapter, we explored the OUTLINE STEPS directive in prompt engineering for ChatGPT. Using the OUTLINE STEPS directive, we can prompt ChatGPT to generate structured outlines or step-by-step procedures for various tasks or processes.