Covers the techniques that make models more reliable on harder tasks: zero-shot, few-shot and chain-of-thought prompting, self-consistency, prompt chaining and the ReAct pattern behind AI agents, with the published research results behind each.
7.1 Zero-shot prompting
In zero-shot prompting the model is given a task with no examples. It relies entirely on what it learned in training.
Classify the sentiment of this review as Positive, Negative or Neutral.
Review: "The delivery was quick but the packaging was damaged."
Sentiment:
Zero-shot works well for common tasks the model has seen many times: summarising, translating, simple classification. It is the fastest to write and uses the fewest tokens.
7.2 One-shot and few-shot prompting
In few-shot prompting the prompt includes a small number of solved examples (called demonstrations or "shots") before the new case. One-shot means exactly one example. The model copies the pattern, format and labelling style.
The GPT-3 paper (Brown et al., 2020), titled Language Models are Few-Shot Learners, showed that large models can learn a task from a handful of examples in the prompt, with no retraining. This is called in-context learning.
Example: classifying customer emails for a bank
Classify each email into: Card, Loan, Account, Complaint.
Email: "My debit card was swallowed by the ATM at MG Road."
Category: Card
Email: "What is the interest rate for a two-wheeler loan?"
Category: Loan
Email: "Your branch staff were rude and made me wait two hours."
Category: Complaint
Email: "Please update my registered mobile number."
Category:
The model answers "Account" and keeps the one-word format.
Tips for good examples
- Cover each category at least once, and include the tricky borderline cases.
- Keep the format identical across examples.
- Mix the order of labels so the model does not just copy the last one.
- Use realistic examples from the actual domain.
| Technique | Examples given | Strengths | Weaknesses |
|---|---|---|---|
| Zero-shot | 0 | Quick, cheap, flexible | Output format and labels may vary |
| One-shot | 1 | Fixes the format | One example may bias the model |
| Few-shot | Usually 2–10 | Consistent format; handles custom labels and styles | Longer prompts cost more tokens; examples must be chosen carefully |
7.3 Chain-of-thought (CoT) prompting
Chain-of-thought prompting asks the model to write out its intermediate reasoning steps before the final answer. Wei and colleagues at Google (2022) showed that adding worked examples with step-by-step reasoning to a prompt sharply improves performance on arithmetic, common-sense and symbolic reasoning tasks in large models.
Few-shot CoT example
Q: A shop had 23 pens. It sold 9 and then received a box of 12. How many pens now?
A: Start with 23. After selling 9: 23 − 9 = 14. After receiving 12: 14 + 12 = 26. The answer is 26.
Q: A canteen made 120 samosas. Morning sales were 45, afternoon sales were twice the morning sales. How many are left?
A:
The model follows the pattern: morning 45, afternoon 2 × 45 = 90, total sold 135. Since 135 > 120, the data is inconsistent, so it should flag that it cannot be right. Writing out steps makes such errors visible.
Zero-shot CoT. Kojima and colleagues (2022) found that simply adding the phrase "Let's think step by step" to a question, with no examples, also improves reasoning. With the InstructGPT model text-davinci-002, accuracy on the MultiArith benchmark rose from 17.7% to 78.7%, and on GSM8K from 10.4% to 40.7%.
When to use CoT
- Multi-step arithmetic, word problems and financial calculations.
- Logical puzzles, scheduling and planning.
- Decisions with several factors to weigh.
- Debugging, where tracing the code line by line helps.
When not to use it: simple lookups, short translations or creative writing, where steps add length but not quality.
Note on newer models. Many recent models have built-in "reasoning" or "thinking" modes that work through steps internally before answering. With these, an explicit "think step by step" adds less, but asking the model to show its working is still useful when you need to check the logic.
7.4 Self-consistency
A single chain of reasoning can go wrong. Self-consistency (Wang et al., 2022) samples several different reasoning chains for the same question, then takes the most common final answer, a majority vote. On the GSM8K maths benchmark this improved accuracy by 17.9 percentage points over ordinary chain-of-thought prompting.
In practice a user can approximate it: ask the same question three to five times in fresh chats, or ask the model to "solve this in three different ways and compare the answers."
7.5 Prompt chaining
Prompt chaining splits a large task into a sequence of smaller prompts, where the output of one step becomes the input of the next.
Example: writing a market report
- Prompt 1: "List the five key trends in India's electric two-wheeler market from the attached articles."
- Prompt 2: "For each trend, give one supporting data point from the articles, with source."
- Prompt 3: "Write a 400-word executive summary using only the trends and data above."
- Prompt 4: "Review the summary for any claim not supported by the data in step 2."
Each step is simpler, easier to check and easier to fix than one giant prompt.
7.6 ReAct: reasoning and acting (introductory)
ReAct (Yao et al., 2022) interleaves reasoning with actions such as a web search or calculator call. The model writes a thought, takes an action, reads the result (observation), and repeats. This pattern underlies today's AI agents that browse the web or use tools.
Thought: I need the current repo rate to answer.
Action: Search["RBI repo rate"]
Observation: [search result]
Thought: Now I can compute the EMI change.
Action: Calculate[...]
7.7 Worked numericals
Numerical 7.1: Chain-of-thought on a business problem.
Prompt: "A trader buys 50 kg of rice at ₹42/kg and 30 kg at ₹48/kg, and sells the mixture at ₹50/kg. Find the profit percentage. Let's think step by step."
Expected reasoning:
Without step-by-step reasoning, a model may average the two prices (₹45) and get 11.1%, which is wrong because the quantities are unequal.
Numerical 7.2: Why majority voting helps (self-consistency).
Suppose each independent reasoning chain gives the correct answer with probability 0.6, and the wrong chains do not agree with each other. With five chains, the majority (3 or more) is correct with probability:
Voting raises accuracy from 60% to about 68%. In reality chains are not fully independent, so the gain is smaller, but the direction holds.
Numerical 7.3: Token cost of few-shot prompting.
A classification prompt has 60 tokens of instructions and 40 tokens for the new item. Each example adds 50 tokens. For 10,000 items a day, how many extra input tokens does 5-shot add compared with zero-shot?
The zero-shot prompt is 100 tokens; the 5-shot prompt is 350, so 3.5 times the input cost. The extra cost is worth paying only if accuracy improves enough. Many platforms offer cheaper "cached" input for repeated prompt parts, which reduces this cost.
7.8 Industry use cases
- Customer email routing. Banks, telecom companies and e-commerce firms use few-shot prompts with their own category labels to sort incoming messages, because the labels (for example "KYC update" or "EMI bounce") are specific to the company.
- Financial analysis. Analysts use chain-of-thought prompts for multi-step calculations such as loan EMIs and ratio analysis, and ask the model to show working so a person can check it.
- AI agents. The ReAct pattern of thought, action and observation underlies agent features that research the web, fill forms or run code, such as ChatGPT's agent mode and coding agents in GitHub Copilot.
7.9 Review questions
- Distinguish zero-shot, one-shot and few-shot prompting with examples from HR.
- What did Brown et al. (2020) mean by "in-context learning"?
- Explain chain-of-thought prompting. Quote the results reported by Kojima et al. (2022) for zero-shot CoT.
- How does self-consistency improve reliability? What is its cost?
- Design a four-step prompt chain to write a product launch press release.
- A trader mixes 40 kg of dal at ₹90/kg with 60 kg at ₹110/kg and sells at ₹115/kg. Find the profit percentage, showing steps. (Answer: cost ₹10,200, revenue ₹11,500, profit ₹1,300, about 12.75%.)
- In Numerical 7.2, recompute the majority-vote accuracy if each chain is correct with probability 0.7. (Answer: about 0.837.)
Knowledge sources
- Brown, T. et al., Language Models are Few-Shot Learners, NeurIPS 2020.
- Wei, J. et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, NeurIPS 2022.
- Kojima, T. et al., Large Language Models are Zero-Shot Reasoners, NeurIPS 2022.
- Wang, X. et al., Self-Consistency Improves Chain of Thought Reasoning in Language Models, ICLR 2023.
- Yao, S. et al., ReAct: Synergizing Reasoning and Acting in Language Models, ICLR 2023.
- Schulhoff, S. et al., The Prompt Report: A Systematic Survey of Prompting Techniques, 2024.
Independent study notes for learning purposes. Not affiliated with any university or course provider. Facts and case-study figures are linked to their original sources. ChatGPT, Gemini, Copilot, Jasper, Synthesia, Runway, Lumen5 and other product names are trademarks of their respective owners.