ChatGPT提示词工程(三):Summarizing概括总结

news2024/9/21 20:40:09

目录

  • 一、说明
  • 二、安装环境
  • 三、概括总结(Summarizing)
    • 1. 简单地概括总结,只有字数限制
    • 2. 概括总结需要关注的某些点
  • 四、用“提取”代替“总结”(Try "extract" instead of "summarize")
  • 五、概括总结多个产品评价(Summarize multiple product reviews)

一、说明

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

二、安装环境

参考: ChatGPT提示词工程(一):Guidelines准则 的第二节

三、概括总结(Summarizing)

1. 简单地概括总结,只有字数限制

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)

Prompt中任务是要求模型总结prod_review,要求30字以内,运行结果:
在这里插入图片描述

2. 概括总结需要关注的某些点

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)

代码中,要求模型关注商品的运输和交付方面,运行结果:
在这里插入图片描述

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)

代码中,要求模型关注商品的价格和价值,运行结果:
在这里插入图片描述
注意:模型给出的结果中,除了你所关注的方面,还会给出一些无关的内容,这需要在实际的运用中由你自己决定是否有用。
https://blog.csdn.net/Jay_Xio/article/details/130456580



四、用“提取”代替“总结”(Try “extract” instead of “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)

代码中,要求模型提取相关信息反馈给商品运输部门,模型给出的结果简单明了,只有商品提前一天到达的信息,结果如下:
在这里插入图片描述
https://blog.csdn.net/Jay_Xio/article/details/130456580



五、概括总结多个产品评价(Summarize multiple product reviews)

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")

代码中, 有四个产品评价,需要模型进行总结,代码运行模型分别给出了四个总结结果:

在这里插入图片描述

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

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

相关文章

Mysql第二章 多表查询的操作

这里写自定义目录标题 一 外连接与内连接的概念sql99语法实现 默认是内连接sql99语法实现左外连接,把没有部门的员工也查出来sql99语法实现右外连接,把没有人的部门查出来sql99语法实现满外连接,mysql不支持这样写mysql中如果要实现满外连接的…

生成对抗网络原理

GAN的原理 GAN是在2014年由Ian Goodfellow等人提出的,发表在论文“Generative Adversarial Networks”中。 GAN的主要灵感来源于博弈论中零和博弈的思想,应用到深度学习神经网络上来说,就是通过生成网络G(Generator)和…

系统架构设计

高性能 客户端内部缓存客户端到服务器之间缓存:CDN,网络专线数据库前加缓存Sessioin等信息共享NoSQL数据库分片,读写分离web层无关态集群负载均衡GeoDNS 就近原则,边缘计算存储异步,解耦,削峰:消息队列离线…

MySQL学习笔记第五天

第06章多表查询 多表查询概述: 多表查询,也称为关联查询,指两个或更多个表一起完成查询操作。前提条件:这些一起查询的表之间是有关系的(一对一、一对多),它们之间一定是有关联字段&#xff0…

第二十章 渲染管线

渲染管线是计算机图形中最基础最核心的部分,它是将3D场景显示到2D平面的技术过程。在DirectX课程中,我们就介绍了渲染管线,分为固定渲染管线和可编程渲染管线(Shader)。但是在DirectX 10版本之后统一了渲染架构&#x…

【Java】面试常问知识点(Java基础)

JVM java 栈:线程私有,生命周期和线程,每个方法在执行的同时都会创建一个 栈帧用于存储局部变量表,操作数栈,动态链接,方法出口等信息。方法的执行就对应着栈帧在虚拟机栈中入栈和出栈的过程;栈…

Photoshop如何使用蒙版之实例演示?

文章目录 0.引言1.给单调的天空添加蓝天白云2.清除头发边缘的杂色3.制作景深效果4.制作枯荣共存的树5.制作双重曝光肖像 0.引言 因科研等多场景需要进行绘图处理,笔者对PS进行了学习,本文通过《Photoshop2021入门教程》及其配套素材结合网上相关资料进行…

【Linux内核解析-linux-5.14.10-内核源码注释】内核启动kernel_init解释

源码 解释1 static int __ref kernel_init(void *unused): 声明一个静态整型函数kernel_init(),该函数不会被其他文件访问,使用__ref标记表示该函数是可重定位的,并且该函数不需要任何参数。 wait_for_completion(&kthreadd_done);: 等待…

FL Studio 2023中文高级版水果编曲软件下载

FL Studio 2023中文版是一款非常经典的音乐制作软件,这款软件除了可以为用户提供全面的音乐制作功能之外,还有丰富的主题和皮肤供用户选择,让用户不但做出的音乐具有自己的风格,连制作的音乐的过程也个性十足,非常适合…

荔枝派Zero(全志V3S)驱动开发之串口

系列文章目录 文章目录 系列文章目录前言一、修改及编译设备树1、修改设备树文件2、编译 kernel 二、移植 minicom1、配置buildroot2、编译 buildroot 三、拷贝到 SD 卡四、测试验证1、确认 minicom 是否正常2、确认串口3、发送测试4、接收测试 前言 修改设备树打开 uart1 和 …

14-4-进程间通信-共享内存

之前学习了无名管道,命名管道,消息队列。 还剩下:共享内存,信号,信号量。 本章讨论的是共享内存。 一、共享内存的应用场景 A进程有自己的存储空间; B进程也有自己的存储空间; A进程和B进…

使用物联网技术进行肥胖管理是可行的吗?

在物联网和可穿戴设备的帮助下,个人现在可以监测自己的健康指标,如心率、血糖水平和身体活动。这些个性化的见解帮助人们对自己的生活方式做出明智的决定,从而带来更好的体重管理结果。 利用物联网技术成功管理肥胖症 肥胖是一个全球性的健…

还在挣扎文件

由于在老式打印机里面每打下一行都要进行回车和换行,在windows系统里面也延续了这个惯例,但是c语言是只有换行,但是为了兼容,会自动进行转换;比如,它在写入文件的时候换行会自动转换为回车加换行&#xff0…

加强网络风险生命周期

当今业务环境中云原生应用程序的激增帮助组织简化了运营。 企业现在可以近乎实时地监控数据、与客户互动并分享见解,帮助他们克服曾经阻碍生产力的低效率问题。 然而,使用云也极大地扩展了企业可利用的攻击面。 CSPM、CWPP、CNAPP、SAST、SCA、IaC、D…

网络基础3【网络层、数据链路层】

目录 一.网络层 1.IP协议 (1)基本概念 (2)协议头格式 2.网段划分 3.特殊的IP地址 4.IP地址的数量限制 5.私有IP地址和公网IP地址 6.路由 二.数据链路层 1.以太网 2.以太网帧格式 3.MAC地址 4.对比MAC地址和IP地址 …

【图】邻接矩阵

图的存储结构分为邻接矩阵和邻接表两种,带权的图叫做网。 邻接矩阵 邻接矩阵适合边多的图 无向图 两个顶点之间的连线是双向的,一个一维数组存顶点,一个二维数组存边 若有边则值为1,反之为0 邻接矩阵需要知道点数、边数、一个二维…

ARM微处理器的指令集概述

ARM处理器是基于精简指令集计算机(RISC)原理设计的,指令集和相关译码机制较为简单。ARM微处理器的指令集是加载(Load)/存储(Store)型的,也即指令集仅能处理寄存器中的数据&#xff0…

【论文笔记】Attention和Visual Transformer

Attention和Visual Transformer Attention和Transformer为什么需要AttentionAttention机制Multi-head AttentionSelf Multi-head Attention,SMA TransformerVisual Transformer,ViT Attention和Transformer Attention机制在相当早的时间就已经被提出了&…

Word2vec原理+实战学习笔记(二)

来源:投稿 作者:阿克西 编辑:学姐 前篇:Word2vec原理实战学习笔记(一) 视频链接:https://ai.deepshare.net/detail/p_5ee62f90022ee_zFpnlHXA/6 5 对比模型(论文Model Architectur…