如何使用ChatGPT得到更满意的结果(6):面向开发者的ChatGPT Prompt Engineering (Transforming)

承接上篇,继续整理关于面向开发者的Prompt Engineering教程笔记,教程之前的部分见:如何使用ChatGPT得到更满意的结果:Prompt Engineering (2)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(3):面向开发者的ChatGPT Prompt Engineering (迭代式Prompt开发)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(4):面向开发者的ChatGPT Prompt Engineering (Summarizing)_Dorothy30的博客-CSDN博客

如何使用ChatGPT得到更满意的结果(5):面向开发者的ChatGPT Prompt Engineering (Inferring)_Dorothy30的博客-CSDN博客

整理的内容基本上英文原文都来自于教程,有需要的朋友可以直接戳https://learn.deeplearning.ai/。这篇笔记主要整理教程中的Transforming部分。我们将探索如何使用大型语言模型进行文本转换任务,比如语言翻译、语气调整,格式转换以及拼写/语法检查。

1 翻译

ChatGPT经过多种语言的训练,因此该模型具备良好翻译的能力。以下是使用这一功能的示例。

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

 

2 语气调整

写作可以根据预期受众而有所不同。ChatGPT也可以根据你的需求进行不同的语气文本生成。例如,下面展示了如何将slang转换为商务英语。

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)

 

3 文本格式转换

ChatGPT可以在不同文本格式之间进行转换。实现该功能的prompt需要包含输入和输出的格式。以下为一个示例:

这里我们有一个包含餐厅员工姓名和电子邮件的JSON列表。然后在prompt中,我们要求模型将其从JSON格式转换成HTML格式。

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)

 紧接着再使用IPython.display模块输出HTML的可视化表格。

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

 

4 拼写/语法检查

这里有一些常见的语法和拼写问题的例子,以及大型语言模型(LLM)针对这些问题的回答。

4.1 校对和纠正

如果你希望使用大型语言模型(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 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)

 

4.2 使文本符合APA的写作风格

你也可以在使用LLM进行文本校对和修正的同时,确保文本符合APA的写作风格,并用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))

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值