ChatGPT Prompt Engineering

ChatGPT Prompt Engineering for Developers

从Andrew Ng和Isa Fulford的联合课程中学习所获。

更加适合开发者使用,对于目前ChatGPT、Claude这样trained模型,可以不使用特别复杂的prompt校正。

1 Guidelines for Prompting

1.1 Principles of Prompting

Principle 1. Write clear and specific instructions.

clear ≠ \neq =short

  1. Use delimiters

    • Triple quotes: “”"
    • Triple backticks: ```
    • Triple dashes: ---
    • Angle brackets: <>
    • XML tages: <tag></tag>

作用:

  • Make it clear t the model that this is a seperate section.
  • Avoid prompt injections.
  1. Ask for structured output

HTML, JSON

  1. Check whether conditions are satisfied

Check assumptions required to do the task.

  1. Few-shot prompting

Give successful examples of completing tasks.

Then ask model to perform the task.

Principle 2. Give the model time to think.
  1. Specify the steps to complete a task

Step 1 - …
Step 2 - …

Step N - …

  1. Instruct the model to work out its own solution before rushing to a conclusion.

1.2 Model Limitations

Hallucination

Makes statements that sound plausible but are not true

Reducing hallucinations:

First find relevant information,

then answer the question based on the relevant information.

2 Iterative Prompt Development

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

3 Summarizing

4 Inferring

5 Transforming

6 Expanding

Temperature

  • Temperature = 0: For tasks that require reliability, predictability
  • Temperature = 0.3 (0.7, or even higher): For tasks that require variety

7 Conclusion

Role

messages = 
[
	{"role": "system"
	 "content": "You are an assistant… "},
	{"role": "user"
	 "content": "tell me a joke "},
	{"role": "assistant"
	 "content": "Why did the chicken… "},]
  • system: Sets behavior of assitant
  • assistant: Chat model
  • user: You
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值