Module 2: Techniques in Prompting
prompting techniques or prompt patterns
- Zero-shot prompting
- Few-shot prompting
- Chain-of-thought prompting
- Instruction-style prompting
- Role prompting or persona-based prompting
Each technique gives the model better instructions, depending on what we want.
Zero-shot Prompting
In zero-shot prompting, we just ask the question or give the instruction without giving any examples.
Example:
Prompt: “Translate to Hindi: ‘How are you?’”
Output: “Aap kaise hain?”
Even though we did not show any examples, the model understood the task. This is useful when:
You want a quick result
You believe the model already knows how to do the task.
Few-shot Prompting
In few-shot prompting, we give the model a few examples before asking it to do something new. This helps it understand the pattern better.
```
Example:
Prompt: English: Hello
Hindi: Namaste
English: Thank you
Hindi: Dhanyavaad
English: Good morning
Hindi:
Output: Shubh prabhat
This method is useful when:
You want better accuracy
You’re not sure if the model knows the task
You can give 2–3 examples
Chain-of-Thought Prompting (CoT)
This is a special technique where we ask the model to think step-by-step.
Example:
Prompt:
I went to the market and bought 10 apples. I gave 2 apples to the neighbor and 2 to the repairman. I then went and bought 5 more apples and ate 1. How many apples did I remain with? Let’s think step by step.
Output:
First, you started with 10 apples. You gave away 2 apples to the neighbor and 2 to the repairman, so you had 6 apples left. Then you bought 5 more apples, so now you had 11 apples. Finally, you ate 1 apple, so you would remain with 10 apples.
Chain-of-thought helps in:
Math problems
Logical reasoning
Multi-step tasks
Instruction-style Prompting
Here, we give clear instructions in a natural language format. This is how ChatGPT and InstructGPT were trained.
Example:
Prompt:
“Write a short summary of the movie Inception in 2-3 lines using simple English.”
Output:
Inception is a sci-fi movie where people enter dreams. A team tries to plant an idea in someone’s mind through dreams.
Instruction-style prompts are useful for:
Summarization
Content creation
Rewriting tasks
Questions and answers
Role or Persona Prompting
In this type, we ask the model to act like someone. This helps set a context or tone.
Example:
Prompt:
“You are a nutritionist. Explain why breakfast is important to a 10-year-old.”
Output:
Breakfast gives your body energy after sleeping all night. It helps you focus in school and keeps you strong and healthy.