ChatGPT Prompt Engineering开发指南:Transforming

  • 翻译
  • 通用翻译器
  • 音调转换
  • 格式转换
  • 拼写检查/语法检查
  • 内容来源

在本教程中,我们将探讨如何使用大型语言模型来进行文本转换任务,例如语言翻译,拼写和语法检查,音调调整和格式转换。
注意:环境设置跟前面文章一致,这里不再提及。

翻译

ChatGPT使用多种语言的源代码进行训练。这使模型能够进行翻译。以下是一些如何使用此功能的示例。

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

执行结果:

Hola, me gustaría ordenar una licuadora.

另外三个案例:

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

执行结果:

This is French.
prompt = f"""
Translate the following  text to French and Spanish
and English pirate: \
```I want to order a basketball```
"""
response = get_completion(prompt)
print(response)

执行结果:

French pirate: ```Je veux commander un ballon de basket```
Spanish pirate: ```Quiero pedir una pelota de baloncesto```
English pirate: ```I want to order a basketball```
prompt = f"""
Translate the following text to Spanish in both the \
formal and informal forms:
'Would you like to order a pillow?'
"""
response = get_completion(prompt)
print(response)

执行结果:

Formal: ¿Le gustaría ordenar una almohada?
Informal: ¿Te gustaría ordenar una almohada?

通用翻译器

想象一下,您负责大型跨国电子商务公司。用户在其所有母语中都向您发送IT问题。您的员工来自世界各地,只会说他们的母语。您需要一个通用翻译器!

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

音调转换

写作可以根据预期受众的不同而有所不同。ChatGPT可以产生不同的音调。

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)

格式转换

ChatGPT可以在不同格式之间进行转换。提示应该描述输入和输出格式。

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)
<table><caption>Restaurant Employees</caption><thead><tr><th>Name</th><th>Email</th></tr></thead><tbody><tr><td>Shyam</td><td>shyamjaiswal@gmail.com</td></tr><tr><td>Bob</td><td>bob32@gmail.com</td></tr><tr><td>Jai</td><td>jai87@gmail.com</td></tr></tbody>
</table>

显示HTML:

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

拼写检查/语法检查

以下是一些常见语法和拼写问题的例子以及LLM的回应。

为了向LLM发出信号,表示您希望它校对您的文本,您指示模型“proofread”或“proofread and correct”。

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 textand rewrite the corrected version. If you don't findand errors, just say "No errors found". Don't useany punctuation around the text:```{t}```"""response = get_completion(prompt)print(response)

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)

执行结果:

批改模式:

from redlines import Redlinesdiff = Redlines(text,response)
display(Markdown(diff.output_markdown))


补充:Redlines生成一个Markdown文本,显示两个字符串/文本之间的差异。这些更改用删除线和下划线表示,看起来类似于Microsoft Word的跟踪更改。这种显示变化的方法对律师来说更为熟悉,对长系列的角色来说更为紧凑。
pip install redlines

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

执行结果:

内容来源

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

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

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

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

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

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

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

    ChatGPT Prompt Engineering开发指南:Inferring 产品评论文本 情感(正/负面) 识别情绪类型 识别愤怒 从客户评论中提取产品和公司名称 一次执行多个任务 推断主题 推 ...

  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. rsync+inotify实时备份
  2. java 支付宝h5网页支付接口,移动端h5网页调用支付宝支付接口
  3. 解决Win8下使用net use命令磁盘映射无效的问题
  4. SpringBoot+Shiro学习(八):RememberMe
  5. 关于$'\r': command not found错误的一点体会
  6. php 逗号 分割字符串
  7. redhat linux 9.0 拷贝u盘的文件,肿么用U盘安装Linux,安装的是red hat 9.0…用Ubuntu很方便,redhat可以吗?...
  8. iOS仿支付宝芝麻信用仪表盘效果
  9. 坚果Pro 3发布,罗永浩大赞科大讯飞:不成器国产厂商尽早跟讯飞合作
  10. 2013 Multi-University Training Contest 4
  11. Eclipse-习惯设置/快捷键/插件
  12. 微软7月修复117个漏洞,其中9个为0day,2个是Pwn2Own 漏洞
  13. java 显示数据库_java连接数据库并显示数据
  14. html小游戏社区,h5小游戏源码(h5养成社区源码)
  15. 大学生性价比计算机推荐,2018大学生笔记本推荐_良心笔记本推荐【性价比之王】-太平洋电脑网...
  16. Java电阻计算器(二)
  17. 宝塔Linux面板如何进入,云服务器怎么进入宝塔面板
  18. 收到谷歌实习邀请 “比被清华录取还激动”
  19. T229470 A. 小智的疑惑(暴力)
  20. Linux:更新 /usr/share/glib-2.0/schemas 目录

热门文章

  1. 新笔记本无法激活Office解决办法
  2. 计算机系统要素-从零开始构建现代计算机--第一章,01-用与非门实现与戓非
  3. Camtasia 2019 注册信息配置
  4. ROHM | 开发出以1220尺寸达到1W业界超高额定功率的分流电阻器“LTR10L”
  5. 渗透常用工具-Goby
  6. The Path to Learning WR Python FPE.5
  7. Ubuntu子系统下载源配置
  8. 字符串比较的原理是什么?
  9. 20220213协整
  10. Elasticsearch入门简介