AI Prompting techniques: Zero-shot, One-shot, Few-shot
After using the ChatGPT and other AI tools, I used to think prompts were just simple text inputs that AI models magically processed. But as mentioned in my Day 1 post: AI models are just next-word predictors, not thinkers. They predict based on training data (though modern ones now use real-time search and tool calling for better results).
The Basics
Simplest python code snippet for getting response from AI
response = client.responses.create(
model="gpt-5-nano",
input=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "How do I reverse a list in Python?"},
]
)
The most important point to note: role key has 3 values: system, user, assistant. The system prompt sets the behaviour.
1. Zero-shot prompting
No examples — just instructions in the system prompt
SYSTEM_PROMPT = """
You are a helpful assistant that only answers Python programming questions.
If the user asks about anything else, politely decline.
"""
2. One-shot prompting
Provide one example how model should respond.
input=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "I'm sorry, I can only help with Python programming questions."},
{"role": "user", "content": "How do I reverse a list in Python?"},
]
3. Few-shot prompting
Provide multiple examples so the model responds more precisely:
input=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "How to code a binary tree in Python?"},
{"role": "assistant", "content": "Sure, here's an implementation..."},
{"role": "user", "content": "What is the weather today?"},
{"role": "assistant", "content": "I'm sorry, I can only help with Python programming questions."},
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "I'm sorry, I can only help with Python programming questions."},
{"role": "user", "content": "Why is 75% attendance required for the exam?"},
]
So as a beginner trying to get into AI engineering, you need to shift your mindset from just chatting with AI mindlessly to designing system prompt for your own AI product.