面向开发者的LLM入门课程-拼写及语法纠正: 拼写及语法纠正 在使用非母语撰写时,拼写和语法错误比较常见,进行校对尤为重要。例如在论坛发帖或撰写英语论文时,校对文……
哈喽!伙伴们,我是小智,你们的AI向导。欢迎来到每日的AI学习时间。今天,我们将一起深入AI的奇妙世界,探索“面向开发者的LLM入门课程-拼写及语法纠正”,并学会本篇文章中所讲的全部知识点。还是那句话“不必远征未知,只需唤醒你的潜能!”跟着小智的步伐,我们终将学有所成,学以致用,并发现自身的更多可能性。话不多说,现在就让我们开始这场激发潜能的AI学习之旅吧。
面向开发者的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 spelling abilitty” # spelling
]
for i in range(len(text)):
time.sleep(20)
prompt = f”””请校对并更正以下文本,注意纠正文本保持原始语种,无需输出原始文本。
如果您没有发现任何错误,请说“未发现错误”。
例如:
输入:I are happy.
输出:I am happy.
“`{text[i]}“`”””
response = get_completion(prompt)
print(i, response)
0 The girl with the black and white puppies has a ball.
1 Yolanda has her notebook.
2 It’s going to be a long day. Does the car need its oil changed?
3 Their goes my freedom. There going to bring their suitcases.
4 You’re going to need your notebook.
5 That medicine affects my ability to sleep. Have you heard of the butterfly
effect?
6 This phrase is to check chatGPT for spelling ability.
下面是一个使用大语言模型进行语法纠错的简单示例,类似于Grammarly(一个语法纠正和校对的工具)的功能。
输入一段关于熊猫玩偶的评价文字,语言模型会自动校对文本中的语法错误,输出修改后的正确版本。这里使用的Prompt比较简单直接,只要求进行语法纠正。我们也可以通过扩展Prompt,同时请求语言模型调整文本的语气、行文风格等。
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”校对并更正以下商品评论:“`{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. It’s also a bit smaller than
I expected for the price. I think there might be other options that are bigger
for the same price. On the bright side, it arrived a day earlier than expected,
so I got to play with it myself before giving it to my daughter.
引入 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))
Got I got this for my daughter for her daughter’s birthday cuz because she keeps taking mine
from my room. room. Yes, adults also like pandas too. too. She takes it everywhere with her,
and it’s super soft and cute. One cute. However, one of the ears is a bit lower than the other,
and I don’t think that was designed to be asymmetrical. It’s also a bit small smaller than I
expected for what I paid for it though. the price. I think there might be other options that are
bigger for the same price. It price. On the bright side, it arrived a day earlier than expected, so I
got to play with it myself before I gave giving it to my daughter.
这个示例展示了如何利用语言模型强大的语言处理能力实现自动化的语法纠错。类似的方法可以运用于校对各类文本内容,大幅减轻人工校对的工作量,同时确保文本语法准确。掌握运用语言模型进行语法纠正的技巧,将使我们的写作更加高效和准确。
嘿,伙伴们,今天我们的AI探索之旅已经圆满结束。关于“面向开发者的LLM入门课程-拼写及语法纠正”的内容已经分享给大家了。感谢你们的陪伴,希望这次旅程让你对AI能够更了解、更喜欢。谨记,精准提问是解锁AI潜能的钥匙哦!如果有小伙伴想要了解学习更多的AI知识,请关注我们的官网“AI智研社”,保证让你收获满满呦!
还没有评论呢,快来抢沙发~