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

news2024/7/4 4:29:02

目录

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

一、说明

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

二、安装环境

参考: 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 class
    messages = [{"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.coloradmin.cn/o/482193.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

linux编写脚本之快速入门

前言 在进行Linux测试时编写脚本是必不可少的。最近经常使用Linux,感觉太频繁地敲击键盘有些累了,于是想到了Shell脚本。可以把太多的命令写成一个脚本,这样每次执行一遍 shell文件,就可以省去了敲击键盘的时间。于是在网上搜了一…

3.7 虚拟存储器

学习目标: 建议按照以下学习目标进行学习: 了解虚拟存储器的基本概念和原理。包括什么是虚拟存储器、虚拟地址和物理地址、虚拟内存、页面置换算法等。 了解虚拟存储器的实现方式。包括基于请求分页、请求分段和请求段页混合的虚拟存储器实现方式&…

前置操作:Kubernetes快速安装组件Kubectl Kubeadam Kubeinit

文章目录 配置K8S主从集群前置准备操作一:主节点操作 查看主机域名->编辑域名1.1 编辑HOST 从节点也做相应操作1.2 从节点操作 查看从节点102域名->编辑域名1.3 从节点操作 查看从节点103域名->编辑域名 二:安装自动填充,虚拟机默认…

对接ChatGPT开发对话机器人小程序

前言 ChatGPT已经非常火爆了,企业开始招聘ChatGPT工程师,可能对接ChatGPT接口进行企业级开发是程序员必备的技能了。本篇文章主要是基于ChatGPT开发接口进行对接,使用微信小程序制作一款自己的聊天机器人,通过这一案例你可以展开…

图神经网络:在KarateClub上动手实现图神经网络

文章说明: 1)参考资料:PYG官方文档。超链。 2)博主水平不高,如有错误还望批评指正。 3)我在百度网盘上传了这篇文章的jupyter notebook。超链。提取码8888。 文章目录 文献阅读:代码实操: 文献阅读: 参考文…

JavaWeb05(删除增加修改功能实现连接数据库)

目录 一.实现删除功能 1.1 url如何传参? xx.do?参数参数值&参数名参数值 1.2 servlet如何拿对应值? //根据参数名拿到对应的参数值 String str req.getParameter("参数名") 1.3 如何询问? οnclick"return con…

区位码-GB2312

01-09区为特殊符号 10-15区为用户自定义符号区(未编码) 16-55区为一级汉字,按拼音排序 56-87区为二级汉字,按部首/笔画排序 88-94区为用户自定义汉字区(未编码) 特殊符号 区号:01 各类符号 0 1 2 3 4 …

I/O多路转接——epoll服务器代码编写

目录 一、poll​ 二、epoll 1.epoll 2.epoll的函数接口 ①epoll_create ②epoll_ctl ③epoll_wait 3.操作原理 三、epoll服务器编写 1.日志打印 2.TCP服务器 3.Epoll ①雏形 ②InitEpollServer 与 RunServer ③HandlerEvent 四、Epoll的工作模式 1.LT模式与ET…

第二十一章 光源

光源是每个场景必不可少的部分,光源除了能够照亮场景之外,还可以产生阴影效果。 Unity中分为四种光源类型: 1. 方向光:Directional Light 用于模拟太阳光,方向光任何地方都能照射到。 2. 点光源:Point L…

JavaWeb-Servlet【内含思维导图】

目录 Servlet思维导图​编辑 1.什么是Servlet 2.Servelt概述 3.Servlet-Quickstart Your Project 3.1创建一个Web项目,导入Servlet依赖 3.1.1 选择Servlet导入依赖 3.1.2 导入Servlet依赖 3.2 在Web项目,定义类,实现Servlet接口…

Java8新特性-流式操作

在Java8中提供了新特性—流式操作,通过流式操作可以帮助我们对数据更快速的进行一些过滤、排序、去重、最大、最小等等操作并且内置了并行流将流划分成多个线程进行并行执行,提供更高效、快速的执行能力。接下来我们一起看看Java8为我们新增了哪些便捷呢…

Python基础合集 练习19(类与对象3(多态))

多态 class Horse: def init(self, name) -> None: self.name name def fature(self):return 父亲-----马的名字: {0}.format(self.name)def mover(self):print(马儿跑起来很潇洒)class Monkey: def init(self, name) -> None: self.name name def fature(self):ret…

《用于准确连续非侵入性血压监测的心跳内生物标志物》阅读笔记

目录 0 基础知识 1 论文摘要 2 论文十问 3 实验结果 4 论文亮点与不足之处 5 与其他研究的比较 6 实际应用与影响 7 个人思考与启示 参考文献 0 基础知识 非侵入性是指在进行医学检查或治疗时,不需要切开皮肤或穿刺体内组织,而是通过外部手段进…

【VQGAN论文精读】Taming Transformers for High-Resolution Image Synthesis

【VQGAN论文精读】Taming Transformers for High-Resolution Image Synthesis 0、前言Abstract1. Introduction2. Related Work3. Approach3.1. Learning an Effective Codebook of Image Constituents for Use in Transformers学习一个有效的图像成分的Codebook为了在Transfor…

高性能:负载均衡

目录 什么是负载均衡 负载均衡分类 服务端负载均衡 服务端负载均衡——软硬件分类 服务端负载均衡——OSI模型分类 客户端负载均衡 负载均衡常见算法 七层负载均衡做法 DNS解析 反向代理 什么是负载均衡 将用户请求分摊(分流) 到不同的服务器上…

小记Java调用C++开发的动态链接库(DLL)

一、背景 五一快乐吖!死肥宅正趁着五一这段时间,努力提升自己! 最近使用Java拦截Windows系统中一些默认事件时,发现了一些瓶颈。 我用Java操作浏览器、用Java最小化其他应用窗口,但是我发现这个操作,他都…

【Unity-UGUI控件全面解析】| InputField 输入框组件详解

🎬【Unity-UGUI控件全面解析】| InputField 输入框组件详解一、组件介绍二、组件属性面板2.1 Content Type(内容类型)三、代码操作组件四、组件常用方法示例4.1 代码限制输入字符4.2 校验文本输入格式4.3 校验输入文本长度💯总结🎬 博客主页:https://xiaoy.blog.csdn.…

话说【永恒之塔sf】里面最有前途的职业:商人

如果有人问我永恒之塔里面什么职业最有前途!那我告诉你就是商人! 做一个NB商人比拥有一身牛b装备要更有成就感。 在老区由于进入的比较晚,所以最后随了大流被淹死在千万基纳中。为了证明商人在永恒之塔是钱途无量的,我转到了新区—…

快解析动态域名解析,实现外网访问内网数据库

今天跟大家分享一下如何借助快解析动态域名解析,在两种特定网络环境下,实现外网访问内网mysql数据库。 第1种网络环境:路由器分配的是动态公网IP,且有路由器登录管理权限。如何实现外网访问内网mysql数据库? 针对这种…

IDEA2022版教程上()

0、前景摘要 0.1 概览 0.2 套课程适用人群 初学Java语言,熟悉了记事本、EditPlus、NotePad或Sublime Text3等简易开发工具的Java初学者熟练使用其他Java集成开发环境(IDE),需要转向IDEA工具的Java工程师们关注IDEA各方面特性的J…