Day 5 – Prompt Engineering
Table of Contents
What is Prompt Engineering?
Prompt Engineering is the skill of writing clear instructions for an AI model.
The instructions you give to an AI are called prompts.
Think of AI like a very smart assistant. If you give confusing instructions, you may get confusing results. If you give clear instructions, you usually get better results.
Simple Example
Weak Prompt
Tell me about dogs.
The AI may give a very general answer.
Better Prompt
Explain dogs to an 11-year-old student in 5 simple points.
The AI now knows:
- Who the audience is
- How much detail to give
- How to format the answer
Why Prompt Engineering is Important
Prompt Engineering helps us:
- Get better answers
- Save time
- Generate useful content
- Build AI applications
- Create chatbots and assistants
Lecture 1 Topics
Role Prompting
Role Prompting means telling the AI who it should act like. This helps the AI understand the style and expertise needed.
Example 1
Act as a science teacher and explain gravity.
The AI will respond like a teacher.
Example 2
Act as a doctor and explain why exercise is important.
Example 3
Act as a chef and suggest a healthy breakfast.
Why Role Prompting Works
It gives AI a specific identity. This helps the AI:
- Choose the right tone
- Use appropriate knowledge
- Give more focused answers
Structured Prompting
Structured Prompting means organizing instructions clearly. Instead of asking randomly, we provide details.
Basic Structure
Role
Task
Audience
Output Format
Example
You are a teacher.
Explain the solar system.
Audience: 11-year-old students.
Format:
1. Simple language
2. Five points
3. One example
Comparison
| Type | Prompt |
|---|---|
| Unstructured | Tell me about planets. |
| Structured | You are a science teacher. Explain planets to a class 6 student. Use: Simple language, Five points, One example |
The second prompt usually gives a better answer.
Lecture 2 Topics
Improving AI Responses
You can improve AI responses by giving better instructions.
Tips for Better Prompts
- Be Specific
Bad: Write a story.
Good: Write a 200-word story about a brave village boy who saves his farm. - Define the Audience
Bad: Explain AI.
Good: Explain AI to an 11-year-old student using simple language. - Specify Format
Bad: Tell me about India.
Good: Tell me about India in 5 bullet points. - Give Examples
Example: Translate English to Hindi. Example: Hello = Namaste. Now translate: Good Morning
Examples often improve results.
Temperature Basics
Temperature controls creativity in AI responses. Think of it as a creativity level.
| Temperature | Result | Useful For |
|---|---|---|
| Low = 0.2 | More accurate, More consistent, Less creative | Coding, Mathematics, Facts |
| High = 1.0 | More creative, More varied, Sometimes less predictable | Stories, Poetry, Brainstorming |
Easy Analogy
Imagine asking students to draw a tree.
Low temperature: Most students draw similar trees.
High temperature: Students draw many different and creative trees.
Token Basics
A token is a small piece of text processed by AI. Tokens can be words, parts of words, or punctuation.
Example
Sentence: I love Python. May be broken into several tokens.
Warning!
More tokens mean longer answers, more processing, and higher API usage cost. Many AI platforms charge based on tokens.
Real-Life Example
If an AI model allows 1000 tokens, the response length is limited to roughly that amount.
Simple Summary
| Topic | Meaning |
|---|---|
| Prompt | Instruction given to AI |
| Prompt Engineering | Writing better AI instructions |
| Role Prompting | Giving AI a role |
| Structured Prompting | Organizing instructions clearly |
| Temperature | Controls creativity |
| Token | Small unit of text used by AI |
Daily Assignment
Assignment 1: Create 5 Different Prompts
- Explain cricket to a child.
- Act as a doctor and explain healthy eating.
- Write a short story about a farmer.
- Summarize a news article in 5 points.
- Create a study plan for exams.
Assignment 2: Compare Outputs
Choose one topic. Example:
Tell me about space.
Then improve it:
You are a science teacher.
Explain space to an 11-year-old student.
Use simple language and 5 bullet points.
Compare both outputs and write which one is better.
Assignment 3: Create a Chatbot Personality Prompt
Example:
You are StudyBot.
You are a friendly tutor for school students.
Rules:
- Use simple language.
- Be polite.
- Give examples.
- Encourage learning.
Try creating your own chatbot personality.
Homework
- What is a prompt?
- What is Prompt Engineering?
- What is Role Prompting?
- What is Structured Prompting?
- What does temperature control?
- What is a token?
- Why are good prompts important?
