GenAI & Agentic AI Workshop · Day 1 · Session 2

Prompt Engineering

Same model. Better answers.

Press → to move · S for speaker notes · F for full screen

Let's try something 🎪

Prompt A: "Write about our college fest."

Prompt B: "Write a 60-word Instagram caption for TechNova 2026, our tech fest on 20–21 Feb. Audience: first-years. Tone: fun. Mention the hackathon and robo-race. End with 2 hashtags."

Which one would you actually post?

Vague in, vague out

Weak prompt gives generic result; strong prompt gives ready-to-post result

Today's plan

  1. Six parts of a good prompt
  2. Zero-shot
  3. Few-shot
  4. Chain-of-thought
  1. System prompts
  2. JSON output for apps
  3. Seven simple tips
  4. Lab: weak vs strong prompts

The six parts of a good prompt

Role, Task, Context, Examples, Format, Rules

Your turn: fix this prompt

"Improve my resume."

Role: You are a placement trainer. Task: Review the resume summary below. Context: Final-year CSE, applying for backend roles. Format: 3 bullet points, under 20 words each. Rules: Don't invent skills I didn't mention.

Four techniques

Zero-shot, few-shot, chain-of-thought, structured output

Zero-shot: just ask

"Is this canteen review positive, negative or neutral? Reply with one word.
Review: The dosa was great but the chai was cold."

→ Neutral

Good for simple, common tasks. Even here, saying the format ("one word") helps.

Few-shot: show, don't tell

Send each complaint to the right department.
Departments: Hostel, Exam cell, Library, Maintenance

Complaint: WiFi in Block C is very slow            → Department: Hostel
Complaint: My internal marks are not updated       → Department: Exam cell
Complaint: Library book return date is wrong       → Department: Library
Complaint: The projector in Room 204 is not working → Department:

→ Maintenance

Use 2–5 varied examples. If every example says "Hostel", it'll say "Hostel" for everything.

Chain-of-thought: think step by step 🧮

"I've attended 36 of 50 classes (72%). 20 classes are left. How many must I attend to reach 75%? Think step by step."

Total = 50 + 20 = 70  ·  75% of 70 = 52.5 → 53
Need 53 − 36 = 17 more classes

Writing the steps = more text to read before the answer = fewer mistakes. Reasoning models do this automatically.

System prompts: rules for the whole chat

SYSTEM: You are "CampusBuddy", helpdesk assistant for ABC Engineering College.
- Answer only questions about the college: exams, fees, hostel, library, placements.
- Under 80 words, simple English.
- If you don't know: "I'm not sure. Please contact office@abc.edu."
- Never share any student's personal details.

USER: Can you write my DBMS assignment for me?

"I can't write your assignment, but I can explain any DBMS topic you're stuck on. Which one?"

JSON output: when code reads the answer

Prompt

Extract name, course, city, wants_hostel (true/false). JSON only.

"Hi, I am Rahul from Mysuru. I want to join B.Tech CSE. Is hostel available?"

Answer

{"name": "Rahul", "course": "B.Tech CSE", "city": "Mysuru", "wants_hostel": true}

  • List fields + types · "JSON only" · temperature 0
  • Use the API's JSON mode · always check with json.loads()

Seven simple tips

  1. Be specific: length, audience, tone
  2. Say what to do
  3. Wrap data in """quotes"""
  4. Allow "I don't know"
  1. One job per prompt
  2. Iterate: write → test → fix
  3. Test with 5–10 real inputs

⚠️ Prompt injection: user text saying "Ignore all previous instructions..." More in Session 5.

Lab: weak vs strong (20 min) 🧪

TaskWeak promptMake it strong by adding...
Fest caption"Write about our college fest."Name, dates, audience, tone, length
Complaint routing"Which department is this for?"Label list + 3 examples + "name only"
Enquiry → JSON"Get the details from this email."Fields + types, JSON only, temp 0

Use any chat app, or the Colab notebook linked from the Session 2 notes page. Note: what was wrong, what you added, did it fix it?

Recap

  1. The prompt decides the answer
  2. Role · Task · Context · Examples · Format · Rules
  3. Zero-shot simple · Few-shot style · CoT logic
  4. System prompt = rules for the whole chat
  5. JSON when code reads the answer
  6. Write → test → fix → repeat

Quick quiz 🧠

  1. Zero-shot vs few-shot? No examples vs a few examples
  2. When do you add "think step by step"? Maths, logic, multi-step
  3. Who sees the system prompt? The developer, not the user
  4. Rewrite: "Explain OS." Audience + analogy + length + format

Up next · Session 3

Building with LLM APIs

Call a model from Python, stream the answer, count the cost, and build a chatbot with memory

Questions? 🙋