Chain of Thought Prompting: Eliciting LLM Reasoning
"Language models are few-shot learners, but they are also few-shot reasoners if prompted correctly." – Wei et al., 2022. By forcing models to generate intermediate steps, we drastically reduce hallucinations.
The Problem: Single Pass Computation
Large Language Models (LLMs) operate fundamentally by predicting the next token. If you ask a complex mathematical or logical question in a Standard Prompt, the LLM attempts to output the final answer immediately. Because it hasn't mapped out the state changes, it often hallucinates the result.
Zero-Shot Chain of Thought
Discovered by Kojima et al. (2022), simply appending the trigger phrase "Let's think step by step" to your prompt dramatically improves performance. This forces the model to generate a reasoning trace, acting as a "scratchpad" memory before generating the final answer.
Few-Shot Chain of Thought
While Zero-Shot is great, Few-Shot CoT is significantly more reliable for production applications. Here, you provide the LLM with 2 to 5 examples of how you want it to reason.
Format:
Q: [Example Question]
A: [Example Step-by-Step Reasoning] Therefore, the answer is [X].
Q: [Target Question]
A:
❓ Generative AI Prompting FAQ
What is the difference between Zero-Shot and Few-Shot Prompting?
Zero-Shot: You give the LLM a task without any examples. E.g., "Translate this to French: Hello".
Few-Shot: You provide examples of the input-output mapping within the prompt context before asking the target question. This aligns the model to your specific format and style.
Why does Chain of Thought (CoT) Prompting reduce LLM hallucinations?
LLMs generate output token by token. In a standard prompt, the model must calculate the entire answer in a single forward pass. CoT forces the generation of a reasoning trace (intermediate steps). This allows the model to condition its final answer on its own previously generated logical steps, allocating more compute (tokens) to the problem.
How do I structure a Few-Shot Chain of Thought prompt?
1. System Persona: Define the role (e.g., "You are an expert mathematician").
2. Examples (The Few-Shots): Provide Q&A pairs where the 'A' includes the step-by-step reasoning leading to the final answer.
3. Target Input: Provide the actual question followed by the trigger (e.g., "A: Let's think step by step").