ChatGPT提示词工程(五):Transforming转换

news2025/2/27 9:25:00

目录

  • 一、说明
  • 二、安装环境
  • 三、转换(Transforming)
    • 1. 翻译 Translation
    • 2. 语气转换 Tone Transformation
    • 3. 格式转换 Format Conversion
    • 4. 拼写或语法检查 Spellcheck/Grammar check

一、说明

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

二、安装环境

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

三、转换(Transforming)

在本笔记本中,我们将探讨如何将大型语言模型用于文本转换任务,如语言翻译、拼写和语法检查、语气调整和格式转换等。

1. 翻译 Translation

prompt = f"""
Translate the following English text to Chinese: \ 
```Hi, I would like to order a blender```
"""
response = get_completion(prompt)
print(response)

prompt:把 “Hi, I would like to order a blender” 翻译成中文
运行结果:
在这里插入图片描述

prompt = f"""
Tell me which language this is: 
```Combien coûte le lampadaire?```
"""
response = get_completion(prompt)
print(response)

prompt:告诉我句子 “Combien coûte le lampadaire? ” 是什么语言
运行结果:
在这里插入图片描述

user_messages = [
  "La performance du système est plus lente que d'habitude.",  # System performance is slower than normal         
  "Mi monitor tiene píxeles que no se iluminan.",              # My monitor has pixels that are not lighting
  "Il mio mouse non funziona",                                 # My mouse is not working
  "Mój klawisz Ctrl jest zepsuty",                             # My keyboard has a broken control key
  "我的屏幕在闪烁"                                               # My screen is flashing
] 

for issue in user_messages:
    prompt = f"Tell me what language this is: ```{issue}```"
    lang = get_completion(prompt)
    print(f"Original message ({lang}): {issue}")

    prompt = f"""
    Translate the following  text to English \
    and Korean: ```{issue}```
    """
    response = get_completion(prompt)
    print(response, "\n")

prompt:告诉我这句话是什么语言,并把它翻译成英文和韩文
运行结果:
在这里插入图片描述

2. 语气转换 Tone Transformation

指定正式还是非正式的语气,指定语言使用的场合比如商务场合的邮件

prompt = f"""
Translate the following from slang to a business letter: 
'Dude, This is Joe, check out this spec on this standing lamp.'
"""
response = get_completion(prompt)
print(response)

prompt:将以下俚语翻译成商务信函
在这里插入图片描述

3. 格式转换 Format Conversion

data_json = { "resturant employees" :[ 
    {"name":"Shyam", "email":"shyamjaiswal@gmail.com"},
    {"name":"Bob", "email":"bob32@gmail.com"},
    {"name":"Jai", "email":"jai87@gmail.com"}
]}

prompt = f"""
Translate the following python dictionary from JSON to an HTML \
table with column headers and title: {data_json}
"""
response = get_completion(prompt)
print(response)

prompt:把JSON转换为HTML表格
运行结果:
在这里插入图片描述
结果展示:

from IPython.display import display, Markdown, Latex, HTML, JSON
display(HTML(response))

在这里插入图片描述

4. 拼写或语法检查 Spellcheck/Grammar check

text = [ 
  "The girl with the black and white puppies have a ball.",  # The girl has a ball.
  "Yolanda has her notebook.", # ok
  "Its going to be a long day. Does the car need it’s oil changed?",  # Homonyms
  "Their goes my freedom. There going to bring they’re suitcases.",  # Homonyms
  "Your going to need you’re notebook.",  # Homonyms
  "That medicine effects my ability to sleep. Have you heard of the butterfly affect?", # Homonyms
  "This phrase is to cherck chatGPT for speling abilitty"  # spelling
]
for t in text:
    prompt = f"""Proofread and correct the following text
    and rewrite the corrected version. If you don't find
    and errors, just say "No errors found". Don't use 
    any punctuation around the text:
    ```{t}```"""
    response = get_completion(prompt)
    print(response)

prompt:校对并改正下面的课文,改写改正后的版本,如果找不到错误,只需说"No errors found"。不要在正文周围使用任何标点符号。
运行结果:
在这里插入图片描述

text = f"""
Got this for my daughter for her birthday cuz she keeps taking \
mine from my room.  Yes, adults also like pandas too.  She takes \
it everywhere with her, and it's super soft and cute.  One of the \
ears is a bit lower than the other, and I don't think that was \
designed to be asymmetrical. It's a bit small for what I paid for it \
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 my daughter.
"""
prompt = f"proofread and correct this review: ```{text}```"
response = get_completion(prompt)
print(response)

prompt:校对并更正这篇评论
运行结果:
在这里插入图片描述
在原文上标注修改的部分

from redlines import Redlines

diff = Redlines(text,response)
display(Markdown(diff.output_markdown))

在这里插入图片描述

进一步改写:

prompt = f"""
proofread and correct this review. Make it more compelling. 
Ensure it follows APA style guide and targets an advanced reader. 
Output in markdown format.
Text: ```{text}```
"""
response = get_completion(prompt)
display(Markdown(response))

prompt:校对并更正这篇评论。让它更有说服力。确保它遵循APA风格指南,并针对高级读者。以markdown格式输出。
运行结果:
在这里插入图片描述

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



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

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

相关文章

kubernetes安全框架RBAC

目录 一、Kubernetes 安全概述 二、鉴权、授权和准入控制 2.1 鉴权(Authentication) 2.2 授权(Authorization) 2.3 准入控制 三、基于角色的权限访问控制: RBAC 四、案例:为指定用户授权访问不同命名空间权限 一、Kubernetes 安全概述 K8S安全控…

YOLOv5 txt标签转图像标签(多个标签)

Python YOLOv5 txt标签转图像标签(多个标签 txt的数据如图所示1.读原始图像以及对应的txt文件2.获得原始图像的大小3.生成一张大小相同,黑色背景的图片4.读取txt文件,循环的增加标签5.获得不规则图形(标签)6.完整代码7…

Linux运维:makefile

一.makefile 1.makefile介绍 Makefile 是一种用于自动化构建的文件,它描述了一个软件项目的编译规则和依赖关系,并提供了一些工具来自动执行这些规则。 Makefile 的主要作用如下: 自动化编译:通过 Makefile,可以定…

使用 nvcc 的时候出现“helper_cuda.h”: No such file or directory错误该怎么办(其他xxx.h也是同样的解决方法)

今天在命令行中使用nvcc的时候,出现了“helper_cuda.h”: No such file or directory错误。这个错误信息表示:在编译的时候,找不到helper_cuda.h头文件(其他xxx.h如果也找不到,那么下面的解释和解决方法也通用&#xf…

Java流式操作——Collectors工具类

文章目录 方法实践说明一、前提条件Person类Data类 二、操作maxBy:获取流中最大元素;minBy:获取流中最小元素joining:合并,将流中的元素,以字符串的形式拼接起来summingInt:把流中的元素映射成int类型的元素&#xff0…

springboot第14集:MyBatis-CRUD讲解

注意点:增、删、改操作需要提交事务! 为了规范操作,在SQL的配置文件中,我们尽量将Parameter参数和resultType都写上! 编写Mapper接口类 import com.da.pojo.User; import java.util.List; public interface UserMapper…

4.1 指令系统的发展与性能要求

学习目标: 指令系统的发展与性能要求的学习目标: 理解指令系统的发展历程,包括CISC、RISC、VLIW等架构的特点、优缺点以及应用领域;掌握指令系统的性能要求,包括指令集的多样性、可编程性、并行性、效率、可靠性等&a…

ChatGPT学习-如何向ChatGPT提问

​ 最近在学习chatGPT,怎么样的提问是一个好的提问。通过网上找资料肯定不是最好的方法,我想起一句话,“不识庐山真面目,只缘身在此山中”。最好的老师就是chatGPT! 下面先展示下提问成果,我通过xmind生成了思维导图 一…

为什么越来越多的企业选择云计算

目录 一、前言 二、云计算的基础概念 2.1 云计算的定义 2.2 云计算的发展历程 2.3 云计算的基本架构 三、 企业采用云计算的优势 四、 行业应用案例 五、未来发展与挑战 六、总结 随着数字化转型的加速,越来越多的企业开始选择云计算作为信息技术应用的基础…

Linux 用户管理与文件权限

Linux 是一个多用户系统,它允许多个用户同时登陆主机,并为他们分配不同的资源和工作环境进行使用。当然,不同的用户都有文件的私有需求,所以设置不同用户文件的权限管理十分重要。 01 用户与用户组 Linux 中一般将文件访问权限的…

【matplotlib】可视化解决方案——如何正确设置图例

概述 matplotlib 中的图例(Legend)可以帮助我们展示每个数据对应的名称,让图像阅读者更好的认识到图像的数据结构以及绘图者想表达的意思。matplotlib 可以为每一个可见绘图对象(Artist)添加图例,官方建议…

windows10系统如何实现telnet内网穿透

在windows10系统环境中,我们常用的内网穿透方案是远程桌面内网穿透技术方案,存在的弊端是它属于视窗类操作工具。网上很多教人开启windows10的telnet服务的帖子,凡是通过系统设置进入启用或关闭windows应用后勾选telnet客户端这种方式&#x…

ChatGPT实现服务器体验沙箱

服务器体验沙箱 IT 人员在学习一门新技术时,第一个入门门槛通常都是"如何在本地安装并成功运行"。因此,很多技术的官网都会通过沙箱技术,提供在线试用的 playground 或者按步模拟的 tour。让爱好者先在线尝试效果是否满足预期&…

如何评估现代处理器的性能——以ARM Cortex-A53为例

如何评估现代处理器的性能——以ARM Cortex-A53为例 1 有哪些通用评价指标? 现代处理器内核的性能可以从以下几个方面进行评估: 时钟速度(Clock Speed):它是CPU内部时钟发生器的频率,以赫兹(…

IDEA2022版教程下()

8.快捷键的使用 8.1 常用快捷键 见《 尚硅谷_宋红康_IntelliJ IDEA 常用快捷键一览表.md 》 8.2 查看快捷键 1、已知快捷键操作名,未知快捷键 2、已知快捷键,不知道对应的操作名 8.3 自定义快捷键 8.4 使用其它平台快捷键 苹果电脑或者是用惯Eclips…

改进YOLOv5: | 涨点神器 | 即插即用| ICLR 2022!Intel提出ODConv:即插即用的动态卷积

OMNI-DIMENSIONAL DYNAMIC CONVOLUTION ODConv实验核心代码ODConv代码yaml文件运行:论文链接: https://openreview.net/forum?id=DmpCfq6Mg39 本文介绍了一篇动态卷积的工作:ODConv,其通过并行策略采用多维注意力机制沿核空间的四个维度学习互补性注意力。作为一种“即插…

Java8流式操作——中间操作

文章目录 什么是中间操作?方法实践说明一、前提条件Person类Data类 二、操作filter:过滤distinct:去重(去除集合中重复的元素)sorted:排序①、sorted():无参构造②、sorted(Compartor compartor):有参构造 skip:跳过。从前往后数&…

【Python入门篇】Python开发环境的搭建——安装和配置PyCharm工具

作者简介: 辭七七,目前大一,正在学习C/C,Java,Python等 作者主页: 七七的个人主页 文章收录专栏: Python入门,本专栏主要内容为Python的基础语法,Python中的选择循环语句…

闲谈【Stable-Diffusion WEBUI】的插件:绘图过程动画输出

文章目录 (零)前言(一)过程动画输出(Steps Animation)(1.1)使用(1.2)成果 (零)前言 本篇主要提到WEBUI的过程动画输出插件&#xff0c…

Docker 持久化存储 Volumes

Docker 持久化存储 Volumes 简介如何选择 -v 和 --mount-v或--volume--mount 创建和管理卷启动带有卷的容器使用Docker Compose的卷使用卷启动服务使用只读卷备份、恢复或迁移数据卷备份卷 删除卷自动删除匿名卷删除所有未使用卷 简介 官方文档: https://docs.docker.com/stor…