如何写好prompt
prompt工程
提示词要素
- 上下文
- 输入数据
- 指令
- 输出提示
编写好的prompt可以让你得到你想要的输出
- 编写清晰的指令
- 提供具体的问题,不要让gpt猜测你想问什么
-
Worse Write code to calculate the Fibonacci sequence. Better Write a TypeScript function to efficiently calculate the Fibonacci sequence. Comment the code liberally to explain what each piece does and why it's written that way.
-
- 使用SYSTEM来指示GPT的属性(是编程专家等)
-
SYSTEM When I ask for help to write something, you will reply with a document that contains at least one joke or playful comment in every paragraph. USER Write a thank you note to my steel bolt vendor for getting the delivery in on time and in short notice. This made it possible for us to deliver an important order.
-
- 使用分隔符来表明输出的部分
-
USER Summarize the text delimited by triple quotes with a haiku. """insert text here"""
-
- 指明完成该问题的步骤
-
SYSTEM 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: ". USER """insert text here"""
-
- 提供输入和输出样例,让GPT进行参照
- 要求输出的长度
- 提供具体的问题,不要让gpt猜测你想问什么
- 提供参考文本
- 输入供GPT参照的文本
- 让GPT回答的时候说明参考的文本是哪句
- 把复杂任务拆分成子任务
- 使用缩进来分类
- 让模型去思考
- 让GPT在给出解决方案前先自己评估
- 使用外部工具