Part 2.3: Prompting Techniques
Learn how to apply zero-shot, few-shot, and chain-of-thought prompting to get better responses from LLMs — with concrete examples, formats, and tips for real-world use.
Prompting isn't one-size-fits-all. Depending on the complexity of your task and the kind of response you want, you'll need different strategies to guide the model. In this guide, we break down the three core prompting techniques — zero-shot, few-shot, and chain-of-thought — and show how to use them to get better, more consistent output from large language models (LLMs).
Why Prompting Techniques Matter
Not all tasks are equal — and neither are all prompts. Some tasks require deep reasoning. Others rely on clear examples. The prompt that works for generating a product summary might fail at solving a math problem. That's why different prompting techniques exist.
Modern language models can perform surprisingly well with minimal instruction, but to get consistently useful results, you need to understand how to guide the model. Prompting techniques help you do just that — by shaping the structure, clarity, and reasoning path the model uses to generate answers.
In this section, we'll walk through three foundational techniques you'll use often:
- Zero-shot prompting – Ask a question or give an instruction without any examples.
- Few-shot prompting – Show the model a few examples to help it learn in context.
- Chain-of-thought prompting – Encourage the model to reason step-by-step.
Each has its strengths. Each works best in different situations. Learning when and how to use them is a core skill in prompt engineering.
Zero-shot Prompting
Zero-shot prompting is the simplest — and most widely supported — technique. You give the model an instruction or question without any examples, and expect it to perform the task based on its pretraining alone.
This is the default mode for many users. It's fast, token-efficient, and surprisingly powerful on general tasks.
✅ When It Works Best:
- Simple tasks like classification, summarization, Q&A, or formatting
- Situations where model size and training give it enough knowledge
- Tasks with clearly worded, specific instructions
📌 Example 1: Classification
Prompt:
Classify the sentiment of the following review as Positive, Negative, or Neutral:
"I absolutely loved the experience — everything was smooth and delightful."
Output:
Positive
📌 Example 2: Text Transformation
Prompt:
Convert the following sentence to active voice:
"The report was submitted by the intern."
Output:
"The intern submitted the report."
💡 Pro Tip: Zero-shot prompting relies on precise instructions. If your output is vague or inconsistent, revise your wording — not necessarily your technique.
As LLMs get larger and more instruction-tuned, their zero-shot performance continues to improve. But when your task is nuanced, ambiguous, or domain-specific, you might want to level up to few-shot prompting.
Few-shot Prompting
Few-shot prompting provides the model with examples before asking it to perform a task. These examples demonstrate the format, tone, or pattern you want the model to follow — helping it generalize better to your actual prompt.
This approach is especially powerful when zero-shot doesn't quite work, or when you're trying to guide the model toward a specific output format or domain behavior.
✅ When It Works Best:
- Tasks with specialized formats or domain-specific knowledge
- When consistency or structure is important
- To steer model behavior with clear demonstrations
📌 Example: Sentiment Classification
Prompt:
Text: I love this product! // Sentiment: Positive
Text: It broke on the first day. // Sentiment: Negative
Text: It’s okay I guess. // Sentiment: Neutral
Text: Worst customer service ever. // Sentiment:
The model sees a few examples and learns to continue the pattern. This is known as in-context learning, and it works surprisingly well across many domains.
💡 Pro Tip: Use examples that are diverse but consistent in structure. Put your most representative examples first. When possible, format them cleanly using separators or labels. Be mindful of token limits — include just enough examples to teach the pattern without overwhelming the model.
Some tools like LangChain and Guidance support advanced few-shot
setups using ExampleSelectors — dynamically picking
examples based on semantic similarity. But for many practical
uses, even static 2–3-shot prompts make a big difference.
Chain-of-Thought (CoT) Prompting
Some tasks — like solving math problems, making decisions, or explaining reasoning — benefit from more than just an answer. They require the model to think through intermediate steps before arriving at a conclusion.
That’s where Chain-of-Thought prompting shines. By encouraging the model to "think step by step," you unlock more accurate, interpretable, and consistent reasoning.
🧠 Why It Works
Language models are trained on patterns of human reasoning, including explanations and step-by-step breakdowns. When you explicitly ask the model to show its work, it can tap into those patterns more reliably than when asked to jump straight to the answer.
🔍 Simple Example
Prompt:
Q: If Alice has 3 apples and gives 1 to Bob, how many does she have left?
A: Let's think step by step.
Step 1: Alice starts with 3 apples.
Step 2: She gives 1 apple to Bob.
Answer: Alice has 2 apples left.
❌ Without CoT vs ✅ With CoT
❌ Prompt:
How many prime numbers are between 1 and 10?
Output: 4
✅ Prompt:
How many prime numbers are between 1 and 10?
Let's think step by step.
Step 1: List the numbers from 1 to 10.
Step 2: Identify the primes: 2, 3, 5, 7.
Step 3: Count them: 4.
Answer: 4
Even though both reach the same answer, the second response is easier to verify — and more likely to be accurate on harder tasks.
✅ When It Works Best
- Multi-step reasoning problems (math, logic, analysis)
- When you want transparency in how the answer was derived
- To improve accuracy on hard or ambiguous questions
💡 Pro Tip: Use explicit phrases like“Let's think step by step”,“First...”, or“Step 1:”to encourage detailed reasoning. CoT often improves performance — especially on models trained with reasoning-heavy data (e.g., GPT-4 or Claude).
Some advanced users combine CoT with few-shot prompting — providing multiple reasoning examples — or use techniques like self-consistency (sampling multiple CoT responses and choosing the most common answer). We’ll explore those in a future section.
Choosing the Right Prompting Technique
With all these prompting styles in your toolkit — zero-shot, few-shot, and chain-of-thought — the key is knowing which one to reach for, and when.
📊 Quick Guide
- Zero-shot: Best for straightforward tasks where the model is already trained to perform well (e.g., answering factual questions, rephrasing text).
- Few-shot: Use when task formatting is unusual or domain-specific, or when output consistency is critical (e.g., sentiment classification, email tone matching).
- Chain-of-thought: Ideal for reasoning-heavy tasks, math problems, multi-step logic, or when you want to “show the work.”
When in doubt, start simple — try zero-shot first. If results are vague or inconsistent, add examples (few-shot) or step-by-step thinking (CoT).
💡 Pro Tip: Prompt engineering is an iterative process. Experiment with different techniques, tweak instructions, and observe how the model changes its behavior. Don’t be afraid to mix styles — e.g., use few-shot with CoT for the best of both worlds.
In later parts of this series, we’ll go deeper into advanced prompting strategies like self-consistency, tool use, meta-prompting, and ReAct-style planning. For now, you’ve built a solid foundation in three of the most powerful techniques available.