Day 3: Prompting Techniques in AI (Part 1)
Source: Dev.to

AI Prompting techniques: Zero-shot, One-shot, Few-shot
After using ChatGPT and other AI tools, I used to think prompts were just simple text inputs that AI models magically processed. As mentioned in my Day 1 post, AI models are 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 a response from an AI model:
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: the role key has three possible 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 of how the 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 prompts for your own AI product.
Links