目录
1、文本翻译
1.1、翻译为德语
1.2、识别语种
1.3、多语言翻译
1.4、同时进行语气转换
1.5、通用翻译器
2、语气与写作风格调整
3、数据格式转换
4、拼写及语法纠正
5、综合样例
大语言模型具有强大的文本转换能力,可以实现多语言翻译、拼写纠正、语法调整、格式转换等不同类型的文本转换任务。利用语言模型进行各类转换是它的典型应用之一。
1、文本翻译
1.1、翻译为德语
将以下中文翻译成德语:、
```您好,我想订购一个搅拌机。```
{
"German": "Guten Tag, ich möchte einen Mixer bestellen."
}
1.2、识别语种
请告诉我以下文本是什么语种:
```Guten Tag, ich möchte einen Mixer bestellen.```
这段文本是德语。
1.3、多语言翻译
请将以下文本分别翻译成中文、英文、法语和西班牙语:
```I want to order a basketball.```
{
"中文": "我想订购一个篮球。",
"英文": "I want to order a basketball.",
"法语": "Je veux commander un ballon de basket.",
"西班牙语": "Quiero ordenar un balón de baloncesto."
}
1.4、同时进行语气转换
请将以下文本翻译成中文,分别展示成正式与非正式两种语气:
```Would you like to order a pillow?```
{
"正式": "您想订购一个枕头吗?",
"非正式": "你想订购一个枕头吗?"
}
1.5、通用翻译器
需要一个智能的通用翻译工具。该翻译工具需要能够自动识别不同语言文本的语种,无需人工指定。然后它可以将这些不同语言的文本翻译成目标用户的母语。在这种方式下,全球各地的用户都可以轻松获得用自己母语书写的内容。
告诉我以下五段文本是什么语种,直接输出语种,如法语,无需输出标点符号:
```
La performance du système est plus lente que d'habitude,
Mi monitor tiene píxeles que no se iluminan,
Il mio mouse non funziona,
Mój klawisz Ctrl jest zepsuty,
我的屏幕在闪烁
```
这五段文本分别是:
法语、西班牙语、意大利语、波兰语、中文。
将以下五条消息先识别他的对应语种,然后分别翻译成英文和中文,
并写成
中文翻译:xxx
英文翻译:yyy
的格式:
```
La performance du système est plus lente que d'habitude,
Mi monitor tiene píxeles que no se iluminan,
Il mio mouse non funziona,
Mój klawisz Ctrl jest zepsuty,
我的屏幕在闪烁
```
[
{
"语种": "法语",
"原文": "La performance du système est plus lente que d'habitude",
"中文翻译": "系统的性能比平时更慢",
"英文翻译": "The system's performance is slower than usual"
},
{
"语种": "西班牙语",
"原文": "Mi monitor tiene píxeles que no se iluminan",
"中文翻译": "我的显示器有一些像素不亮",
"英文翻译": "My monitor has pixels that do not light up"
},
{
"语种": "意大利语",
"原文": "Il mio mouse non funziona",
"中文翻译": "我的鼠标不能工作",
"英文翻译": "My mouse does not work"
},
{
"语种": "波兰语",
"原文": "Mój klawisz Ctrl jest zepsuty",
"中文翻译": "我的Ctrl键坏了",
"英文翻译": "My Ctrl key is broken"
},
{
"语种": "中文",
"原文": "我的屏幕在闪烁",
"中文翻译": "我的屏幕在闪烁",
"英文翻译": "My screen is flickering"
}
]
2、语气与写作风格调整
将以下文本翻译成商务信函的格式:
```小老弟,我小羊,上回你说咱部门要采购的显示器是多少寸来着?```
尊敬的[收件人姓名]:
您好!
我是小羊。上次您提到我们部门需要采购的显示器,请问尺寸是多少寸的?
感谢您的回复。
祝好!
[您的姓名]
3、数据格式转换
将以下JSON数据对象转成HTML格式,保留标题和列名
```
{ "resturant employees" :[
{"name":"Shyam", "email":"shyamjaiswal@gmail.com"},
{"name":"Bob", "email":"bob32@gmail.com"},
{"name":"Jai", "email":"jai87@gmail.com"}
]}```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Restaurant Employees</title>
<style>
table {
width: 50%;
border-collapse: collapse;
margin: 25px 0;
font-size: 18px;
text-align: left;
}
th, td {
padding: 12px;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h2>Restaurant Employees</h2>
<table>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<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>
</table>
</body>
</html>
from IPython.display import display, Markdown, Latex, HTML, JSON
display(HTML(response))
4、拼写及语法纠正
利用大语言模型进行自动校对可以极大地降低人工校对的工作量。
请校对并更正以下文本,注意纠正文本保持原始语种,无需输出原始文本。
如果您没有发现任何错误,请说“未发现错误”。如果错误,需要说出错误原因
例如:
输入:I are happy.
输出:I am happy.
```
"The girl with the black and white puppies have a ball.",
"Yolanda has her notebook.",
"Its going to be a long day. Does the car need it’s oil changed?",
"Their goes my freedom. There going to bring they’re suitcases.",
"Your going to need you’re notebook.",
"That medicine effects my ability to sleep. Have you heard of the butterfly affect?",
"This phrase is to cherck chatGPT for spelling abilitty"
```
"The girl with the black and white puppies has a ball."
错误原因:主语是 "The girl",需要使用单数动词 "has"。
"It's going to be a long day. Does the car need its oil changed?"
错误原因:使用的是 "its" 而不是 "it’s"。
"There goes my freedom. They're going to bring their suitcases."
错误原因:使用了错误的同音异义词 "Their" 和 "There" 以及 "they're"。
"You're going to need your notebook."
错误原因:使用了错误的同音异义词 "Your" 和 "you're"。
"That medicine affects my ability to sleep. Have you heard of the butterfly effect?"
错误原因:使用了错误的词 "effects" 和 "affect"。
"This phrase is to check ChatGPT for spelling ability."
错误原因:拼写错误 "cherck" 和 "abilitty"。
引入 Redlines
包,详细显示并对比纠错过程:
# 如未安装redlines,需先安装 pip3.8 install redlines
from redlines import Redlines
from IPython.display import display, Markdown
diff = Redlines(text,response)
display(Markdown(diff.output_markdown))
5、综合样例
语言模型具有强大的组合转换能力,可以通过一个Prompt同时实现多种转换,大幅简化工作流程。
下面是一个示例,展示了如何使用一个Prompt,同时对一段文本进行翻译、拼写纠正、语气调整和格式转换等操作。
针对以下三个反引号之间的英文评论文本, 首先进行拼写及语法纠错, 然后将其转化成中文, 再将其转化成优质淘宝评论的风格,从各种角度出发,分别说明产品的优点与缺点,并进行总结。 润色一下描述,使评论更具有吸引力。
输出结果格式为:
【优点】xxx
【缺点】xxx
【总结】xxx
注意,只需填写xxx部分,并分段输出。 将结果输出成Markdown格式。
```
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.```