Core Prompting Techniques
Module 04 — Core Prompting Techniques
Goal: Master the workhorse techniques every expert uses: zero-shot, few-shot, chain-of-thought, self-consistency, decomposition, and a few more. These are the “moves” you combine to solve almost any task.
4.1 Zero-shot prompting
Zero-shot = you ask the model to do a task with no examples, relying on its trained ability. “Zero” refers to zero examples provided.
Classify the sentiment of this review as Positive, Negative, or Neutral.
Review: "The food was cold and the waiter ignored us."
Sentiment:
Most everyday prompts are zero-shot. It works well for common tasks the model has seen often (summarizing, translating, basic classification, general writing).
When zero-shot struggles:
- Niche or custom tasks the model hasn’t internalized.
- Tasks needing a specific output format or labeling scheme.
- Subjective judgments where “good” depends on your taste.
When zero-shot output is inconsistent or off-target, the next tool is examples.
4.2 Few-shot prompting (the power tool)
Few-shot = you include a handful of example input→output pairs (“shots”) in the prompt to show the model exactly what you want. One example = “one-shot”; several = “few-shot.”
Why it works: the examples set a pattern, and the model — being a pattern-continuer — continues it. Showing is often far more effective than telling, especially for format and style.
Classify each support message by category: [Billing, Technical, Account, Other].
Message: "I was charged twice this month."
Category: Billing
Message: "The app crashes when I open settings."
Category: Technical
Message: "How do I change my email address?"
Category: Account
Message: "Your CEO seems nice."
Category: Other
Message: "My password reset link doesn't work."
Category:
The model will output Account or Technical following the demonstrated pattern and label set.
Tips for great few-shot prompts
- Use 2–5 examples to start; add more only if needed. More examples cost tokens and can hit limits.
- Make examples representative and diverse — cover the tricky and edge cases, not just easy ones. Include an example of the hard case you keep getting wrong.
- Keep formatting identical across examples (same labels, same layout). The model mimics format precisely.
- Watch label balance. If all your examples are “Positive,” the model may lean positive. Mix the classes.
- Order can matter, especially the last example (recency). If results skew, shuffle the examples.
- Examples teach format AND content style. Use them to lock in tone, length, and structure too — not just classification labels.
Few-shot for formatting/extraction
Few-shot shines when you need a precise output shape:
Extract the person's name and the company as JSON.
Input: "Hi, I'm Dana Lee from Northwind Traders."
Output: {"name": "Dana Lee", "company": "Northwind Traders"}
Input: "This is Raj at Globex calling."
Output: {"name": "Raj", "company": "Globex"}
Input: "Hello, Maria Gomez here, I work at Initech."
Output:
(We’ll make structured output far more reliable in Module 05.)
4.3 Chain-of-Thought (CoT): make the model think
For tasks involving reasoning — math, logic, multi-step decisions, word problems — asking for the answer directly often fails, because the model commits to an answer token before working it out. Chain-of-Thought prompting tells the model to reason step by step before answering. This dramatically improves accuracy on reasoning tasks.
The classic trigger phrase (zero-shot CoT):
Q: A store has 12 boxes. Each box has 8 apples. They sell 30 apples.
How many apples are left?
Let's think step by step.
The model will then write out: 12 × 8 = 96; 96 − 30 = 66; answer 66 — and get it right far more often than if you’d demanded just the number.
Why CoT works
The model “thinks by writing.” Each reasoning step becomes context that supports the next step, so the final answer is conditioned on actual worked-out logic instead of a guess. It mirrors how showing your work helps a student.
Few-shot CoT
You can combine: give examples that include the reasoning, not just the answer.
Q: Tom has 3 bags with 4 marbles each. He loses 2. How many remain?
A: 3 bags × 4 = 12 marbles. He loses 2, so 12 − 2 = 10. Answer: 10.
Q: A train travels 60 km in 1 hour. How far in 2.5 hours?
A: Speed is 60 km/h. In 2.5 hours: 60 × 2.5 = 150. Answer: 150 km.
Q: A recipe needs 200g flour per loaf. How much for 3 loaves?
A:
Practical CoT tips
- For user-facing apps you may want the reasoning hidden. Ask the model to reason internally and then output only the final answer, OR have it put reasoning in a section you strip out, OR put reasoning inside tags like
<scratchpad>…</scratchpad>followed by<answer>…</answer>and display only the answer. - Many modern “reasoning models” do this thinking automatically; explicit CoT helps most with standard models, but structured “think first” instructions still help everywhere.
- CoT trades tokens/latency for accuracy. Use it where correctness matters; skip it for trivial tasks.
4.4 Self-consistency: vote across multiple reasonings
An upgrade to CoT. Instead of one chain of reasoning, you generate several independent reasonings (using a higher temperature for variety) and take the majority answer. Different reasoning paths that converge on the same answer give you more confidence; outliers get out-voted.
(Run the same CoT prompt 5 times at temperature ~0.7)
-> answers: 66, 66, 64, 66, 66
-> majority vote: 66
It costs more (multiple runs) but meaningfully boosts accuracy on hard reasoning. Use it for high-stakes correctness; skip it when cost/latency matter more.
4.5 Decomposition: break big tasks into parts
Complex requests fail when crammed into one prompt. Decompose the task into smaller sub-tasks and tackle them in sequence — either within one prompt (numbered steps) or across multiple prompts (a chain, Module 07).
In-prompt decomposition:
Help me plan a 3-day Tokyo trip. Work through it in this order:
1. List 6 must-see areas with a one-line reason each.
2. Group them into 3 days minimizing travel time.
3. For each day, suggest a lunch and dinner spot near that day's area.
4. Finally, output a clean day-by-day itinerary.
By forcing structure, you get more complete, organized output and fewer skipped pieces. For very large tasks, full chaining (separate calls per step) is more reliable — covered in Module 07.
4.6 Role/expert prompting and “think like…”
Asking the model to adopt an expert lens improves relevant tasks:
Act as a senior security engineer reviewing this code. Identify the top 3
vulnerabilities, explain each in one sentence, and suggest a fix.
Combine with CoT for analysis tasks: “As an experienced editor, first note the 3 biggest weaknesses, then rewrite.”
4.7 Giving the model an “escape hatch”
To cut hallucination, explicitly permit non-answers and uncertainty:
Answer ONLY using the provided document. If the answer isn't in the document,
reply exactly: "Not found in the document."
If you are not confident, say "I'm not sure" rather than guessing.
This single habit prevents a huge fraction of confident-but-wrong outputs. Pair it with “let’s think step by step” for reasoning + honesty.
4.8 Prompting the model to ask YOU questions
For ambiguous tasks, flip the script:
Before writing the proposal, ask me up to 5 clarifying questions that would
most improve the result. Wait for my answers before drafting.
This turns a one-shot guess into a brief interview, dramatically improving output on under-specified tasks — and teaches you what context you forgot to include.
4.9 Output priming and partial completions
You can “prime” the format by starting the answer for the model:
List three benefits, then three risks.
Benefits:
1.
By providing the beginning (“Benefits:\n1.”), you nudge the model straight into the desired structure. Similarly, providing the opening of a JSON object ({"name":) pushes toward structured output (more in Module 05). Some APIs let you put this in an assistant turn to literally continue from it.
4.10 Iterative refinement and self-critique
Let the model improve its own work in stages:
Step 1: Draft a 100-word product description for [X].
Step 2: Now critique your draft: list 3 specific weaknesses.
Step 3: Rewrite it, fixing those weaknesses.
“Generate → critique → revise” loops often beat a single attempt. You can do this in one prompt (as above) or across turns. Caution: models aren’t perfect self-critics; an external check or eval (Module 09) is stronger for high stakes.
4.11 Choosing the right technique (quick decision guide)
| If your task is… | Reach for… |
|---|---|
| Common and simple | Zero-shot |
| Needs a specific format/label scheme/style | Few-shot examples |
| Involves math, logic, multi-step reasoning | Chain-of-Thought (“think step by step”) |
| High-stakes reasoning, must be right | Self-consistency (CoT × several, vote) |
| Large/complex, many parts | Decomposition / chaining (Module 07) |
| Prone to made-up facts | Escape hatch + “use only provided info” |
| Under-specified by the user | Have the model ask clarifying questions |
| First draft is mediocre | Generate → critique → revise |
These combine freely. A strong real-world prompt might be: a system persona (Module 03) + few-shot examples + “think step by step” + an escape hatch + a strict output format (Module 05).
Exercises
- Zero vs. few-shot. Invent a custom labeling task (e.g., tag emails as “Urgent / Can wait / Ignore”). Try zero-shot, then add 4 examples. Compare consistency on 5 new inputs.
- CoT proof. Find a tricky multi-step word problem. Ask for the answer directly, then ask again with “Let’s think step by step.” Compare correctness. Try 2–3 problems.
- Self-consistency by hand. Take one hard reasoning question. Run a CoT prompt 5 times at higher temperature. Tally the answers and take the majority. Did voting fix any wrong single runs?
- Decompose. Take a big task (“write a business plan for a food truck”) and rewrite it as a numbered 5-step in-prompt decomposition. Compare to a one-line version.
- Clarify first. Give the model a deliberately vague request and instruct it to ask 5 questions first. Notice how much better the final result is.
Key takeaways
- Zero-shot for simple/common tasks; few-shot (examples) to lock in format, labels, and style.
- Chain-of-Thought (“think step by step”) makes reasoning tasks far more accurate by letting the model work before it commits.
- Self-consistency (vote across multiple CoT runs) boosts hard-problem accuracy at extra cost.
- Decompose big tasks; give escape hatches to cut hallucination; let the model ask clarifying questions and self-critique.
- Real prompts combine several techniques.