ChatGPT提示词工程(六):Expanding扩展

目录

  • 一、说明
  • 二、安装环境
  • 三、扩展(Expanding)
    • 1. 自定义自动回复客户电子邮件
    • 2. 提醒模型使用客户电子邮件中的详细信息
    • 3. 参数 temperature

一、说明

这是吴恩达 《ChatGPT Prompt Engineering for Developers》 的课程笔记系列。
本文是第七讲的内容:Expanding

二、安装环境

参考: ChatGPT提示词工程(一):Guidelines准则 的第二节
不过本节课中的辅助函数不一样了,增加了一个参数 temperature

def get_completion(prompt, model="gpt-3.5-turbo", temperature=0): # Andrew mentioned that the prompt/ completion paradigm is preferable for this classmessages = [{"role": "user", "content": prompt}]response = openai.ChatCompletion.create(model=model,messages=messages,temperature=temperature, # this is the degree of randomness of the model's output)return response.choices[0].message["content"]

三、扩展(Expanding)

1. 自定义自动回复客户电子邮件

# given the sentiment from the lesson on "inferring",
# and the original customer message, customize the email
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.
"""
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)

客户邮件内容review翻译成中文为:

所以,在11月份,他们仍然有17件制的季节性销售,售价约为49美元,大约减半,但由于某种原因(称之为价格欺诈),在12月的第二周左右,同一种制的价格都上涨到了大约70美元到89美元之间。11件套的售价也比早先29美元的售价上涨了10美元左右。所以看起来还可以,但如果你看看底座,刀片锁定的部分看起来不像几年前的前几版那么好,但我计划对它非常温和(例如,我先在搅拌器里粉碎非常硬的东西,比如豆子、冰、大米等,然后在搅拌器里把它们粉碎成我想要的服务大小,然后切换到搅拌刀片,以获得更好的面粉,在做奶昔时首先使用横切刀片,如果我需要它们更细/更少浆状的话,再使用扁平刀片)。做冰沙时,要特别注意切开和冷冻水果和蔬菜(如果用菠菜–轻轻炖菠菜,让菠菜变软,然后冷冻,直到可以使用–如果做冰糕,用中小型食品加工机),这样你就可以避免在做冰沙时添加太多的冰。大约一年后,马达发出了奇怪的声音。我给客服打了电话,但保修期已经过了,所以我不得不再买一台。仅供参考:这些类型的产品已经实现了整体质量,所以他们在某种程度上依赖于品牌认知度和消费者忠诚度来维持销售。大约两天后就拿到了。

prompt
你是一名客服人工智能助理。
你的任务是向重要客户发送电子邮件回复。
鉴于客户电子邮件由```分隔,
生成回复以感谢客户的评价。
如果情绪是积极的或中性的,感谢他们的评价。
如果情绪是负面的,道歉,并建议他们可以联系到客户服务。
确保使用评价中的具体细节。
用简洁和专业的语气写作。
用“AI customer agent”签名

运行结果:
在这里插入图片描述

上述代码中,sentiment = “negative” 是写死的, 我们可以运用上一课所学(Inferring),让它自己判断客户评价的情绪

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.
What is the sentiment of their review, 
which is delimited with triple backticks?
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}```
"""
response = get_completion(prompt)
print(response)

prompt:添加了一句:
What is the sentiment of their review,
which is delimited with triple backticks?

运行结果:
在这里插入图片描述

2. 提醒模型使用客户电子邮件中的详细信息

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, temperature=0.7)
print(response)

prompt:添加了一句 Make sure to use specific details from the review.
get_completion参数temperature允许你改变模型的探索和多样性的程度
运行结果:
在这里插入图片描述

3. 参数 temperature

在这里插入图片描述
参数temperature能使我们改变模型响应的多样性。
比如,我最喜欢的食物,模型预测pizza可能性为53%,sushi的可能性为30%,tacos的可能性为5%
如果temperature = 0 则模型总是给出pizza
如果 temperature > 0 则模型给出的结果可能就会是 sushi 或者 tacos

https://blog.csdn.net/Jay_Xio/article/details/130460267



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/26381.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

通达信自动包络线指标公式以及ATR通道指标

根据亚历山大埃尔德在其著作《以交易为生》中的描述,自动包络线的设计思路是将通道看作试穿衬衫一样,寻找那些穿起来既不过松也不过紧的衬衫,只让手腕和脖子露在外面。自动包络线能够适应最近的行情波动,只有在极端情况下&#xf…

微信支付费率0.38还是0.6,0.2费率怎么开,3分钟申请教程

目前微信支付官方给到商家的费率统一为0.6%,部分线下实体店商家由服务商推广开户一般是用的0.38%的费率。 其实很多商户都不知道,其实还可以开通更低的费率,0.2~0.35%的费率。 现在就分享一个如何在几分钟申请提交开通0.2费率的…

微信支付申请费率0.2%的方法,百分百通过不求人

微信支付通用的费率都是0.6%,那么如何申请0.2%呢。方法很简单。

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing det

报错: 此错误消息表明您已达到API的最大月支出(硬限制)。这意味着您已经消耗了分配给计划的所有积分或单位,并且已经达到计费周期的限制。这种情况可能有几个原因,例如: 您使用的是高容量或复杂的服务&…

关于0.2%费率的微信支付,你需要了解一下。

经营流水大,支付手续费高,想要减少手续费?不了解微信支付申请流程,步骤太多太繁琐,想要快捷开户?不用担心,这些都可以用微信支付特约商户解决! 为助力商家享受到更快捷的微信商户申…

定时任务原理方案综述

ChatGPT狂飙160天,世界已经不是之前的样子。 新建了人工智能中文站https://ai.weoknow.com 每天给大家更新可用的国内可用chatGPT资源 导读 本文主要介绍目前存在的定时任务处理解决方案。业务系统中存在众多的任务需要定时或定期执行,并且针对不同的系…

巴比特 | 元宇宙每日必读:AI搜索大战打响!微软官宣ChatGPT引入Bing,“文心一言”传首站将接入百度搜索,接下来是谁?...

摘要:据财联社报道,北京时间8日凌晨,微软宣布推出由ChatGPT支持的最新版Bing搜索引擎和Edge浏览器,新版Bing于今日上线,不过预览人数有限。微软计划近期推出移动版本,预览人数有望扩展至数百万人。那么&…

Docker 十周年 | 历史上的今天

整理 | 王启隆 透过「历史上的今天」,从过去看未来,从现在亦可以改变未来。 今天是 2023 年 3 月 20 日,在 1999 年的今天,人类首次成功乘热气球环球飞行。在 24 年的今天,瑞士人皮尔卡、英国人琼斯经过近 20 天的飞行…

macOS 下载汇总(系统、应用和教程) 2023 持续更新中

macOS Ventura 13, macOS Monterey 12, macOS Big Sur 11, macOS Catalina 10.15, macOS Mojave 10.14, macOS High Sierra 10.13, macOS Sierra 10.12 请访问原文链接:https://sysin.org/blog/macOS/,查看最新版。原创作品,转载请保留出处。…

网景浏览器正式发布 | 历史上的今天

整理 | 王启隆 透过「历史上的今天」,从过去看未来,从现在亦可以改变未来。 今天是 2022 年 12 月 15 日,在 56 年前的今天,美国动画制作家迪士尼逝世。他创造的米老鼠形象曾经给世界上的每一个孩子带来了欢乐;他是一位…

马化腾微信转发文章称要“收紧队形”,腾讯公关回应;微软宣布终止支持 Cortana;TypeScript 5.1发布|极客头条...

「极客头条」—— 技术人员的新闻圈! CSDN 的读者朋友们早上好哇,「极客头条」来啦,快来看今天都有哪些值得我们技术人关注的重要新闻吧。 整理 | 梦依丹 出品 | CSDN(ID:CSDNnews) 一分钟速览新闻点&#…

苹果电脑惊现比特币白皮书,乔布斯会是中本聪吗?

原创:刘教链 * * * 隔夜比特币继续在28k附近横盘,静静等待30日线向上靠近。 市场总在百无聊赖之际找些乐子。昨天,圈子里热议最多的话题就是在苹果电脑系统中发现了比特币的白皮书[1]。 话题的源头是4月5号一个叫Andy Baio的网友在waxy.org发…

本地推理,单机运行,MacM1芯片系统基于大语言模型C++版本LLaMA部署“本地版”的ChatGPT

OpenAI公司基于GPT模型的ChatGPT风光无两,眼看它起朱楼,眼看它宴宾客,FaceBook终于坐不住了,发布了同样基于LLM的人工智能大语言模型LLaMA,号称包含70亿、130亿、330亿和650亿这4种参数规模的模型,参数是指…

安装Windows和MacOS双系统 (UEFI + GPT) 和常用软件及配置,一篇文章解决所有

调节显示器自带扬声器音量用Loopback 镜像下载地址:https://mirrors.dtops.cc/iso/MacOS/daliansky_macos/ 黑苹果AppleALC声卡驱动: 通过windows系统查看,右键我的电脑——管理——设备管理器——右键设备属性——详细信息——属性中选择硬件id,查看第一行“值”,注意dev后…

Win11系统更新后网络速度变的很慢怎么办?

Win11系统更新后网络速度变的很慢怎么办?有用户将自己的电脑系统升级到了Win11之后,出现了一些问题。电脑在使用中出现了网络速度变慢的情况。而且其它的设备在连接网络后速度是正常的,那么这个问题要怎么解决?来看看以下的方法分…

为什么微软的网站访问速度都这么慢?

微软这家企业大家还是挺熟悉的,微软自己研发的Windows系统很多人都在使用,微软除了操作系统还自己研发了浏览器,但是国内的小伙伴在使用微软网站的时候访问速度都比较慢,这是什么原因呢? 微软的的有些服务器在国外有些…

实现简单登入注册功能(php表单)

1.环境部署&#xff08;数据库的建立&#xff09; 2.代码展示 <meta charset"utf-8" /> <form action"bd.php" method"GET"><center>账号&#xff1a;<input typetext name"uname"/><br />密码&#x…

帮管客CRM客户管理系统V2.5.4OA系统PHP源码,已去除域名授权无限制版

源码介绍 帮管客CRM客户管理系统基于先进的CRM营销理念设计&#xff0c;集客户档案、销售记录、业务往来于一身&#xff0c;以凝聚客户关系、提升资源价值为核心&#xff0c;将潜在客户变为现实客户、从而提升销售量、提高用户的满意度&#xff0c;并增加企业竞争力。帮管客CR…

无忧微店自动发货软件

很多时候大家需要用到微店自动发货功能来解放自己的时间&#xff0c;不用整天守在电脑旁边也能做生意。想想是多么惬意的事情啊!事情当然不是没有可能&#xff0c;简单几步教给大家如何实现微店自动发货&#xff0c;微店现在本身没有在做自动发货服务&#xff0c;需要虚拟自动发…