Prompt工程最佳实践

Prompt工程最佳实践

OpenAI 文档:Best practices for prompt engineering with OpenAI API (prompt工程最佳实践) 内容总结。

  1. 用最新的模型
  2. ###""" 把说明和内容分隔
    1
    2
    3
    4
    5
    Summarize the text below as a bullet point list of the most important points.  

    Text: """
    {text input here}
    """
  3. 具体。尽可能详细地描述所需的上下文、结果、长度、格式、风格
  4. 通过举例,阐明需要的输出格式
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes  

    Desired format:
    Company names: <comma_separated_list_of_company_names>
    People names: -||-
    Specific topics: -||-
    General themes: -||-

    Text: {text}
  5. 从zero-shot开始, 再few-shot(提供例子), 都不起效时fine-tune
  6. 要求不要模糊暧昧,“fairly short”不如“3 to 5 sentence”,类似有”a few”, “not too much”
  7. 不要只说“别做什么”,说“怎么做”
  8. 说完代码需求,写一个leading word让AI接着写代码。比如让它写一个什么什么样的python代码,然后写个“import”。类似的要写SQL,leading word可以是“SELECT”
    1
    2
    3
    4
    5
    # Write a simple python function that  
    # 1. Ask me for a number in mile
    # 2. It converts miles to kilometers

    import

相关阅读:
ChatGPT Prompt Framework | Learning Prompt

评论