Machine Learning & AI · Chapter 4.7 · Intermediate level

Bonus: Generative AI & Prompt Engineering (LLM Lab)

बोनस: Generative AI और Prompt Engineering (ChatGPT/Gemini सीक्रेट)

Today's hottest AI skill is Generative AI & Prompt Engineering (how models like Gemini & ChatGPT work)! Unlike classical ML that predicts a single label, a Large Language Model (LLM) generates full explanations, code, and plans. The secret formula for a 100/100 Master Prompt is: 1. Clear Role + 2. Specific Task + 3. Output Format!

आज दुनिया की सबसे हाई-डिमांड स्किल है Generative AI और Prompt Engineering (जिस पर Gemini और ChatGPT काम करते हैं)! AI से परफेक्ट जवाब निकलवाने का सीक्रेट फ़ॉर्मूला याद रखो: 1. Role (AI कौन बने) + 2. Specific Task (क्या काम करना है) + 3. Format (जवाब स्टेप्स/उदाहरण में कैसे चाहिए)!

In the classroom you can run and edit this code in your browser, get hints and mark the chapter as done. क्लास में यह code ब्राउज़र में चलाकर बदल सकते हो।

Words and symbols in this chapter

ai_assistant
Built-in Generative AI mentor simulator ready inside our AI Lab.
हमारी लैब का इन-बिल्ट Generative AI असिस्टेंट।
role="..."
Tells the AI who to act as (e.g. "Senior Coding Teacher").
AI को उसकी भूमिका बताता है (जैसे "Friendly Coding Teacher")।
prompt="..."
Your exact instruction/question with clear context & output format.
आपका साफ़ और पूरा सवाल — जिसमें उदाहरण या स्टेप्स की माँग साफ़ लिखी हो।
ai_assistant.ask(...)
Sends your engineered prompt to the AI and returns the generated response + quality score!
प्रॉम्प्ट को AI के पास भेजता है और जवाब + Prompt Score दिखाता है!

Ready example

role = "Friendly Indian Coding Teacher"
prompt = "Explain Python loops with a real-life example in 3 easy steps"

reply = ai_assistant.ask(prompt, role)
print("AI Reply:", reply)

What you will see: Check your Prompt Quality Score out of 100 on the right and test live custom prompts interactively!

दाईं तरफ़ देखें — आपके प्रॉम्प्ट का Quality Score (100 में से) और लाइव Generative AI Prompt Studio तैयार है!

Line by line

role = "Friendly Indian Coding Teacher"
Gives the AI a clear expert persona.
AI को एक दोस्ताना भारतीय कोडिंग टीचर का रोल दिया।
prompt = "Explain Python loops ... in 3 easy steps"
Specific topic + real-life example + exact format ('3 easy steps') = 100/100 Prompt!
साफ़ विषय + उदाहरण + फ़ॉर्मेट ('3 easy steps') लिखा जिससे 100/100 स्कोर मिलेगा!
reply = ai_assistant.ask(prompt, role)
Generates the AI response and opens the interactive Prompt Quality Studio!
AI का जवाब जनरेट करता है और दाईं तरफ़ लाइव Prompt Studio खोलता है!

Common mistake

✗ Wrong

ai_assistant.ask("Python")  # vague 1-word prompt

✓ Right

ai_assistant.ask("Explain Python loops with example in 3 steps", "Coding Teacher")

One-word prompts give generic replies. Always specify Role + Specific Topic + Output Format!

अधूरे 1-शब्द वाले सवाल से औसत जवाब मिलता है। हमेशा Role + साफ़ काम + स्टेप्स/उदाहरण फ़ॉर्मेट लिखें!

Your task

Define a role and a detailed prompt (include words like steps or example), call ai_assistant.ask(prompt, role), and print the answer!

role और एक विस्तृत prompt (जिसमें steps या example लिखा हो) बनाकर ai_assistant.ask(prompt, role) चलाएँ और जवाब प्रिंट करें!

  1. Set role to an expert title like "Senior Coding Teacher".
    role में कोई एक्सपर्ट नाम लिखें जैसे "Senior Coding Teacher"।
  2. Write a clear 5+ word prompt asking for steps or an example.
    prompt में कम से कम 5 शब्दों का साफ़ सवाल लिखें जिसमें steps या example हो।
  3. Call ai_assistant.ask(prompt, role) and print(...) the result!
    ai_assistant.ask(prompt, role) चलाकर print() करें!
Starter code for the task
role = "Senior Career Mentor"

# TODO 1: prompt = "..." likho - 5+ shabd, aur "steps" ya "example" jaise shabd zaroor daalo
# TODO 2: ans = ai_assistant.ask(prompt, role)
# TODO 3: print(ans)

Do this task in the classroom: your code is checked automatically and you get hints if something is missing.

Recap

Quick quiz

Which 3 ingredients make a high-scoring Generative AI Prompt?

Generative AI से सबसे सटीक जवाब पाने के लिए प्रॉम्प्ट में कौन-सी 3 चीज़ें होनी चाहिए?

  1. Only 1 vague word
  2. Role + Specific Task + Output Format
  3. All capital letters
  4. Lots of emojis only
Show the answer

Answer: B (Role + Specific Task + Output Format)

Giving a clear Role, Specific Task, and Output Format (e.g. 'in 3 steps with example') yields expert LLM answers!

Role + साफ़ काम + Output Format देने से AI सबसे सटीक और उपयोगी जवाब देता है!

Practice problems for this chapter

Solve them in the Practice Zone, where each answer is checked automatically and two hints are available.