【Prompting】ChatGPT Prompt Engineering开发指南(3)

ChatGPT Prompt Engineering开发指南3

  • 总结文字
    • 使用单词/句子/字符限制进行总结
    • 以运输和交付为重点进行总结
    • 以价格和价值为重点进行总结
  • 尝试“extract”而不是“summarize”
  • 总结多个产品评论
  • 内容来源

本文承接上文:ChatGPT Prompt Engineering开发指南2,继续基于Deeplearning.AI的ChatGPT Prompt Engineering for Developers学习。在本教程中,将以特定主题的重点进行总结文本。

总结文字

prod_review = """
Got this panda plush toy for my daughter's birthday, \
who loves it and takes it everywhere. It's soft and \ 
super cute, and its face has a friendly look. It's \ 
a bit small for what I paid though. I think there \ 
might be other options that are bigger for the \ 
same price. It arrived a day earlier than expected, \ 
so I got to play with it myself before I gave it \ 
to her.
"""

使用单词/句子/字符限制进行总结

prompt = f"""
Your task is to generate a short summary of a product \
review from an ecommerce site. Summarize the review below, delimited by triple 
backticks, in at most 30 words. Review: ```{prod_review}```
"""response = get_completion(prompt)
print(response)

执行结果:

Soft and cute panda plush toy loved by daughter, but a bit small for the price. Arrived early.

以运输和交付为重点进行总结

prompt = f"""
Your task is to generate a short summary of a product \
review from an ecommerce site to give feedback to the \
Shipping deparmtment.Summarize the review below, delimited by triple
backticks, in at most 30 words, and focusing on any aspects \
that mention shipping and delivery of the product.Review: ```{prod_review}```
"""response = get_completion(prompt)
print(response)

执行结果:

The panda plush toy arrived a day earlier than expected, but the customer thinks it's a bit small for the price paid.

以价格和价值为重点进行总结

prompt = f"""
Your task is to generate a short summary of a product \
review from an ecommerce site to give feedback to the \
pricing deparmtment, responsible for determining the \
price of the product.  Summarize the review below, delimited by triple 
backticks, in at most 30 words, and focusing on any aspects \
that are relevant to the price and perceived value. Review: ```{prod_review}```
"""response = get_completion(prompt)
print(response)

执行结果:

Soft and cute panda plush toy, loved by daughter. However, a bit small for the price paid. Consider offering bigger options for the same price.

注意:摘要包括与重点主题无关的主题。

尝试“extract”而不是“summarize”

prompt = f"""
Your task is to extract relevant information from \ 
a product review from an ecommerce site to give \
feedback to the Shipping department. From the review below, delimited by triple quotes \
extract the information relevant to shipping and \ 
delivery. Limit to 30 words. Review: ```{prod_review}```
"""response = get_completion(prompt)
print(response)

执行结果:

The product arrived a day earlier than expected.

总结多个产品评论

review_1 = prod_review# review for a standing lamp
review_2 = """
Needed a nice lamp for my bedroom, and this one \
had additional storage and not too high of a price \
point. Got it fast - arrived in 2 days. The string \
to the lamp broke during the transit and the company \
happily sent over a new one. Came within a few days \
as well. It was easy to put together. Then I had a \
missing part, so I contacted their support and they \
very quickly got me the missing piece! Seems to me \
to be a great company that cares about their customers \
and products.
"""# review for an electric toothbrush
review_3 = """
My dental hygienist recommended an electric toothbrush, \
which is why I got this. The battery life seems to be \
pretty impressive so far. After initial charging and \
leaving the charger plugged in for the first week to \
condition the battery, I've unplugged the charger and \
been using it for twice daily brushing for the last \
3 weeks all on the same charge. But the toothbrush head \
is too small. I’ve seen baby toothbrushes bigger than \
this one. I wish the head was bigger with different \
length bristles to get between teeth better because \
this one doesn’t.  Overall if you can get this one \
around the $50 mark, it's a good deal. The manufactuer's \
replacements heads are pretty expensive, but you can \
get generic ones that're more reasonably priced. This \
toothbrush makes me feel like I've been to the dentist \
every day. My teeth feel sparkly clean!
"""# review for a blender
review_4 = """
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.
"""reviews = [review_1, review_2, review_3, review_4]

循环遍历代码:

for i in range(len(reviews)):prompt = f"""Your task is to generate a short summary of a product \review from an ecommerce site.Summarize the review below, delimited by triple \backticks in at most 20 words.Review: ```{reviews[i]}```"""response = get_completion(prompt)print(i, response, "\n")

执行结果
解决办法,增加重试次数:
安装tenacity包,然后给的自己的脚本,访问API那段函数,添加修饰:@retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))如下:

from tenacity import (retry,stop_after_attempt,wait_random_exponential,
)  # for exponential backoff@retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
def get_completion(prompt, model="gpt-3.5-turbo"):messages = [{'role': 'user', 'content': prompt}]response = openai.ChatCompletion.create(model=model,messages=messages,max_tokens=1024,n=1,temperature=0,  # this is the degree of randomness of the model's outputstop=None,top_p=1,frequency_penalty=0.0,presence_penalty=0.6,)return response['choices'][0]['message']['content']

这样的话,在访问之间会自动增加一定时间间隔,并在访问受拒之后,再次进行尝试。
重新执行上述代码,返回结果如下:
执行结果

内容来源

  1. DeepLearning.AI: 《ChatGPT Prompt Engineering for Developers》
  2. openai.error.RateLimitError: Rate limit reached for default-text-davinci-003 in organization

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

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

相关文章

巴比特 | 元宇宙每日必读:承认ChatGPT正损害公司业务增长,美国知名在线教育公司股价一日腰斩,带崩欧美教育股...

摘要:据华尔街见闻报道,近日,美国知名在线教育公司Chegg的首席执行官Dan Rosenweig在财报电话会议上承认,ChatGPT正在损害其业务增长:“自3月份以来,我们发现学生对ChatGPT的兴趣显著上升。我们现在认为&am…

马斯克离开OpenAI内幕:大权独揽想法被拒

Datawhale干货 选自:Semafor,编译:机器之心 作为创始投资人,马斯克为什么和 OpenAI「反目成仇」? 在 OpenAI 成立三年之后,埃隆・马斯克准备放弃他扶持创立的这家人工智能研究公司。 OpenAI 于 2015 年成立…

纽约大学教授建议:ChatGPT时代下,请躺平!

文|小戏 二月以来一波一波的 ChatGPT 和 GPT-4 刷屏,从围城外面来看整个 AI 社区确实一片勃勃生机万物竞发,CNN、纽约客又一次开始讨论人工智能危机,公众号里“ChGPT时代,我们该如何如何”的文章也轻松拿到十万&#x…

想要自己的专属 AI 猫娘助理?教你使用 CPU 本地安装部署运行 ChatGLM-6B实现

今天介绍的ChatGLM-6B 是一个清华开源的、支持中英双语的对话语言模型,基于GLM架构,具有62亿参数。关键的是结合模型量化技术,ChatGLM-6B可以本地安装部署运行在消费级的显卡上做模型的推理和训练(全量仅需14GB显存,INT4 量化级别下最低只需 6GB 显存)虽然智商比不过 ope…

Tomcat:127.0.0.1拒绝了我们的连接请求(half)

参考文章 //结束进程(没有成功) https://blog.csdn.net/m0_64476167/article/details/125801810修改端口号(可以解决) https://blog.csdn.net/qq_56240927/article/details/124111532?ops_request_misc&request_id&biz_id102&utm_term%E9%85%8D%E7%BD%AE%E5%A5…

Java面试之孔乙己拒止攻略(2)——MYSQL篇

一、前言 其实,我们做的大多数系统都是数据库应用系统,up主的大学专业也是这个。对于这部分知识,确实有掌握的必要。然而,实际上这部分知识并不困难,大部分知识点看一眼就会了。 本篇打算包括以下几个方面&#xff1a…

Rocky和ChatGPT谈笑风生的日子 |【AI行研商业价值分析】

Rocky Ding 公众号:WeThinkIn 写在前面 【AI行研&商业价值分析】栏目专注于分享AI行业中最新热点/风口的思考与判断。也欢迎大家提出宝贵的意见或优化ideas,一起交流学习💪 大家好,我是Rocky。 近日,ChatGPT风光无…

Github每日精选(第97期): 类似ChatGPT 的开源AI 聊天ChatRWKV

ChatRWKV 类似于 ChatGPT,但由 RWKV(100% RNN)语言模型提供支持,并且是开源的。 github地址 ChatRWKV 类似于 ChatGPT,但由我的 RWKV(100% RNN)语言模型提供支持,这是目前唯一可以在…

揭秘 ChatGPT 背后的技术栈:将Kubernetes扩展到2500个节点

揭秘 ChatGPT 背后的技术栈:将Kubernetes扩展到2500个节点 etcdKube mastersDocker image 推送NetworkingARP cache 在本文中,OpenAI 的工程师团队分享了他们在 Kubernetes 集群扩展过程中遇到的各种挑战和解决方案,以及他们取得的性能和效果…

半天就行!教你用ChatGPT开发小程序;谁能做出中国的Discord?LangChain中文入门教程;一个周末搞定电影预告片的AI工作流 | ShowMeAI日报

👀日报&周刊合集 | 🎡生产力工具与行业应用大全 | 🧡 点赞关注评论拜托啦! 🤖 『Discord和它的中国「学徒」们』为什么还没有人跑出来? ShowMeAI知识星球资料分类「下资料」,编号「R080」 D…

2023最新ChatGPT3.0小程序/云开发无需服务器开源Vue自带API接口

正文: ChatGPT3.0小程序,云开发无需服务器开源vue自带接口,界面的UI也是比较还原官方的了,就连颜色都是一摸一样的,有兴趣的自行去安装体验吧,其它就没什么好介绍的了。 程序: wwxgus.lanzoum.com/iLfKe0otvx5i 图片:

2023 首发 ChatGPTv3.0多端小程序开源源码 云开发无需服务器 带接口

云开发无需服务器开源vue自带接口! 全开源vue 自带接口 上传即可使用! 无需服务器 后续会更新流量主版本! 。。。。

2023最新VUE开发的ChatGPT3.5全开源小程序源码+功能强大/UI也不错

正文: 所需环境 uniapp nodejs 搭建教学 首先前端源码下载下来,用idea源码编辑器打开,只需要修改配置文件中的请求api(request/request.js),需要搭建好后端请求 1.服务器配置 centos7.9 2.宝塔面板安装宝塔 3.如果在线下载…

获取了文心一言的内测及与其ChatGPT、GPT-4 对比结果

百度在3月16日召开了关于文心一言(知识增强大语言模型)的发布会,但是会上并没现场展示demo。如果要测试的文心一言 也要获取邀请码,才能进行测试的。 我这边通过预约得到了邀请码,大概是在3月17日晚就收到了&#xff…

搭建人工智能wx机器人完整版教程

参考搭建流程 首先需要下载Ubuntu 20.04 镜像包 阿里云开源镜像包 下载方式: 打开以上网站-->点击20.04/-->点击ubuntu-20.04.5-live-server-amd64.iso下载 项目开源地址 https://github.com/zhayujie/chatgpt-on-wechat NxShell下载地址 https://xiaodao.lan…

【微信小程序】微信小程序的接口调入 获取太阳码 根据返回值的类型进行接收,微信接口可能直接返回图片,也可能返回一个错误信息的json,同时兼容处理这两种情况

目录 事件起因环境和工具操作过程解决办法遇到的一点问题结束语 事件起因 在开发一个关于微信小程序的过程中,有一个这样的需求,要求生成微信小程序的太阳码,然而这个东西的请求方式我们是这样的:我作为后端服务去请求这个太阳码…

如何设计开放平台接口与集成chatgpt

如何设计开放平台接口与集成chatgpt 文章目录 如何设计开放平台接口与集成chatgpt前言一、Token机制生成方式有哪些session存在的问题JWT如何解决session存在的问题 二、AppId、AppSecretAppId机制签名机制 三 码上实现客户端注意 源码地址配置 前言 前一段时间,突…

ChatGPT研究(二)——ChatGPT助力跨模态AI生成应用

✏️写作:个人博客,InfoQ,掘金,知乎,CSDN 📧公众号:进击的Matrix 🚫特别声明:创作不易,未经授权不得转载或抄袭,如需转载可联系小编授权。 前言 …

《花雕学AI》12:从ChatGPT的出现看人类与人工智能的互补关系与未来发展

马云说道,ChatGPT这一类技术已经对教育带来挑战,但是ChatGPT这一类技术只是AI时代的开始。 谷歌CEO桑德尔皮猜曾说:“人工智能是我们人类正在从事的最为深刻的研究方向之一,甚至要比火与电还更加深刻。” 360周鸿祎认为&#xf…

论文谷歌翻译:SinGAN(代码开源)

论文地址:https://arxiv.org/abs/1905.01164 代码地址:http://webee.technion.ac.il/people/tomermic/SinGAN/SinGAN.htm 摘要 提出了 SinGAN,这是一个可以从单张自然图像学习的非条件性生成式模型。模型可以捕捉给定图像中各个小块内的内在…