All lessons · 44
Prompting Techniques: Zero-shot, Few-shot, CoT, ReAct
The four core prompting techniques every AI engineer uses: zero-shot, few-shot, chain-of-thought and ReAct — with copyable prompts and when each one helps.
Four techniques, one idea
Every prompting technique answers the same question: what does the model need to see to produce the right answer? Sometimes nothing extra. Sometimes examples. Sometimes room to think. Sometimes tools.
Why bother learning four techniques instead of one? Because “it works” and “it works every time” are different things. Most prompting frustration is really one of four problems wearing a costume: wrong format (fix with examples), wrong answer (fix with reasoning), missing information (fix with tools), or no problem at all — in which case just ask plainly and stop over-engineering.
You will use all four in real projects, usually mixed together. Let’s go through them in order of complexity.
This is the short version
Four core techniques, enough to ship real features. Looking for a specific trick — Tree of Thoughts, self-consistency, step-back, automatic prompt engineering? The full catalog is in The Full Prompting Techniques Catalog. Read this one first; go there when a prompt “almost works” and you need a sharper tool.
Zero-shot: just ask
Zero-shot means asking the model to do a task with no examples at all — “zero examples”, hence the name. You are relying on everything it learned during training. For common, well-represented tasks — summarize, translate, classify sentiment, fix grammar — modern models handle this fine.
Classify the sentiment of this review as "positive",
"negative" or "neutral".
Review: "The battery lasts forever, but the app is a disaster."
Answer with one word.Use zero-shot when the task is simple and common. Reach for something stronger when you need a specific format or the task has unusual edge cases.
Few-shot: show examples
Few-shot prompting puts a handful of input/output examples right into the prompt (“a few examples” — usually two to five). The model imitates the pattern. This is the cheapest way to control format and edge cases — no fine-tuning (retraining the model on your own data), no training data pipeline, just text. (Examples are one of the six blocks in Prompt Anatomy; here we turn that block into a technique.)
Here is the difference in practice. Same classification task, first without examples:
Inconsistent: one label, then a four-word phrase. The model is guessing what style you want. Now with two examples:
Same model, same task — but now every answer is parseable. That is what few-shot buys you: consistency.
Copy this one and swap in your own labels:
Label each support ticket with exactly one label
from this list: billing, bug, how_to, refund, other.
Reply with the label only. No explanation.
Ticket: "App crashes when I upload a photo."
Label: bug
Ticket: "How do I change my password?"
Label: how_to
Ticket: "I was charged twice, please refund one."
Label: refund
Ticket: "Do you have a plan for teams of 20?"
Label:Two details make or break this: give the model a closed list of labels
(otherwise it invents new ones), and leave the final Label: empty so it
continues the pattern instead of summarizing it.
Chain-of-thought: let the model think
For math, logic, comparisons and multi-step decisions, forcing an instant answer hurts quality — the model has to commit to each word before it has “finished thinking”. Chain-of-thought (CoT) asks the model to reason step by step before answering: it writes out the intermediate steps, and each step becomes context that makes the next one easier.
The simplest version is one line:
A store sells notebooks in packs of 6 for 4 dollars
and in packs of 10 for 6 dollars. I need 50 notebooks.
What is the cheapest combination of packs, and what
does it cost?
Think step by step: first compute how many packs are
needed, then check if a bigger pack could be cheaper,
then give the final answer on the last line as
"Answer: ...".Two practical notes:
- Reasoning costs tokens. Turn CoT on for tasks that need it, not for “summarize this paragraph”.
- If you do not want the reasoning visible to users, ask the model to put the final answer in a structured field (for example as JSON) and show only that.
Modern reasoning models do much of this internally, but for standard models — and for seeing why an answer is wrong — explicit step-by-step prompting is still a tool you need.
ReAct: reason + act with tools
ReAct (Reason + Act) is CoT plus the ability to do things: the model thinks, calls a tool (a function it can ask your code to run — look up an order, fetch a price, search the web), observes the result, and repeats until it can answer. This is the loop underneath most AI agents.
A trace — the log of one such cycle — looks like this:
- Thought: I need today’s exchange rate for the total.
- Action: call tool
get_ratewith EUR to USD. - Observation: 1.09
- Thought: Now I can compute: 250 EUR is 272.50 USD.
- Answer: The order totals 272.50 USD.
The key mental shift: in ReAct the prompt is no longer one message — it is a cycle where the model’s output becomes a tool call, and the tool’s output becomes new input. We build these loops properly in What Are AI Agents? and wire up the tool calls themselves in Tools and Function Calling.
How to choose
Start zero-shot. Wrong format or sloppy edge cases? Add few-shot examples. Wrong reasoning? Add chain-of-thought. Task needs real-world data or actions? That is ReAct territory.
Check yourself
Your classifier keeps inventing new labels instead of using your five. Which technique fixes it, and how?
A task needs today's exchange rate. Which technique is required?
When is chain-of-thought a waste of money?
Prompts alone cannot give the model knowledge it does not have — your documents, your products, your users’ data. That is a different problem, and later in this roadmap we solve it with embeddings (how models turn meaning into numbers) and RAG.
And when one of these four is not enough, the full prompting catalog picks up where this article stops.
Questions?
Join the Telegram channel — happy to discuss techniques and share examples.