如何使用ChatGPT得到更满意的结果(7):面向开发者的ChatGPT Prompt Engineering (Expanding)

承接上篇,继续整理关于面向开发者的Prompt Engineering教程笔记,教程之前的部分见:如何使用ChatGPT得到更满意的结果:Prompt Engineering (2)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(3):面向开发者的ChatGPT Prompt Engineering (迭代式Prompt开发)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(4):面向开发者的ChatGPT Prompt Engineering (Summarizing)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(5):面向开发者的ChatGPT Prompt Engineering (Inferring)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(6):面向开发者的ChatGPT Prompt Engineering (Transforming)_Dorothy30的博客-CSDN博客

整理的内容基本上英文原文都来自于教程,有需要的朋友可以直接戳https://learn.deeplearning.ai/。这篇笔记主要整理教程中的Expanding部分。

扩展(Expanding)是一种任务,它一般是将短文本片段,比如一组说明或主题列表,输入到大型语言模型中,并让模型生成更长的文本,例如一封电子邮件或一篇关于某个主题的文章。在这一节中,你将生成针对每个客户的评论量身定制的客户服务电子邮件。我们还将使用模型的另一个输入参数称为温度(temperature)来调整模型响应中的探索程度和多样性。

我们已经在Inferring部分使用过类似的prompts来提取情感了。现在我们给出一个关于搅拌机的用户评论,并根据情感极性定制回复。

首先我们先指定情感为“negative”,并给出搅拌机的评论。

sentiment = "negative"

# review for a blender
review = f"""
So, they still had the 17 piece system on seasonal sale for around $49 \
in the month of November, about half off, but for some reason (call it \
price gouging) around the second week of December the prices all went \
up to about anywhere from between $70-$89 for the same system. And the \
11 piece system went up around $10 or so in price also from the earlier \
sale price of $29. So it looks okay, but if you look at the base, the part \
where the blade locks into place doesn’t look as good as in previous editions \
from a few years ago, but I plan to be very gentle with it (example, I crush \
very hard items like beans, ice, rice, etc. in the blender first then \
pulverize them in the serving size I want in the blender then switch to the \
whipping blade for a finer flour, and use the cross cutting blade first when \
making smoothies, then use the flat blade if I need them finer/less pulpy). \
Special tip when making smoothies, finely cut and freeze the fruits and \
vegetables (if using spinach-lightly stew soften the spinach then freeze \
until ready for use-and if making sorbet, use a small to medium sized food \
processor) that you plan to use that way you can avoid adding so much ice \
if at all-when making your smoothie. After about a year, the motor was \
making a funny noise. I called customer service but the warranty expired \
already, so I had to buy another one. FYI: The overall quality has gone \
done in these types of products, so they are kind of counting on brand \
recognition and consumer loyalty to maintain sales. Got it in about two days.
"""

然后我们使用ChatGPT来生成一个对于客户的回复,并提到了如果情感是积极或者消极的话需要怎么回复。

prompt = f"""
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}
"""
response = get_completion(prompt)
print(response)

 

当然,你也可以使用语言模型的参数温度(temperature)来调整文本,即在get_completion函数中添加temperature参数。你可以将温度视为模型探索程度或随机性的度量,它可以帮助我们改变模型响应的多样性。

一般而言,如果你构建的应用程序需要可预测的响应,那么建议使用温度为零。如果你希望以更有创意的方式使用模型,希望得到不同的输出,那么可以使用更高的温度。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值