멀티스텝 프롬프팅

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

Fouad Trad

Machine Learning Engineer

멀티스텝 프롬프팅

  • 최종 목표를 일련의 단계로 분해
  • 모델이 각 단계를 거쳐 최종 출력 생성
  • 멀티스텝 프롬프트의 활용 분야:
    • 순차적 작업
    • 인지적 작업

멀티스텝 프롬프트가 모델에게 일련의 순차적 단계를 제공하는 방식을 보여주는 다이어그램.

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

보물 지도로서의 멀티스텝 프롬프트

보물 지도와 보물을 찾기 위한 단서들을 나타내는 이미지.

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

단일 스텝 프롬프트: 블로그 작성

prompt = "Compose a travel blog"
print(get_response(prompt))
Title: Exploring the Enchanting Landscapes of Iceland

Introduction: Welcome to my travel blog! Today, I am thrilled to share my unforgettable journey through 
the mesmerizing landscapes of Iceland. 

Day 1: Reykjavik - The Charming Capital [...]
Day 2: Golden Circle - Nature's Wonders [...]
Day 3: South Coast - A Journey of Ice and Fire [...]
Day 4: Glacier Lagoon - A Frozen Wonderland [...]
Day 5: Blue Lagoon - A Relaxing Finale [...]
OpenAI API로 배우는 프롬프트 엔지니어링

멀티스텝 프롬프트: 블로그 포스트 작성

prompt = """Compose a travel blog as follows:
Step 1: Introduce the destination.
Step 2: Share personal adventures during the trip.
Step 3: Summarize the journey.
"""
print(get_response(prompt))
OpenAI API로 배우는 프롬프트 엔지니어링

여행 블로그 포스트 작성

Title: Exploring the Enchanting Streets of Barcelona

Step 1: Introduce the destination. Welcome to Barcelona, a vibrant city nestled along the stunning Mediterranean coast of Spain [...]
Step 2: Share personal adventures during the trip. Exploring the narrow, winding streets of the Gothic Quarter, I stumbled upon hidden gems at every turn. [...]
Step 3: Summarize the journey. As my journey through Barcelona came to an end, I couldn't help but feel grateful for the incredible experiences and memories I had made [...]
OpenAI API로 배우는 프롬프트 엔지니어링

솔루션 정확성 분석

  • 솔루션 정확성 검사에는 여러 단계가 필요합니다
  • 예시:
    • 계산 함수를 위한 파이썬 코드

계산기 이미지

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

솔루션 정확성 분석

검사할 대표 솔루션

calculator = """
def add(a, b):
    return a + b
def subtract(a, b):
    return a - b
def multiply(a, b):
    return a * b
def divide(a, b):
    return a / b
"""
단일 스텝 프롬프트:
prompt = f"""Determine if the code delimited 
by triple backticks is correct or not.
Answer by yes or no.
```{calculator}```"""

print(get_response(prompt))
Yes
OpenAI API로 배우는 프롬프트 엔지니어링

멀티스텝 프롬프팅으로 솔루션 정확성 분석

멀티스텝 프롬프트:
prompt = f"""Determine the correctness of the code delimited by triple backticks 
as follows: 
Step 1: Check the code correctness in each function. 
Step 2: Verify if the divide function handles the case when dividing by 0. 
Code: ```{calculator}```"""

print(get_response(prompt))
The code appears to be correct. It defines four functions: add, subtract, multiply, and 
divide. Each function performs the corresponding mathematical operation and returns the
result. However, it does not handle the case when dividing by 0, which can result in a 
ZeroDivisionError.
OpenAI API로 배우는 프롬프트 엔지니어링

멀티스텝 프롬프트와 퓨샷 프롬프트 비교

스텝

  • 모델에게 수행할 작업을 명시적으로 지시

멀티스텝 프롬프트가 명령어를 일련의 단계로 분해하여 모델이 하나씩 처리하는 방식을 보여주는 다이어그램.

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

멀티스텝 프롬프트와 퓨샷 프롬프트 비교

스텝

  • 모델에게 수행할 작업을 명시적으로 지시

멀티스텝 프롬프트가 명령어를 일련의 단계로 분해하여 모델이 하나씩 처리하는 방식을 보여주는 다이어그램.

  • 모델이 학습하는 질문과 답변 예시

퓨샷 프롬프트의 작동 방식을 보여주는 이미지. 예시 질문과 답변, 그리고 모델에게 묻는 질문이 입력으로 제공됩니다.

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

연습해 봅시다!

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

Preparing Video For Download...