提示工程 - OUTLINE STEPS 提示



使用 OUTLINE STEPS 指令,我們可以利用 ChatGPT 的功能來為各種任務或流程生成結構化大綱或分步程式。此技術使我們能夠利用 ChatGPT 的知識和組織能力來提供清晰簡潔的說明。

瞭解 OUTLINE STEPS 指令

OUTLINE STEPS 指令允許我們提示 ChatGPT 為完成給定任務或流程生成結構化大綱或分步程式。透過在我們的提示中加入 OUTLINE STEPS 指令,我們可以利用 ChatGPT 的組織技能和語言理解能力來提供清晰的說明。

OUTLINE STEPS 指令的基本語法如下:

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 的響應包含一個結構化的大綱,其中包含根據給定提示生成的逐步說明。

使用 OUTLINE STEPS 指令的最佳實踐

為了充分利用 OUTLINE STEPS 指令,讓我們考慮以下最佳實踐:

  • 明確定義任務或流程 - 為我們想要概述的任務或流程提供清晰簡潔的描述。這有助於 ChatGPT 理解上下文並生成相關的步驟。

  • 使用動作動詞 - 提示 ChatGPT 在步驟中使用動作動詞以提供清晰的說明。這確保每個步驟都是可操作的且易於理解。

  • 分解複雜任務 - 如果任務或流程很複雜,請提示 ChatGPT 將其分解成更小、更容易管理的步驟。這有助於使用者輕鬆遵循說明。

  • 包含其他詳細資訊 - 鼓勵 ChatGPT 包含每個步驟所需的任何詳細資訊或具體要求。這確保說明全面且涵蓋任務或流程的所有重要方面。

示例應用 - Python 實現

讓我們探討使用帶有 Python 指令碼的 OUTLINE STEPS 指令的實際示例,該指令碼與 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 指令以概述組裝傢俱的步驟。

輸出

當我們執行指令碼時,我們將收到 ChatGPT 生成的響應,包括結構化的大綱以及 OUTLINE STEPS 指令中指定的逐步說明。

這裡使用者提示是“你能概述組裝傢俱的步驟嗎?”,ChatGPT 將會回覆類似以下的輸出:

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.

結論

在本章中,我們探討了 ChatGPT 提示工程中的 OUTLINE STEPS 指令。使用 OUTLINE STEPS 指令,我們可以提示 ChatGPT 為各種任務或流程生成結構化大綱或分步程式。

廣告