提供清楚明確的指令

指示模型應採取的行動,是自訂模型行為的有效方式。請以清楚簡潔的指示提供必要背景資訊,並說明所需輸出內容。說明可以簡單列出逐步操作指示,也可以複雜到要繪製使用者的體驗和心態。

如何撰寫有效指令

有效的指令會遵循下列原則:

  • 告訴模型要做什麼。
  • 清楚明確地說明。
  • 指定輸出內容的任何限制或格式規定。

範例

舉例來說,假設您經營起司漢堡餐廳,並想使用模型瞭解哪些菜單品項最受歡迎。您希望模型將顧客訂單的轉錄稿格式設為 JSON,以便快速找出菜單項目。下表顯示模型在收到一般指令和遵循指令原則的特定指令時,會提供哪些不同的回覆:

一般操作說明
  Extract the transcript in JSON.
  Transcript:
  Speaker 1 (Customer): Hi, can I get a cheeseburger and large fries, please?
  Speaker 2 (Restaurant employee): Coming right up! Anything else you'd like to add to your order?
  Speaker 1: Hmmm, maybe a small orange juice. And could I get the fries with ketchup on the side?
  Speaker 2: No problem, one cheeseburger, one large fries with ketchup on the side, and a small
  orange juice. That'll be $5.87. Drive through to the next window please.
    
      {
        "speakers": [
          {
            "speaker": "Customer",
            "utterances": [
              "Hi, can I get a cheeseburger and large fries, please?"
            ]
          },
          {
            "speaker": "Restaurant Employee",
            "utterances": [
              "Coming right up! Anything else you'd like to add to your order?"
            ]
          },
          {
            "speaker": "Customer",
            "utterances": [
              "Hmm, maybe a small orange juice. And could I get the fries with ketchup on the
              side?"
            ]
          },
          {
            "speaker": "Restaurant Employee",
            "utterances": [
              "No problem, one cheeseburger, one large fries with ketchup on the side, and a
              small orange juice. That'll be $5.87. Drive through to the next window please."
            ]
          }
        ]
      }
    
在這個範例中,一般指令會產生比您所需更多 JSON 欄位的回應,以識別顧客訂購的菜單項目。如要改善指令,請設定更具體的輸出限制,如下表所示:
具體操作說明
  Extract the items from this transcript in JSON and separate drinks from food.
  Transcript:
  Speaker 1 (Customer): Hi, can I get a cheeseburger and large fries, please?
  Speaker 2 (Restaurant employee): Coming right up! Anything else you'd like to add to your order?
  Speaker 1: Hmmm, maybe a small orange juice. And could I get the fries with ketchup on the side?
  Speaker 2: No problem, one cheeseburger, one large fries with ketchup on the side, and a small
  orange juice. That'll be $5.87. Drive through to the next window please.
    
      {
        "drinks": [
          "orange juice"
        ],
        "food": [
          "cheeseburger",
          "large fries"
        ]
      }
    

套用指令原則後,這個範例從包含過多資料的回覆,變成只包含這個用途所需的資料。使用指令原則撰寫的指令,可引導模型生成最符合您用途的回覆。