https://learn.deeplearning.ai/courses/chatgpt-prompt-eng/lesson/1/introduction
git https://github.com/MSzgy/ChatGPT-Prompt-Engineering-for-Developers/tree/main
Introduction
本篇课程是由OpenAI与Deeplearing合作带来的Prompt课程,介绍了如何提高prompt的效果。
Guidelines
Write clear and specific instructions
User delimiters
example:
text = f"""
You should express what you want a model to do by \
providing instructions that are as clear and \
specific as you can possibly make them. \
This will guide the model towards the desired output, \
and reduce the chances of receiving irrelevant \
or incorrect responses. Don't confuse writing a \
clear prompt with writing a short prompt. \
In many cases, longer prompts provide more clarity \
and context for the model, which can lead to \
more detailed and relevant outputs.
"""
prompt = f"""
Summarize the text delimited by triple backticks \
into a single sentence.
```{text}```
"""
从上面例子可看出,用了“”“ 以及```来分割原始的prompt以及text,这样做的好处在于在你的业务系统中,避免Prompt Injecection:
Ask for structured outputs
可以将输出定义为Html,Json,Markdown格式
Check whether conditions are satisfied
可以检查需要做某个task的前提是否满足。
Few-shot prompting
在做某个任务之前,在prompt中提供成功的例子。
Give the model time to think
Specify the steps to complete a task
Instruct the model to work out its own solution before rushing to a conclusion
可以把任务分成步骤去进行,引导模型按步骤思考并输出结果。
Model limitations
幻觉(hallucination)
how to reduce:
First find relevant information
Then answer the questions based on the relevant information
Iterative
在写提示词时,我们要清楚地认识到通过一次Prompt要取得好的结果,这是很难的也是不现实的。好的结果需要不断迭代,就像训练模型一样。
Iterative process:
Try something
Analyze where the result does not give what you want
Clarify instructions, give more time to think
Refine prompts with a batch of examples
Summarizing
在这节直接通过代码举了几个例子,对text进行summary.
Inferring
这节举了例子,使用ChatGPT输出text的topic,没有啥可说的,比较简单。
Transforming
本节利用ChatGPT做了text语言转换,以及tone 转换以适应不同场景与人群。
Expanding
本节利用ChatGPT根据客户对于商品的评论以及评论态度生成了相应的邮件。
Chatbot
Role
System
give an overall instruction
user
input user query
assistant
ChatGPT output