首页 > 其他分享 >[Prompt] Transforming

[Prompt] Transforming

时间:2023-05-02 15:13:00浏览次数:32  
标签:prompt Transforming text going my Prompt My response

Universal Translator

Imagine you are in charge of IT at a large multinational e-commerce company. Users are messaging you with IT issues in all their native languages. Your staff is from all over the world and speaks only their native languages. You need a universal translator!

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

Writing can vary based on the intended audience. ChatGPT can produce different tones.

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

Spellcheck/Grammar check.

Here are some examples of common grammar and spelling problems and the LLM's response.

To signal to the LLM that you want it to proofread your text, you instruct the model to 'proofread' or '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)
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)

from redlines import Redlines

diff = Redlines(text,response)
display(Markdown(diff.output_markdown))

标签:prompt,Transforming,text,going,my,Prompt,My,response
From: https://www.cnblogs.com/Answer1215/p/17367711.html

相关文章

  • 迁移Prompt–解决Prompt Tuning三大问题!
    文|Harris刘鹏飞博士将近代NLP的研究划归为四种范式[1]并把预训练语言模型加持下的PromptLearning看作是近代自然语言处理技术发展的“第四范式”。当我们使用新范式的方法的时候,能够意识到它带来的优异性可能是以某种“人力”牺牲为代价的。而如何让这种人力代价降到最低,往往......
  • 吴恩达Prompt课 - 02 构建原则
    吴恩达和OpenAI一起制作了节一个半小时的,面向开发者的关于《ChatGPTPromptEngineering》的课,对自己Prompt提高非常有帮助。英文课程地址:https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/我反复学习后,针对每小节的例子和关键部分按......
  • 吴恩达Prompt课 - 01 介绍
    吴恩达和OpenAI一起制作了节一个半小时的,面向开发者的关于《ChatGPTPromptEngineering》的课,对自己Prompt提高非常有帮助。英文课程地址:https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/我反复学习后,针对每小节的例子和关键部分按......
  • Langchain框架 prompt injection注入
    Langchain框架promptinjection注入PromptInjection是一种攻击技术,黑客或恶意攻击者操纵AI模型的输入值,以诱导模型返回非预期的结果Langchain框架LangChain是一个基于大语言模型进行应用开发的框架。所谓大语言模型(LargeLanguageModels,LLMs),是指基于海量语料训练、......
  • 7个AI绘画工具Prompt站
    ChatGPT的流行使得AI成为2023最大的科技风口,同时驱动了各种类型的AI发展。这些AI正在改变甚至颠覆很多行业的业务模式。ChatGPT推动了生成式AI革命的到来,这正在彻底颠覆内容的生产方式。自PGC、UGC之后,内容生成终于迎来下一个发展阶段——AIGC。AI工具种类也......
  • 《花雕学AI》24:如何用万能Prompt公式与ChatGPT进行高效的对话测试
    引言你是否想要与人工智能进行有趣、有价值、有说服力的对话?你是否想要使用ChatGPT这个强大而灵活的对话生成器来创造出任何类型和主题的对话?如果是这样,那么你需要了解一个简单而强大的工具,就是万能Prompt公式。万能Prompt公式是一种用于生成任何类型和主题的对话的模板,它可以帮......
  • 你也可以动手参数有效微调:LoRA、Prefix Tuning、P-Tuning、Prompt Tuning
    Part1前言随着大语言模型的流行,如何让大模型在消费级GPU上进行微调训练成为了热点。掌握参数有效微调成为每个自然语言处理工程师必不可少的技能,正好huggingface开源了一个PEFT库,让我们也能够自己动手去了解参数有效微调。接下来以中文情感分析(二分类)去了解下参数有效微调。使......
  • Prompt
    https://mp.weixin.qq.com/s/vyKCCjAEbuOxpKOd6zhz3w一文跟进Prompt进展!综述+15篇最新论文逐一梳理原创ZenMoore夕小瑶科技说2021-11-0412:46https://mp.weixin.qq.com/s/uaS-YjYcEU_3En-Q96YMzwFine-tune之后的NLP新范式:Prompt越来越火,CMU华人博士后出了篇综述文章刘鹏......
  • JavaScript 之 confirm,alert,prompt
    //confirmfunctiondisp_confirm(){varr=confirm("Pressabutton!")if(r==true){alert("YoupressedOK!")}else{alert("YoupressedCancel!")}}//alert<script>window.alert("确......
  • 对话ChatGPT:Prompt是普通人“魔法”吗?
    在ChatGPT、Midjourney、StableDiffusion等新事物的作用下,不少人或多或少听说过Prompt的概念。虽然OpenAI掀起的大模型浪潮再度刷新了人们对AI的认知,但现阶段的AI终归还不是强人工智能,大模型里的“知识”存储在一个隐性空间里,需要输给AI正确的指令,也就是过去几个月中频频被讨论的P......