吴恩达 Chatgpt prompt 工程--5.Transforming

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

Setup

import openai
import osfrom dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv()) # read local .env fileopenai.api_key  = os.getenv('OPENAI_API_KEY')
def get_completion(prompt, model="gpt-3.5-turbo", temperature=0): messages = [{"role": "user", "content": prompt}]response = openai.ChatCompletion.create(model=model,messages=messages,temperature=temperature, )return response.choices[0].message["content"]
翻译

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)

在这里插入图片描述

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?
通用翻译器
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")
Original message (This is French.): La performance du système est plus lente que d'habitude.
English: The system performance is slower than usual.
Korean: 시스템 성능이 평소보다 느립니다. Original message (This is Spanish.): Mi monitor tiene píxeles que no se iluminan.
English: My monitor has pixels that don't light up.
Korean: 내 모니터에는 불이 켜지지 않는 픽셀이 있습니다. Original message (This is Italian.): Il mio mouse non funziona
English: My mouse is not working.
Korean: 내 마우스가 작동하지 않습니다. Original message (This is Polish.): Mój klawisz Ctrl jest zepsuty
English: My Ctrl key is broken.
Korean: 제 Ctrl 키가 고장 났어요. Original message (This is Chinese (Simplified).): 我的屏幕在闪烁
English: My screen is flickering.
Korean: 내 화면이 깜빡입니다. 
音调变换(Tone Transformation)

写作可以根据预期受众的不同而有所不同。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)
Dear Sir/Madam,I am writing to bring to your attention a standing lamp that I believe may be of interest to you. Please find attached the specifications for your review.Thank you for your time and consideration.Sincerely,Joe
格式转换

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>
from IPython.display import display, Markdown, Latex, HTML, JSON
display(HTML(response))

在这里插入图片描述

拼写检查/语法检查

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

为了向LLM发出信号,表示你希望它校对你的文本,你指示模型“校对”或“校对并更正”。

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 use any punctuation around the text:```{t}```"""response = get_completion(prompt)print(response)
The girl with the black and white puppies has a ball.
No errors found.
It's going to be a long day. Does the car need its oil changed?
Their goes my freedom. There going to bring they're suitcases.Corrected version: 
There goes my freedom. They're going to bring their suitcases.
You're going to need your notebook.
That medicine affects my ability to sleep. Have you heard of the butterfly effect?
This phrase is to check ChatGPT for spelling ability.
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)
I got this for my daughter's birthday because 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. However, one of the ears is a bit lower than the other, and I don't think that was designed to be asymmetrical. Additionally, it's a bit small for what I paid for it. I think there might be other options that are bigger for the same price. On the positive side, it arrived a day earlier than expected, so I got to play with it myself before I gave it to my daughter.
from redlines import Redlinesdiff = 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))
Title: A Soft and Cute Panda Plush Toy for All AgesIntroduction: As a parent, finding the perfect gift for your child's birthday can be a daunting task. However, I stumbled upon a soft and cute panda plush toy that not only made my daughter happy but also brought joy to me as an adult. In this review, I will share my experience with this product and provide an honest assessment of its features.Product Description: The panda plush toy is made of high-quality materials that make it super soft and cuddly. Its cute design is perfect for children and adults alike, making it a versatile gift option. The toy is small enough to carry around, making it an ideal companion for your child on their adventures.Pros: The panda plush toy is incredibly soft and cute, making it an excellent gift for children and adults. Its small size makes it easy to carry around, and its design is perfect for snuggling. The toy arrived a day earlier than expected, which was a pleasant surprise.Cons: One of the ears is a bit lower than the other, which makes the toy asymmetrical. Additionally, the toy is a bit small for its price, and there might be other options that are bigger for the same price.Conclusion: Overall, the panda plush toy is an excellent gift option for children and adults who love cute and cuddly toys. Despite its small size and asymmetrical design, the toy's softness and cuteness make up for its shortcomings. If you're looking for a versatile gift option that will bring joy to your child and yourself, this panda plush toy is an excellent choice.

bad-grammar-examples

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

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

相关文章

吴恩达 Chatgpt prompt 工程--2.Iterative-prompt

迭代分析和完善prompts&#xff0c;以从产品概况表中生成营销副本。 Setup import openai import osfrom dotenv import load_dotenv, find_dotenv _ load_dotenv(find_dotenv()) # read local .env fileopenai.api_key os.getenv(OPENAI_API_KEY)def get_completion(prom…

吴恩达 ChatGPT Prompt Engineering for Developers 系列课程笔记--07 Expanding

07 Expanding 本节示例如何用ChatGPT生成一封电子邮件的回复。 1) 定制化情绪 给定客户评论&#xff0c;我们根据评论内容和情绪产生定制的回复。下面是给定情感&#xff08;positive/negative&#xff09;&#xff0c;让ChatGPT产生相应回复的prompt。 """…

吴恩达ChatGPT课爆火:AI放弃了倒写单词,但理解了整个世界

明敏 杨净 发自 凹非寺量子位 | 公众号 QbitAI 没想到时至今日&#xff0c;ChatGPT竟还会犯低级错误&#xff1f; 吴恩达大神最新开课就指出来了&#xff1a; ChatGPT不会反转单词&#xff01; 比如让它反转下lollipop这个词&#xff0c;输出是pilollol&#xff0c;完全混乱。 …

吴恩达ChatGPT《LangChain for LLM Application Development》笔记

基于 LangChain 的 LLM 应用开发 1. 介绍 现在&#xff0c;使用 Prompt 可以快速开发一个应用程序&#xff0c;但是一个应用程序可能需要多次写Prompt&#xff0c;并对 LLM 的输出结果进行解析。因此&#xff0c;需要编写很多胶水代码。 Harrison Chase 创建的 LangChain 框…

国际海运出口的操作流程是怎样的?

国际海运运输因为方便快捷以及运费低等特点&#xff0c;一直以来是大多数外贸企业出口货物物流运输的首选&#xff0c;然而新进入外贸行业的朋友们&#xff0c;对于海运出口流程还不是很了解&#xff0c;今天箱讯小编就为大家来介绍下。 海运出口操作流程如下&#xff1a; 1、…

用Python赚钱的方法有哪些?

很多人想知道用Python赚钱的方法有哪些&#xff1f;Python很容易使用&#xff0c;应用性较强。可以通过使用Python开发小程序、抓取数据、游戏开发、兼职编程老师&#xff0c;发展副业的方式来赚钱。 用Python赚钱的方法&#xff1a; 1、某宝搜python程序      可以到某宝…

学python可以做什么兼职-Python兼职收入过万?用Python做项目真的这么赚钱吗?

今天给大家分享一下2位前辈业余接兼职做的一些Python项目。我在这里想说&#xff0c;无论你是自学还是进培训班&#xff0c;只要把Python学好&#xff0c;钱自然而来。 问&#xff1a;请问用Python可以接哪些兼职的活赚钱? 1兼职费用足够学费生活费 恰巧上学期间接过一些外…

Midjourney指令操作、promt框架、参数设置教程

引言&#xff1a;基于Chatgpt的应用如雨后春笋&#xff0c;这波浪潮正当时。最近在摸索图片生成有价值的应用场景&#xff0c;使用过程中整理了一些指令秘籍&#xff0c;一同分享出来。 1、原理 Midjourney的人工智能绘画技术基于GPT-3.5模型&#xff0c;使用了先进的神经网络…

Python 如何赚钱?学会我交给你的Python赚钱大法,就算是大学生,月入1W外快不在话下。

现在学python的人越来越多了&#xff0c;都说学python赚的钱多&#xff0c;那么问题来了&#xff0c;就是我学完Python赚不到钱怎么办? 或者说找不到Python赚外快的平台或方式&#xff0c;今天小编我分享我的Python赚钱大法&#xff0c;学完月入1W外快不在话下&#xff01; …

实现财务自由 之 A 股上市公司的年报(年度财报)查阅查看、下载地址、以及下载的方法

实现财务自由 之 A 股上市公司的年报&#xff08;年度财报&#xff09;查阅查看、下载地址、以及下载的方法 目录 实现财务自由 之 A 股上市公司的年报&#xff08;年度财报&#xff09;查阅查看、下载地址、以及下载的方法 A 股上市公司年报&#xff0c;下载具体方法 1、打…

在 AI 上训练 AI:ChatGPT 上训练另一种机器学习模型

ChatGPT 可以像 Linux 终端一样运行&#xff0c;并在给出以下提示时返回执行结果。下面我来带大家操作起来。 文章目录 终端操作训练机器学习模型镜像演示 终端操作 输入&#xff1a;I want you to act as a Linux terminal. I will type commands and you will reply with wh…

【免费分享】chatgpt打造属于自己的AI口语私教,保姆级教程

随着人工智能技术的不断发展&#xff0c;AI口语学习已经成为了一种趋势。而如何打造一款自己的AI口语私教工具呢&#xff1f;本文将为大家介绍利用chatgpt api、百度翻译、腾讯智聆api、百度语音等技术&#xff0c;打造一款AI口语私教工具的步骤。 一、利用到的技术 1、chatg…

一分钟教会你ai文本工具如何使用

今天我要给大家推荐一些ai文本生成器&#xff01;你知道吗&#xff0c;ai文本生成器是一个超厉害的东西&#xff0c;它可以帮助我们创作出令人惊叹的文章、故事和甚至是诗歌。不管你是一名作家、学生还是只是想要表达自己的创意&#xff0c;这些工具都会是你的绝佳助手&#xf…

巴比特 | 元宇宙每日必读:多个大模型官宣,马斯克、姚期智、杨立昆等共话AIGC,世界人工智能大会有哪些看点?...

摘要&#xff1a;据钛媒体报道&#xff0c;7月6日&#xff0c;2023世界人工智能大会&#xff08;WAIC&#xff09;在上海世博中心正式拉开帷幕。特斯拉CEO埃隆马斯克&#xff08;Elon Musk&#xff09;&#xff0c;华为轮值董事长胡厚崑&#xff0c;微软全球资深副总裁、微软大…

对话算想未来创始人赵亚雄:希望做“为中国 AI 经济而生的 AWS”

本文约9000字&#xff0c;建议阅读10分钟“全球最聪明的人都在大模型创业&#xff0c;没人会禁受得住它的诱惑。” ChatGPT爆火&#xff0c;引得全世界为之疯狂&#xff0c;恍惚中一夜之间&#xff0c;人人都在讨论ChatGPT&#xff0c;所有大佬和资本纷纷涌进大模型。 上一次如…

真有意思,AI高引论文排行榜:OpenAI和DeepMind未进前十,旷视排第二?

文&#xff5c;丰色 发自 凹非寺源&#xff5c;量子位 哪些机构或国家&#xff08;地区&#xff09;发表的AI研究是最具影响力的&#xff1f; 为了弄清这个问题&#xff0c;美国Zeta Alpha平台统计了2020-2022三年之间全世界引用次数前100的AI论文&#xff0c;得出了一些很有意…

【SaaS播客】onboard20. 生成式AI AIGC:硅谷AI大牛、投资人、创业者眼里的机会与挑战

近期IT领域最火热的话题就是AIGC了&#xff0c;可以说是真正出圈了&#xff0c;这个词貌似是百度大力推广的&#xff1b;国际上用得更多的是Generative生成式AI。最近的热点是“真”智能聊天的产品chatGPT。我认为对上层产品而言最关键的是这2个里程碑: 20年中OpenAI推出GPT-3…

新华三眼中的AI天路

ChatGPT的火爆&#xff0c;在全球范围内掀起了新一轮的AI风暴。如今&#xff0c;各行各业都在讨论AI&#xff0c;各个国家都在密集进行新一轮的AI基础设施建设与技术投入。 但眼前的盛景并非突然到来&#xff0c;就拿这一轮大模型热潮来说&#xff0c;谷歌早在2018年底就发布了…

南京标志设计-logo设计(品牌形象核心部分)

标志设计&#xff0c;是表明事物特征的记号——它以单纯、显著、易识别的物象、图形或文字符号为直观语言&#xff0c;除标示什么、代替什么之外&#xff0c;还具有表达意义、情感和指令行动等作用。标志&#xff0c;作为人类直观联系的特殊方式&#xff0c;不但在社会活动与生…

Logo设计

Inkscape设计Logo 我根据自己名字的缩写&#xff08;XY&#xff09;设计了一个LOGO 1、添加文本 &#xff08;1&#xff09;单击左边工具“A“&#xff0c;在图纸上添加文本框&#xff0c;键盘输入“X”&#xff0c;在上方菜单栏调整自己想要的文本字体和大小&#xff08;字…