Few-Shot and Chain-of-Thought Techniques
Two of the most rigorously studied and consistently effective prompting techniques are few-shot learning — providing examples of input-output pairs to teach the model your specific pattern — and chain-of-thought prompting — instructing the model to reason step by step before reaching a conclusion. Mastering both techniques, and knowing when to apply each, is foundational to expert-level prompt engineering.
Zero-Shot, Few-Shot, and Many-Shot
The "shots" terminology refers to the number of examples included in the prompt. Zero-shot prompting provides no examples — just an instruction and an input. Few-shot provides a small number of input-output examples (typically 2-5) that illustrate the pattern. Many-shot provides a larger set of examples (10, 20, or more) to increase reliability and cover more variation.
Zero-shot works well for tasks that are common and well-represented in the model's training data. Standard summarization, translation, and basic classification all perform adequately zero-shot. When the task is novel, specialized, or requires a specific format the model has not seen frequently, few-shot is dramatically more reliable.
The mechanism is clear: examples communicate requirements that are difficult to specify in abstract language. If you want the model to classify support tickets into five specific categories using a particular naming convention, you can write a paragraph describing the criteria — or you can show three examples. The examples are almost always more reliable because they eliminate the gap between your description and the model's interpretation of it.
Examples are the most compact and unambiguous way to communicate a pattern. A single well-chosen example conveys format, style, level of detail, vocabulary, and reasoning approach simultaneously. Three examples can convey variation and boundary cases that would take paragraphs to specify abstractly — and convey them more reliably.
Choosing Good Few-Shot Examples
The quality of your examples matters as much as their quantity. Poor examples teach the wrong pattern or create confounds that mislead the model.
Few-Shot Prompt Structure
A standard few-shot prompt has a clear structure: an instruction, followed by labeled examples, followed by the actual input to process.
The structure cues the model to continue the pattern. Note the final "Output:" with nothing after it — this invites the model to complete the pattern with a classification. The model has three examples establishing the format and three category mappings to generalize from.
Chain-of-Thought Prompting
Chain-of-thought (CoT) prompting is the technique of instructing the model to show its reasoning step by step before producing a final answer. The seminal finding from research is simple and powerful: when models are prompted to think through a problem explicitly, their accuracy on multi-step reasoning tasks improves dramatically compared to prompting for a direct answer.
The most basic version is the phrase "Let's think step by step" appended to a question. This simple addition consistently improves performance on arithmetic, logic, and multi-step reasoning tasks. The reason is intuitive: generating an intermediate reasoning trace forces the model to "commit" to a chain of inferences that is then visible and correctable, rather than jumping directly to a prediction that may be superficially plausible but logically flawed.
Prompt: "A store is selling notebooks for $3.50 each. A customer buys 4 notebooks and pays with a $20 bill. How much change do they receive? Think through this step by step before giving the final answer."
Output: "Step 1: Calculate the total cost. 4 notebooks x $3.50 each = $14.00. Step 2: Calculate the change. $20.00 - $14.00 = $6.00. The customer receives $6.00 in change."
Without the CoT instruction, the model often gives the right answer — but on harder problems, forcing explicit intermediate steps substantially reduces errors and makes reasoning auditable.
Few-Shot Chain-of-Thought
The most powerful version of CoT prompting combines it with few-shot examples: you provide examples that include not just the input and final answer, but the complete reasoning chain in between. This teaches the model both the format of the reasoning trace and the type of reasoning you expect.
This few-shot CoT structure reliably produces step-by-step reasoning for new problems. The examples establish the exact format of the reasoning trace you want — the vocabulary, the level of detail, the way intermediate results are stated.
Self-Consistency: Sampling Multiple Reasoning Paths
A powerful extension of chain-of-thought is self-consistency: generating multiple independent reasoning chains for the same problem and then selecting the most common answer. The intuition is that even if any individual chain can go wrong, the correct answer is likely to appear most frequently across multiple independent attempts.
In practice, you implement self-consistency by running the same CoT prompt multiple times (with temperature above 0 to introduce variation), extracting the final answers, and taking the majority vote. Research consistently shows that self-consistency improves accuracy over single-chain CoT, particularly for complex reasoning tasks. For high-stakes applications where reliability matters more than cost, this technique is worth the additional API calls.
Chain-of-thought is most valuable for tasks that require multi-step reasoning: mathematical problems, logical deduction, multi-criteria evaluation, planning. It is less valuable for straightforward factual retrieval or simple classification where the answer does not depend on intermediate steps. Forcing CoT on simple tasks adds tokens without improving quality and can sometimes hurt performance by introducing unnecessary complexity.
Zero-Shot CoT: The Magic Phrase
For situations where you cannot provide examples, zero-shot CoT — adding "Let's think step by step" or "Think through this carefully before answering" — still provides meaningful improvement on reasoning tasks. Research has found several effective zero-shot CoT triggers:
- "Let's think step by step."
- "Think through this carefully and show your reasoning."
- "Before answering, work through the problem systematically."
- "Reason through each part of this problem before giving a final answer."
The exact phrasing matters less than the principle: instructing the model to produce intermediate reasoning steps before committing to a final answer. The instruction to reason explicitly is more important than the specific words used to convey it.
Combining Few-Shot and Role Assignment
Few-shot and role assignment are complementary. Role assignment sets the analytical frame; few-shot examples calibrate the specific output format and style within that frame. A prompt that combines both has a role instruction establishing who the model is, followed by examples showing how that role approaches this specific task type, followed by the actual input. This layering produces the most consistently high-quality outputs for complex, specialized tasks.