Chain-of-thought in practice
Now that you understand why chain-of-thought works, let us put it into practice. You will learn how to use thinking tags to separate reasoning from answers, and practice applying CoT to real problems where it makes the biggest difference.
For production use, combine CoT with XML tags to separate reasoning from the answer: "Solve this step by step. Put your reasoning in <thinking> tags and your final answer in <answer> tags." This gives you the best of both worlds: the model reasons thoroughly (improving accuracy), and you can parse just the <answer> for your application while keeping the <thinking> for debugging.
CoT helps most with math, logic, and multi-step reasoning. For simple factual lookups ("What is the capital of France?"), it adds unnecessary tokens without improving accuracy. The trade-off is cost: reasoning tokens increase response length and API costs. Use CoT when the task requires reasoning, skip it for simple retrieval.
AI prompt: Try it with AI
Loading practice…
Quiz: Quiz
Loading practice…
Ordering exercise: Chain-of-thought with tags
Loading practice…
Fill in the blanks: Add cot to a prompt
Loading practice…
Validation checklist: Chain-of-thought checklist
Loading practice…