2

OpenAI Prompt Engineering 摘录和总结

 8 months ago
source link: https://jiajunhuang.com/articles/2024_01_07-openai_prompt_engineering.md.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

OpenAI Prompt Engineering 摘录和总结

这篇文章是指导如何写出比较好的prompt,本文是我的摘录和总结。

原文链接:https://platform.openai.com/docs/guides/prompt-engineering/strategy-write-clear-instructions

写出清晰的指令

  • 写清楚,写详细。比如”Who’s president?“就不清晰,OpenAI就得猜测你的意思,写成 “Who was the president of Mexico in 2021, and how frequently are elections held?” 就清晰很多
  • 明确告诉OpenAI它要扮演的角色。例如,生成SQL时,写上”You’re a MySQL expert”,生成的SQL就会更符合MySQL标准,质量也更高
  • 用户的输入,要明确的分隔符包裹起来,例如:

    Summarize the text delimited by triple quotes with a haiku.
    
    """insert text here"""
    
  • 明确告诉OpenAI,完成任务所需要的步骤(step-by-step 很重要),例如:

    Use the following step-by-step instructions to respond to user inputs.
    
    Step 1 - The user will provide you with text in triple quotes. Summarize this text in one sentence with a prefix that says "Summary: ".
    
    Step 2 - Translate the summary from Step 1 into Spanish, with a prefix that says "Translation: ".
    
  • 如果希望用户按照你的模板输出,可以给OpenAI举一个例子

  • 可以明确告诉OpenAI希望的输出长度。OpenAI很喜欢废话文学,如果你希望简练一些,或者讲的更详细一些,那么你就得明确告诉它。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK