텍스트 변환

OpenAI API로 배우는 프롬프트 엔지니어링

Fouad Trad

Machine Learning Engineer

텍스트 변환

  • 주어진 텍스트를 새로운 텍스트로 변환
  • 다양한 활용 분야
    • 언어 번역
    • 톤 조정
    • 글쓰기 개선

원본 텍스트에서 매우 유사한 표현을 가진 변환된 텍스트로 이동하는 과정을 보여주는 이미지.

OpenAI API로 배우는 프롬프트 엔지니어링

언어 번역

  • 프롬프트에 입력 및 출력 언어 지정
text = "XYZ Scooter is a cutting-edge electric scooter designed for urban 
adventurers. Its sleek design, long-lasting battery, and smart connectivity offer 
a seamless and eco-friendly way to navigate city streets."

prompt = f"""Translate the English text delimited by triple backticks to French: ```{text}```""" print(get_response(prompt))
XYZ Scooter est une trottinette électrique de pointe conçue pour les aventuriers 
urbains. Avec son design élégant, sa batterie longue durée et sa connectivité 
intelligente, elle offre un moyen fluide et respectueux de l'environnement de se 
déplacer dans les rues de la ville.
OpenAI API로 배우는 프롬프트 엔지니어링

텍스트 언어를 모를 경우...

text = "Das Produkt ist wirklich schön, und der Preis ist fair."

텍스트 언어를 알려달라고 모델에 요청

prompt = f"""Tell me which language is the text delimited by triple backticks:
           ```{text}```"""

print(get_response(prompt))
The text delimited by triple backticks (```) is in the German language.
OpenAI API로 배우는 프롬프트 엔지니어링

다국어 번역

  • 여러 언어로 동시에 번역
text = "The product combines top quality with a fair price."
prompt =  f"""Translate the English text delimited by triple backticks to French, 
Spanish, and German:
```{text}```"""
French: Le produit allie une qualité supérieure à un prix équitable.
Spanish: El producto combina una calidad superior con un precio justo.
German: Das Produkt vereint Spitzenqualität mit einem fairen Preis.
  • 참고: 고객이 관련된 경우 모델 번역 결과를 검증해야 합니다
OpenAI API로 배우는 프롬프트 엔지니어링

톤 조정

  • 다른 톤으로 텍스트 재작성
text = "Hey there! Check out our awesome summer deals! They're super cool, and you 
won't want to miss them. Grab 'em now!"

prompt = f"""Write the text delimited by triple backticks using a formal and persuasive tone: ```{text}```""" print(get_response(prompt))
OpenAI API로 배우는 프롬프트 엔지니어링

톤 조정

Dear [Recipient's Name],

We cordially invite you to explore our exceptional summer offers! These exclusive 
deals are truly extraordinary and should not be missed. Time is limited, so we 
encourage you to seize these incredible opportunities promptly.

[...]

Don't miss out on this chance! Take swift action to secure these remarkable summer 
deals before they expire. You won't find a more enticing selection of offers 
elsewhere.

[...]
OpenAI API로 배우는 프롬프트 엔지니어링

톤 조정: 대상 독자 지정

text = "Our cutting-edge widget employs state-of-the-art microprocessors and 
advanced algorithms, delivering unparalleled efficiency and performance for a wide 
range of applications."

prompt = f"""Write the text delimited by triple backticks to be suitable for a non-technical audience: ```{text}```""" print(get_response(prompt))
Our advanced widget uses the latest technology to provide exceptional efficiency 
and performance for a variety of uses.
OpenAI API로 배우는 프롬프트 엔지니어링

문법 및 글쓰기 개선

  • 다른 부분은 수정하지 않고 맞춤법, 문법, 구두점 오류 교정
text = "Dear sir, I wanted too discus a potentiel opportunity for colabration. 
Pls let me know wen you're avaliable."
prompt = f"""Proofread the text delimited by triple backticks while keeping the 
original text structure intact:
           ```{text}```"""
print(get_response(prompt))
Dear sir, I wanted to discuss a potential opportunity for collaboration. Please 
let me know when you are available.
OpenAI API로 배우는 프롬프트 엔지니어링

문법 및 글쓰기 개선

  • 텍스트 구조를 수정하여 명확성 향상
text = "Dear sir, I wanted too discus a potentiel opportunity for colabration. 
Pls let me know wen you're avaliable."
prompt = f"""Proofread and restructure the text delimited by triple backticks for 
enhanced readability, flow, and coherence:
           ```{text}```"""
print(get_response(prompt))
Dear sir,

I wanted to discuss with you a potential opportunity for collaboration. 
Please let me know your availability.

Thank you.
OpenAI API로 배우는 프롬프트 엔지니어링

다중 변환

  • 여러 변환을 한 번에 요청 -> 다단계 프롬프트
text = "omg, I cant believe how awesome this product is! Its like the best thing ever! You guys gotta 
try it out!"

prompt = f"""Transform the text delimited by triple backticks with the following two steps: Step 1 - Proofread it without changing its structure Step 2 - Change the tone to be professional ```{text}```""" response = get_response(prompt)
Step 1 - OMG, I can't believe how awesome this product is! It's like the best thing ever! You guys 
gotta try it out!
Step 2 - I am astounded by the exceptional qualities of this product. It represents a remarkable 
solution that surpasses expectations. I highly recommend trying it out, as its benefits are truly 
impressive.
OpenAI API로 배우는 프롬프트 엔지니어링

연습해 봅시다!

OpenAI API로 배우는 프롬프트 엔지니어링

Preparing Video For Download...