ChatGPT Prompt Engineering开发指南:Inferring

  • 产品评论文本
    • 情感(正/负面)
    • 识别情绪类型
    • 识别愤怒
  • 从客户评论中提取产品和公司名称
  • 一次执行多个任务
  • 推断主题
    • 推断5个主题
    • 为某些主题制作新闻提醒
  • 内容来源:

在本教程中,学习从产品评论和新闻文章中推断出态度和主题。基本设定跟之前教程一致。

产品评论文本

lamp_review = """
Needed a nice lamp for my bedroom, and this one had \
additional storage and not too high of a price point. \
Got it fast.  The string to our 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.  I had a missing part, so I contacted their \
support and they very quickly got me the missing piece! \
Lumina seems to me to be a great company that cares \
about their customers and products!!
"""

情感(正/负面)

prompt = f"""
What is the sentiment of the following product review,
which is delimited with triple backticks?Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

The sentiment of the product review is positive.

简单点:

prompt = f"""
What is the sentiment of the following product review,
which is delimited with triple backticks?Give your answer as a single word, either "positive" \
or "negative".Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

positive

识别情绪类型

prompt = f"""
Identify a list of emotions that the writer of the \
following review is expressing. Include no more than \
five items in the list. Format your answer as a list of \
lower-case words separated by commas.Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

happy, satisfied, grateful, impressed, content

识别愤怒

prompt = f"""
Is the writer of the following review expressing anger?\
The review is delimited with triple backticks. \
Give your answer as either yes or no.Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

No

从客户评论中提取产品和公司名称

prompt = f"""
Identify the following items from the review text:
- Item purchased by reviewer
- Company that made the itemThe review is delimited with triple backticks. \
Format your response as a JSON object with \
"Item" and "Brand" as the keys.
If the information isn't present, use "unknown" \
as the value.
Make your response as short as possible.Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

{"Item": "lamp","Brand": "Lumina"
}

一次执行多个任务

prompt = f"""
Identify the following items from the review text:
- Sentiment (positive or negative)
- Is the reviewer expressing anger? (true or false)
- Item purchased by reviewer
- Company that made the itemThe review is delimited with triple backticks. \
Format your response as a JSON object with \
"Sentiment", "Anger", "Item" and "Brand" as the keys.
If the information isn't present, use "unknown" \
as the value.
Make your response as short as possible.
Format the Anger value as a boolean.Review text: '''{lamp_review}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

{"Sentiment": "positive","Anger": false,"Item": "lamp with additional storage","Brand": "Lumina"
}

推断主题

story = """
In a recent survey conducted by the government,
public sector employees were asked to rate their level
of satisfaction with the department they work at.
The results revealed that NASA was the most popular
department with a satisfaction rating of 95%.One NASA employee, John Smith, commented on the findings,
stating, "I'm not surprised that NASA came out on top.
It's a great place to work with amazing people and
incredible opportunities. I'm proud to be a part of
such an innovative organization."The results were also welcomed by NASA's management team,
with Director Tom Johnson stating, "We are thrilled to
hear that our employees are satisfied with their work at NASA.
We have a talented and dedicated team who work tirelessly
to achieve our goals, and it's fantastic to see that their
hard work is paying off."The survey also revealed that the
Social Security Administration had the lowest satisfaction
rating, with only 45% of employees indicating they were
satisfied with their job. The government has pledged to
address the concerns raised by employees in the survey and
work towards improving job satisfaction across all departments.
"""

推断5个主题

prompt = f"""
Determine five topics that are being discussed in the \
following text, which is delimited by triple backticks.Make each item one or two words long.Format your response as a list of items separated by commas.Text sample: '''{story}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

government survey, job satisfaction, NASA, Social Security Administration, employee concerns
response.split(sep=',')


定义topic_list:

topic_list = ["nasa", "local government", "engineering","employee satisfaction", "federal government"
]

为某些主题制作新闻提醒

prompt = f"""
Determine whether each item in the following list of \
topics is a topic in the text below, which
is delimited with triple backticks.Give your answer as list with 0 or 1 for each topic.\List of topics: {", ".join(topic_list)}Text sample: '''{story}'''
"""
response = get_completion(prompt)
print(response)

执行结果:

nasa: 1
local government: 0
engineering: 0
employee satisfaction: 1
federal government: 1


下一节:探索如何将大型语言模型用于文本转换任务,如语言翻译、拼写和语法检查、音调调整和格式转换。

内容来源:

  1. Deeplearning.AI : 《ChatGPT Prompt Engineering for Developers》

【Prompting】ChatGPT Prompt Engineering开发指南(4)相关推荐

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

    ChatGPT Prompt Engineering开发指南1 Prompting指南 设置 提示原则 策略1:使用分隔符清楚地指示输入的不同部分 策略2:要求结构化输出 策略3:让模型检查条件是否满 ...

  2. 【Prompting】ChatGPT Prompt Engineering开发指南(5)

    ChatGPT Prompt Engineering开发指南:Transforming 翻译 通用翻译器 音调转换 格式转换 拼写检查/语法检查 内容来源 在本教程中,我们将探讨如何使用大型语言模型来 ...

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

    ChatGPT Prompt Engineering开发指南2 从产品概况表生成营销产品描述 问题1:文本太长 问题2: 文本聚焦于错误的细节 问题3:描述需要一个尺寸表 加载Python库查看HTM ...

  4. 面向开发人员的 ChatGPT 提示词教程 - ChatGPT Prompt Engineering for Developers

    面向开发人员的 ChatGPT 提示词教程 - ChatGPT Prompt Engineering for Developers 1. 指南(原文: Guidelines) 1-1. 提示的指南(原 ...

  5. 吴恩达 OpenAI 的Prompt教程笔记 - ChatGPT Prompt Engineering for Developers

    文章目录 第一课 Introduction 第二课 Guidelines for Prompting 一.两个原则 1.编写明确和具体的指令 2.给模型足够的时间来思考 二.一个局限性 第三课 lte ...

  6. 吴恩达《ChatGPT Prompt Engineering for Developers》【自用】

    文章目录 Prompt Engineering for Developers 1 简介 2. 提示原则 Guidelines 将自己的 API-KEY 导入系统环境变量 导入第三方库 读取系统中的环境 ...

  7. 【简单入门】ChatGPT prompt engineering (中文版)笔记 |吴恩达ChatGPT 提示工程

    目录 思维导图 一.资料 二. 指南 环境配置 两个基本原则(最重要!!!!) 原则一:编写清晰.具体的指令 **策略一:使用分隔符清晰地表示输入的不同部分**,**分隔符可以是:```," ...

  8. ChatGPT Prompt Engineering for Developers from DeepLearning.AI

    链接:https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/1/introduction In this course, there are ...

  9. 《ChatGPT Prompt Engineering for Developers》课程-提示词原则

    编写 Prompt 的原则 本章的主要内容为编写 Prompt 的原则,在本章中,我们将给出两个编写 Prompt 的原则与一些相关的策略,你将练习基于这两个原则来编写有效的 Prompt,从而便捷而 ...

最新文章

  1. Java异常实战——OutOfMemoryError
  2. setsockopt()函数使用详解
  3. harbor 多端口_安装Harbor并修改默认使用的80端口
  4. 软件测试中qa的职责,软件测试 -- 测试人员和QA的区别
  5. 数据库持久化ORM框架Hibernate、JPA、Mybatis、JOOQ和JDBC Template的比较
  6. 解决服务器内存被pc微信占满,微信占内存的解决方案终于出现了
  7. Pyramidal Convolution: Rethinking Convolutional Neural Networks for Visual Recognition论文阅读翻译
  8. 打乱魔方软件_家里魔方吃灰了?这三款魔方App教你轻松上手
  9. 计算机mac地址怎么修改密码,如何修改苹果电脑mac地址?
  10. 计算机中的一些基本概念(速度,比特,门,电路图)
  11. Android 设置背景透明
  12. hadoop3访问hdfs web控制页面遇到的各种问题总结
  13. 台州农商行计算机专业能力测试,银行/农商行笔试!刷题要刷到点子上,来这里专业老师给你出题...
  14. DOS之父加里·基尔代尔
  15. php输入框里的提示文字,h5和css3制作带提示文字的输入框
  16. 9.Vue中mounted的简单理解
  17. 关于网络推广的一些心得体会
  18. pythonocc 切完显示要要.Shape()
  19. (转载)【笨木头Lua专栏】基础补充02:函数的几个特别之处
  20. r语言electricity数据集_R语言多元逐步回归模型分析房价和葡萄酒价格:选择最合适的预测变量...

热门文章

  1. PDF转TXT格式软件有什么?推荐这三款软件给你
  2. 天源财富:钠离子电池储能技术迈上新台阶
  3. 咋吃都不胖的朋友,Nature告诉你原因:是基因突变了
  4. 测评TFN FB21 智能电缆故障测试仪的性能
  5. C# XML 序列化 及 反序列化
  6. 文字特效-第12届蓝桥杯Scratch国赛真题第1题
  7. [导入][转]sap学习手册三
  8. 马走日(深度优先搜索)
  9. 塑胶模具运水如何设计,非常详细!!!
  10. Swiper插件的安装及使用