Frodex

Frodex

Beta
EnglishPortuguês (BR)
Foundations
1Introduction2Tokens3Controlling the Model
Communicating with LLMs
4Anatomy of a Good Prompt5System Prompts and Personas6Few-Shot Learning
Structured Outputs
7JSON Mode and Structured Output8Function Calling
Advanced Techniques
9Chain of Thought Reasoning10Managing the Context Window11Embeddings and Semantic Search
Production Systems
12Retrieval-Augmented Generation (RAG)13Streaming Responses14Evaluation and Cost Optimization
Frodex

Frodex

Beta
EnglishPortuguês (BR)
Foundations
1Introduction2Tokens3Controlling the Model
Communicating with LLMs
4Anatomy of a Good Prompt5System Prompts and Personas6Few-Shot Learning
Structured Outputs
7JSON Mode and Structured Output8Function Calling
Advanced Techniques
9Chain of Thought Reasoning10Managing the Context Window11Embeddings and Semantic Search
Production Systems
12Retrieval-Augmented Generation (RAG)13Streaming Responses14Evaluation and Cost Optimization
Advanced Techniques
15 minLesson 9 of 14

Chain of Thought Reasoning

Improve complex reasoning with step-by-step thinking for real-world decision making

Learning goals

  • •Understand chain of thought (CoT) prompting
  • •Learn when CoT improves results
  • •Implement various CoT techniques

What Is Chain of Thought?

Chain of Thought prompting encourages the model to show its reasoning process step by step, rather than jumping directly to an answer.

Without CoT: Q: If a shirt costs $25 and is 20% off, what's the final price? A: $20

With CoT: Q: If a shirt costs $25 and is 20% off, what's the final price? Think step by step. A: Let me work through this: 1. Original price: $25 2. Discount: 20% of $25 = $5 3. Final price: $25 - $5 = $20

Why CoT Works

Chain of thought improves accuracy by:

  • Decomposing complex problems into smaller steps
  • Reducing errors in multi-step reasoning
  • Making the reasoning process auditable
  • Catching mistakes before the final answer
  • Math problems
  • Logic puzzles
  • Multi-step analysis
  • Complex decision-making

CoT Techniques

Zero-Shot CoT Simply add "Think step by step" or "Let's work through this" to your prompt.

Few-Shot CoT Provide examples that demonstrate step-by-step reasoning.

Self-Consistency Generate multiple CoT paths and take the majority answer.

Tree of Thoughts Explore multiple reasoning branches and evaluate each.

Common mistakes

×Using CoT for simple tasks—adds latency and cost without benefit
×Not verifying the reasoning—CoT steps can still contain errors
×Skipping CoT for math—most math problems benefit from explicit steps
×Ignoring the reasoning—the steps often reveal when the model is uncertain

Key takeaways

+Chain of thought prompting improves accuracy on complex reasoning tasks
+Simply adding 'think step by step' can significantly improve results
+CoT makes reasoning auditable—you can check each step
+Use CoT for math, logic, and multi-step analysis

Playground

Try These Experiments

Prompt

Why This Experiment?

Run the same tiny problems with and without “think step by step” and compare the reasoning.

Response
No response yet
Choose an experiment above or type your own prompt, then click Run to see the model's response here.

A very small multi-step calculation that the model might still fumble when answering directly.