LLMS & TRANSFORMERS · INTERVIEW QUESTION
What is chain-of-thought prompting? Why does it improve reasoning?
🟢 beginner · Prompt Engineering
Hint: Think about breaking complex problems into intermediate steps.
Answer
Chain-of-thought (CoT) prompting encourages the model to show intermediate reasoning steps before giving the final answer.
Example
Without CoT: "Q: 23 × 17 = ? A: 391"
With CoT: "Let me break this down: 23 × 17 = 23 × 10 + 23 × 7 = 230 + 161 = 391"
Why It Works
- Decomposes complex problems into simpler subproblems
- Allocates more computation per problem (more tokens = more thinking)
- Provides an inspectable explanation — useful for debugging, but a plausible trace need not faithfully describe the computation causing the answer
Variants
| Variant | Description |
|---|---|
| Zero-shot CoT | Just add "Let's think step by step" |
| Few-shot CoT | Provide examples with reasoning |
| Self-consistency | Sample multiple CoTs, majority vote |
| Tree-of-thought | Explore multiple reasoning branches |
python
# Zero-shot CoT
prompt = """Q: If a store has 23 items and 8 are sold, then 15 arrive, how many now?
A: Let's think step by step.
"""
response = model.generate(prompt)Benefits depend on model training, task and prompting; there is no universal parameter-count threshold for useful reasoning. Validate accuracy and cost on the target task.
Related questions
- Explain the self-attention mechanism in detail. What are Q, K, V and why do we use scaled dot-product attention?
- Explain positional encoding in Transformers. Compare sinusoidal, learned, RoPE, and ALiBi.
- Explain the difference between LoRA, full fine-tuning, and prompt tuning. When would you use each?
- Explain RLHF (Reinforcement Learning from Human Feedback). What are the key steps and challenges?
- Explain RAG (Retrieval-Augmented Generation). What are the key components and failure modes?