吴恩达 ChatGPT Prompt Engineering for Developers 系列课程笔记--07 Expanding

07 Expanding

本节示例如何用ChatGPT生成一封电子邮件的回复。

1) 定制化情绪

给定客户评论,我们根据评论内容和情绪产生定制的回复。下面是给定情感(positive/negative),让ChatGPT产生相应回复的prompt。

"""
You are a customer service AI assistant.
Your task is to send an email reply to a valued customer.
Given the customer email delimited by ```, \
Generate a reply to thank the customer for their review.
If the sentiment is positive or neutral, thank them for \
their review.
If the sentiment is negative, apologize and suggest that \
they can reach out to customer service. 
Make sure to use specific details from the review.
Write in a concise and professional tone.
Sign the email as `AI customer agent`.
Customer review: ```{review}```
Review sentiment: {sentiment}
"""

虽然prompt很长,但关键任务其实就是Generate a reply to thank the customer for their review.前两句是情景假定,可以让ChatGPT明确环境,下面一句指定由三引号分隔原邮件防止恶意注入。后面几句话则是对输出的要求。
最后指定回复的情感。情感为negative时ChatGPT的回复为

Dear valued customer,

Thank you for taking the time to leave a review about our product. We are sorry to hear that you experienced a price increase and that the quality of the product did not meet your expectations. We apologize for any inconvenience this may have caused you.

情感指定为positive时ChatGPT的回复为

Dear Valued Customer,

Thank you for taking the time to leave a review of our 17 piece system. We are thrilled to hear that you were able to take advantage of our seasonal sale in November and that you found the product to be useful in your daily routine. We appreciate your detailed feedback on the product and your tips for making smoothies.

当然我们也可以不指定情感让ChatGPT自己去识别。

2) temperature

temperature是语言模型的一个重要参数,用于控制生成回复的随机性。比如下图中,假设输入"my favorite food is"给ChatGPT,模型预测下一个token可能是"pizza", “sushi”, “tacos”, …。temperature为0时,模型会倾向于选择概率更高的token输出,三次的结果可能都是pizza(53%的概率),当设置temperature=0.3时,模型会增加输出的随机性,可能会选择概率更小的suchi,当然还会可能选择pizza。总之temperature越大,输出的不确定性越大。
temperature
笔者另外做了个简单的小测试,设置prompt = f""" Finish the sentence delimited by ```by adding one word ```Dog likes eating``` """,可以看到temperature=2时,ChatGPT给出各种可能的答案:

temperature= 0
response 1: bones.
response 2: bones.
response 3: bones.
temperature= 0.5
response 1: bones.
response 2: bones.
response 3: bones.
temperature= 1.0
response 1: bones.
response 2: bones.
response 3: bones.
temperature= 2.0
response 1: feet.
response 2: Bones everyday.
response 3: bones.

一般来说,为了使生成的结果可信赖、可预测,我们设置temperature=0(每次得到相同的结果)。当编写故事时如果想更有意思,可以设置更高的temperat

上一篇:吴恩达 ChatGPT Prompt Engineering for Developers 系列课程笔记–06 Transforming

下一篇:吴恩达 ChatGPT Prompt Engineering for Developers 系列课程笔记–08 Chatbot

deeplearning.ai 原课程地址

课程中文翻译地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值