提示使用者產生的工程型 AI 技術

提示工程是一種設計,會將問題交由 LLM 取得,以便取得最佳輸出內容。僅透過純文字語言提示,與 LLM 直接互動。

過去,如要使用機器學習模型,通常必須對資料集、統計資料和模擬技術有深入的瞭解。LLM 目前支援英文和其他語言

寫個優秀的技術工程師並不需要編寫程式碼,但是,發揮創意及持續留存技術,可在旅程中獲得莫大的助益。請繼續閱讀,瞭解一些實用的提示技巧

提示最佳做法

  1. 清楚說明最重要的內容或資訊,

  2. 建立提示的結構:先定義角色,然後提供背景資訊/輸入資料,再提供操作說明。

  3. 使用具體且不同的範例來協助模型縮小聚焦範圍並產生更準確的結果。

  4. 使用限制來限制模型輸出結果的範圍。這有助於避免在說明中因有實質錯誤而失誤。

  5. 將複雜的工作細分為一系列簡單的提示。

  6. 指示模型先評估或檢查自己的回應,再產生回應。(「請務必將回覆內容限制在 3 句話」、「做得好,以 1 至 10 分來表示,為求精簡?」「請問你認為正確嗎?」

最重要的是:

發揮創意!廣告素材和開放性越大,成效就越高。LLM 和提示工程仍在他們的嬰幼兒之中,且每天都會不斷演進。

提示類型

直接提示 (零拍)

直接提示 (也稱為零接觸) 是最簡單的提示類型。只會提供操作說明,而非模型。您也可以將操作說明標示為問題,或向模型提供「角色」,如下方第二個範例所示。

提供:

  1. 教學
  2. 背景資訊

產生提案:

Prompt: Can you give me a list of ideas for blog posts for tourists visiting
New York City for the first time?

角色提示:

Prompt: You are a mighty and powerful prompt-generating robot. You need to
understand my goals and objectives and then design a prompt. The prompt should
include all the relevant information context and data that was provided to you.
You must continue asking questions until you are confident that you can produce
the best prompt for the best outcome. Your final prompt must be optimized for
chat interactions. Start by asking me to describe my goal, then continue with
follow-up questions to design the best prompt.

資料整理:

Prompt: Create a four-column spreadsheet of 10 highly-rated science fiction
movies, year of release, average audience rating, and top 3 keywords from
audience reviews.

Make sure to cite the source of the audience rating.

提示範例 (單次、少數和多鏡頭)

一次性提示可清楚描述模型要以模擬的方式呈現,

以一個例子產生提案:

Prompt:

Come up with a list of ideas for blog posts for tourists visiting
New York City for the first time.

1. Fuggedaboutit! Where to Stay in New York City On Your First Visit

使用多拍攝和多鏡頭提示,能進一步呈現模型要執行的作業範例。在較複雜的工作要執行模式複製作業,或您需要以特定方式說明輸出內容時,結構也非常實用。

最輕微的情緒分類:

Prompt:

Great product, 10/10: Positive
Didn't work very well: Negative
Super helpful, worth it: Positive
It doesn't work!:

在此提示執行時,模型的回應會分類為「It't work」(運作方式無效),如範例所示。

多鏡頭表情符號回應器:

Prompt: Predict up to 5 emojis as a response to a text chat message. The output
should only include emojis.

input: The new visual design is blowing my mind 🤯
output: ➕,💘, ❤‍🔥

input: Well that looks great regardless
output: ❤️,🪄

input: Unfortunately this won't work
output: 💔,😔

input: sounds good, I'll look into that
output: 🙏,👍

input: 10hr cut of jeff goldblum laughing URL
output: 😂,💀,⚰️

input: Woo! Launch time!

流程相同,但由於提示訊息較為複雜,因此我們提供更多範例模擬。

鏈結提示

」。結合使用幾個提示功能,即可取得更複雜的工作,在回應前必須先提出理由。

Prompt:

The odd numbers in this group add up to an even number: 4, 8, 9, 15, 12, 2, 1.
A: Adding all the odd numbers (9, 15, 1) gives 25. The answer is False.
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:

從零

從先前提起的零拍攝提示時,要能省去一個零接觸提示,並新增指示:「讓我們逐步思考。」LLM 能依據此操作說明產生鏈結,而且通常較為準確。這是讓 LLM 產生文字問題等正確解答的絕佳方法。

Prompt:

I went to the market and bought 10 apples. I gave 2 apples to the neighbor and
2 to the repairman. I then went and bought 5 more apples and ate 1. How many
apples was I left with?

Let's think step by step.

提示疊代策略

瞭解在數次 (可能為數十次) 時重新編寫提示的感受。如果遇到以下問題,可參考相關修正提示:

注意:隨著模型改善,這些策略可能會越來越不實用或需要。

  1. 重複出現關鍵字、詞組或提案

  2. 指定所需的輸出格式 (CSV、JSON 等)

  3. 請務必使用大寫以提高壓力或提供指示。或者,您也可以嘗試「誇張」或「誇大」用語;例如:「您的說明不應極為錯誤。」每個字詞都應聽得清楚!」

  4. 使用同義詞或替代措辭 (例如使用「Summarize」取代「Summarize」),在部分輸入文字中加上「tldr」。不妨替換不同的字詞或詞組,並記錄哪些字詞或字詞的表現較佳。

  5. 嘗試使用大提示搭配三明治技巧,在不同位置新增相同的陳述式。

  6. 使用提示資料庫汲取靈感。Prompt Hero 和這個 mptmp Gallery 是著手展開測試的最佳起點。

其他資源

提示最佳做法

瞭解提示 (外部)