OpenAI官方提示词课(五)如何进行文本翻译校正修改

news2024/11/26 22:28:23

在本篇文章中,我们将探讨如何使用大语言模型进行文本转换任务,例如语言翻译、拼写和语法检查、语气调整和格式转换。

翻译

ChatGPT接受多种语言的训练,使得模型具备翻译能力。以下是如何使用这种能力的一些示例。

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

回答:

你好,我想订购一个搅拌机。

识别句子使用了何种语言。

prompt = f"""
Tell me which language this is: 
​```你好,我叫首飞```
"""
response = get_completion(prompt)
print(response)

回答:

This is Chinese (Mandarin).

这里演示了同时将一句话转换为多种语言。

prompt = f"""
Translate the following  text to Chinese and Japanese
and Korean: \
​```I want to order a basketball```
"""
response = get_completion(prompt)
print(response)

回答:

Chinese: 我想订购一个篮球 (Wǒ xiǎng dìnggòu yīgè lánqiú)
Japanese: バスケットボールを注文したいです (Basuketto bōru o chūmon shitai desu)
Korean: 저는 농구공을 주문하고 싶어요 (Jeoneun nonggugong-eul jumunhago sip-eoyo)

下面的例子演示,大模型改变句子的语气,是正式还是不正式?

prompt = f"""
Translate the following text to Chinese in both the \
formal and informal forms: 
'Would you like to order a pillow?'
"""
response = get_completion(prompt)
print(response)

回答:

Formal: 您需要订购枕头吗?
Informal: 你想订购枕头吗?

语气转换

写作可以根据预期受众而有所不同。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的回应。

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)

回答:

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

注意,APA style是一种用于学术写作和出版的规范和指南,它由美国心理学会(American Psychological Association)制定和发布。APA style提供了一套标准的格式和风格要求,以确保学术写作的清晰性、准确性、一致性和规范性。它涵盖了学术论文的各个方面,包括标题页、摘要、正文、参考文献等,并规定了引用和参考文献的格式和要求。

APA style通常用于社会科学领域的学术论文和出版物,如心理学、教育学、社会学、护理学、商务管理等。在美国和其他英语国家,APA style已成为学术写作的标准要求之一。

回答:

Title: A Soft and Cute Panda Plush Toy for All Ages

Introduction: 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. I highly recommend this product to anyone looking for a versatile and adorable gift option.

参考:

https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/6/transforming


觉得有用就点个赞吧!

我是首飞,一个帮大家填坑的工程师。

我也准备了一份提示词的文档。有涉及到各个领域的提示词模板。
在这里插入图片描述
您可以在《首飞》公众号中回复“ 提示词 ” 获取该文档。

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

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

相关文章

利用lambda优化反射功能实现方法调用

最近在思考lambda相关的问题&#xff0c;简单记录下做的相关反射替代和函数映射的尝试。 原理分析 lambda是jdk8才提供的&#xff0c;原理其实就是动态生成内部类来执行函数映射的方法。也就是说一段lambda表达式会对应特定的类方法&#xff0c;之后调用。底层是通过LambdaMe…

《离散数学》:逻辑

〇、前言 离散数学是数学的一个分支&#xff0c;研究离散对象和离散结构的数学理论和方法。这学期学校开了离散数学的课程&#xff0c;我受益颇丰&#xff0c;感觉到了离散数学真正的魅力&#xff0c;也被开创离散数学各个分支的人的聪明与才智深深折服。与连续数学不同&#…

Stopwatch工具类计时器探究

搬砖的我们 特别是Java开发的童鞋们, 经常需要通过记录开始时间和结束时间&#xff0c;然后通过计算差值&#xff0c;得到时间差&#xff0c;如下面的代码&#xff1a; long start System.currentTimeMillis(); long end System.currentTimeMillis(); System.out.println(…

【数字调制】数字调制技术FSK与PSK分析与研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

栈的数据结构完成表达式(5*10+2-7+5)/10+5的计算

栈&#xff08;Stack&#xff09;是一种线性数据结构&#xff0c;具有后进先出&#xff08;LIFO&#xff09;的特性。它可以理解为一种类似于抽屉的容器&#xff0c;只能在顶部进行插入和删除操作&#xff0c;其他位置不可访问。栈的基本操作包括入栈&#xff08;push&#xff…

[数字图像处理]第五章 图像复原与重建

文章目录 第五章 图像复原与重建5.1图像退化复原过程的模型图像退化图像复原图像复原与图像增强图像退化的数学模型为什么采用线性位移不变系统模型来描述图像退化过程 5.2 噪声模型x5.2.1 噪声的空间和频率特性5.2.2 一些重要的噪声概率密度函数高斯噪声实验&#xff1a;采用高…

【微服务架构设计和实现】4.1 微服务架构概述和设计原则

往期回顾&#xff1a; 第一章&#xff1a;【云原生概念和技术】 第二章&#xff1a;【容器化应用程序设计和开发】 第三章&#xff1a;【基于容器的部署、管理和扩展】 4.1 微服务架构概述和设计原则 4.1 微服务架构概述和设计原则4.1.1 微服务架构的优点4.1.2 微服务架构遵…

在 ArcGIS Pro 中使用 H3 创建蜂窝六边形

在 ArcGIS Pro 中使用 H3 创建蜂窝六边形https://mp.weixin.qq.com/s/tGk7AT2jAcvsmNyp2bRvig 之前看了个有意思的ArcGIS博客&#xff1a;H3六边形&#xff0c;当然了这也不是个新鲜东西了。原文&#xff1a; https://www.esri.com/arcgis-blog/products/arcgis-pro/analytic…

为什么要学GIS开发

什么是地理信息系统技术&#xff1f; GIS技术使用专门的计算机系统来获取地理数据并将其集成到智能“超级”地图中。然后&#xff0c;这些数据可用于创建无穷无尽的“假设”场景&#xff0c;为以下应用程序提供强大的工具&#xff1a; 制图&#xff08;地图制作&#xff09;应…

【阅读随笔】Rewrite-Based Decomposition of Signal Temporal Logic Specifications

文章目录 Overview1 IntroLTL任务分解STL任务分解本文工作 Background and Problem DefinitionSTLAgent假设与问题方法 An STL Rewriting SystemRewriting SystemFormula Rewrite DAG Decomposing STL智能体编队任务分解最优分解 Exploring the Formula Rewrite DAGExperiments…

soci在windows下vs2010编译

需要下载 的资源 mysql connector c 因为其使用的的是mysql connector c的api&#xff0c;需要下载https://downloads.mysql.com/archives/c-c/ 分别对应32位和64位的 soci 4.0 从github上下载4.03分支 https://github.com/SOCI/soci/tree/v4.0.3 cmake 需要下载3.25版…

Java多线程快速入门

文章目录 Java多线程快速入门1、认识多线程2、多线程的实现2.1 继承Thread类2.2 实现Runnable接口2.3 利用Callable和Futrue接口2.4 三种方式的比较 3、Thread类常用API3.1 守护线程3.2 礼让线程3.3 插入线程3.4 线程的生命周期 5、线程安全问题5.1 synchronized5.2 Lock 6、等…

wsl安装ubuntu并设置gnome图形界面详细步骤(win11+ubuntu18)

0.前言 wsl确实是个好东西&#xff0c;不过之前配了好几次都没有成功&#xff0c;因为wsl本身确实是有bug。当时配的时候查到GitHub上的一个issue还没被修好。现在重新配一下。 我的环境是Windows11家庭版。区别于win10&#xff0c;win11安装完默认就是wsl2。 1.下载 首先打…

Linux之管理联网

目录 Linux之管理联网 rhel8与7的区别 NetworkManager 定义 NM能管理各种网络 使用方法 使用NM的原因 nmcli使用方法 nmcli的两个常用命令 nmcli connection 定义 两种状态 nmcli device 定义 四种状态 nmcli常用命令 查看ip&#xff08;类似于ifconfig、ip addr&a…

每周练习学习(一)1.1--nc的使用与系统命令执行

1.test_your_nc ----nc的使用与系统命令执行1 平台&#xff1a;buuctf 之前在攻防开学来考核的时候&#xff0c;遇到过一个nc的题&#xff0c;但自己完全不知道nc是什么意思&#xff0c;所以现在为了增强一点自己的知识面&#xff08;说的好听&#xff0c;也就是为了快期末…

4.8 Socket介绍 4.9字节序 4.10字节序转换函数

4.8 Socket介绍 所谓 socket&#xff08;套接字&#xff09;&#xff0c;就是对网络中不同主机上的应用进程之间进行双向通信的端点的抽象。一个套接字就是网络上进程通信的一端&#xff0c;提供了应用层进程利用网络协议交换数据的机制。从所处的地位来讲&#xff0c;套接字上…

使用EasyCode自定义模板,自动生成代码

首先创建spring boot项目&#xff0c;导入相关依赖是必须的#### 导入依赖&#xff1a; pom.xml <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001…

设计模式(十八):行为型之观察者模式

设计模式系列文章 设计模式(一)&#xff1a;创建型之单例模式 设计模式(二、三)&#xff1a;创建型之工厂方法和抽象工厂模式 设计模式(四)&#xff1a;创建型之原型模式 设计模式(五)&#xff1a;创建型之建造者模式 设计模式(六)&#xff1a;结构型之代理模式 设计模式…

【RabbitMQ教程】第六章 —— RabbitMQ - 延迟队列

&#x1f4a7; 【 R a b b i t M Q 教程】第六章—— R a b b i t M Q − 延迟队列 \color{#FF1493}{【RabbitMQ教程】第六章 —— RabbitMQ - 延迟队列} 【RabbitMQ教程】第六章——RabbitMQ−延迟队列&#x1f4a7; &#x1f337; 仰望天空&#xff0c;妳我亦是行人…

数据提取概述

数据提取概述 一、响应内容的分类 在发送请求获取响应之后&#xff0c;可能存在多种不同类型的响应内容&#xff1b;而且很多时候&#xff0c;我们只需要响应内容中的一部分数据 结构化的响应内容 json字符串 可以使用re、json等模块来提取特定数据json字符串的例子如下图 x…