提供清晰而具体的说明

通过向模型提供关于要做什么的指令,可以有效且高效地自定义模型行为。指令要清晰、简洁、直接,提供所需的上下文并概述所需的输出。指令可以很简单,比如分步说明列表;也可以很复杂,例如反映用户的体验和思维模式。

如何编写有效指令

有效指令遵循以下原则:

  • 告诉模型要做什么。
  • 清晰而具体。
  • 指定输出的任何限制条件或格式要求。

示例

例如,假设您拥有一家奶酪汉堡店,并且想使用一个模型来帮助您了解哪些菜单项最受欢迎。您希望模型采用 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"
        ]
      }
    

通过应用说明原则,此示例从包含过多数据的回答转变为仅包含此使用场景所需数据的回答。使用指令原则的指令可帮助您指导模型为您的应用场景提供最有用的回答。

后续步骤