मल्टी-स्टेप प्रॉम्प्टिंग

OpenAI API के साथ Prompt Engineering

Fouad Trad

Machine Learning Engineer

मल्टी-स्टेप प्रॉम्प्टिंग

  • अंतिम लक्ष्य को कई चरणों में तोड़ें
  • मॉडल हर चरण से गुजरकर अंतिम आउटपुट देता है
  • मल्टी-स्टेप प्रॉम्प्ट इस्तेमाल होते हैं:
    • क्रमिक कार्यों के लिए
    • संज्ञानात्मक कार्यों के लिए

एक डायग्राम जो दिखाता है कि मल्टी-स्टेप प्रॉम्प्ट, मॉडल को क्रमवार चरणों की श्रृंखला देता है जिन्हें उसे करना है.

OpenAI API के साथ Prompt Engineering

ख़ज़ाने के नक्शे जैसे मल्टी-स्टेप प्रॉम्प्ट

एक ख़ज़ाने के नक्शे की छवि, साथ में ख़ज़ाना ढूँढने के कुछ संकेत.

OpenAI API के साथ Prompt Engineering

सिंगल-स्टेप प्रॉम्प्ट: ब्लॉग लिखना

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 Engineering

मल्टी-स्टेप प्रॉम्प्ट: ब्लॉग पोस्ट लिखना

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 के साथ Prompt Engineering

ट्रैवल ब्लॉग पोस्ट लिखना

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 के साथ Prompt Engineering

समाधान की शुद्धता का विश्लेषण

  • समाधान की शुद्धता जाँचना कई चरण माँगता है
  • उदाहरण:
    • कैलकुलेशन फंक्शनों के लिए Python कोड

कैलकुलेटर की छवि

OpenAI API के साथ Prompt Engineering

समाधान की शुद्धता का विश्लेषण

जाँचने के लिए सामान्य समाधान

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 Engineering

समाधान की शुद्धता जाँचने के लिए मल्टी-स्टेप प्रॉम्प्टिंग

मल्टी-स्टेप प्रॉम्प्ट:
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 के साथ Prompt Engineering

मल्टी-स्टेप बनाम फ्यू-शॉट प्रॉम्प्ट

Steps

  • मॉडल को साफ़-साफ़ बताएँ कि क्या करना है

एक डायग्राम जो दिखाता है कि मल्टी-स्टेप प्रॉम्प्ट निर्देश को इनपुट में चरणों की श्रृंखला में तोड़ता है ताकि मॉडल उन्हें एक-एक करके देख सके.

OpenAI API के साथ Prompt Engineering

मल्टी-स्टेप बनाम फ्यू-शॉट प्रॉम्प्ट

Steps

  • मॉडल को साफ़-साफ़ बताएँ कि क्या करना है

एक डायग्राम जो दिखाता है कि मल्टी-स्टेप प्रॉम्प्ट निर्देश को इनपुट में चरणों की श्रृंखला में तोड़ता है ताकि मॉडल उन्हें एक-एक करके देख सके.

Shots

  • प्रश्न-उत्तर जिनसे मॉडल सीखता है

एक छवि जो दिखाती है कि फ्यू-शॉट प्रॉम्प्ट कैसे काम करता है, जहाँ मॉडल के इनपुट में उदाहरण प्रश्न-उत्तर का सेट होता है, साथ में वह प्रश्न जिसका उत्तर हमें चाहिए.

OpenAI API के साथ Prompt Engineering

अभ्यास करते हैं!

OpenAI API के साथ Prompt Engineering

Preparing Video For Download...