# Source: https://docs.helicone.ai/guides/prompt-engineering/use-chain-of-thought-prompting.md

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.helicone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Chain-of-Thought prompting

> By encouraging the model to generate intermediate reasoning steps before arriving at a final answer, you can achieve more accurate and insightful responses.

## What is Chain-of-Thought (CoT) prompting

Chain-of-Thought (CoT) prompting involves guiding the model to articulate a step-by-step reasoning process when answering a question or solving a problem. Instead of providing a direct answer, the model is encouraged to "think out loud," detailing the intermediate steps that lead to the final conclusion.

## How to implement Chain-of-Thought prompting

1. **Instruct the model to show its work.** Explicitly ask the model to provide step-by-step reasoning.
2. **Provide examples with reasoning steps.** Demonstrate the desired approach by including examples that show the reasoning process.
3. **Use prompts that encourage explanation.** Incorporate phrases that prompt the model to elaborate.
4. **Leverage few-shot learning with chain-of-thought.** Combine CoT prompting with few-shot learning by providing examples that include reasoning steps.

## Examples

<AccordionGroup>
  <Accordion title="Example 1: Mathematical Problem Solving.">
    By requesting a step-by-step solution, the model demonstrates the calculation process, reducing the chance of errors.

    **Prompt:**

    > Solve the following math problem step-by-step:
    >
    > If one book costs \$15 and you buy 4 books, how much do you spend in total?
    >
    > Answer:

    **Model's response:**

    > Each book costs \$15. If you buy 4 books, the total cost is \$15/book \* 4 books = \$60. So, you spend \$60 in total.
  </Accordion>

  <Accordion title="Example 2: Logical Reasoning.">
    The chain-of-thought reasoning clarifies the relationships, leading to the correct conclusion.

    **Prompt:**

    > Provide a detailed explanation to solve this logic puzzle:
    >
    > Tom, Sarah, and Bill are siblings. Tom is older than Sarah. Sarah is older than Bill. Who is the youngest?
    >
    > Answer:

    **Model's response:**

    > Tom is older than Sarah, and Sarah is older than Bill. This means Tom is the oldest, Sarah is in the middle, and Bill is the youngest. Therefore, Bill is the youngest.
  </Accordion>

  <Accordion title="Example 3: Decision Making.">
    The model walks through the decision-making process, providing justification for the recommendation.

    **Prompt:**

    > Help me decide whether to take an umbrella today. The weather forecast says there's a 60% chance of rain.
    >
    > Answer:

    **Model's response:**

    > A 60% chance of rain means it's more likely than not to rain. To stay dry, it's a good idea to take an umbrella. Therefore, you should take an umbrella today.
  </Accordion>
</AccordionGroup>

## Why use Chain-of-Thought prompting

* **Improves reasoning accuracy**: Helps the model handle complex queries by breaking them down into manageable steps.
* **Enhances transparency**: Provides insight into how the model arrives at an answer, which can be valuable for verification and trust.
* **Facilitates error detection**: Easier to identify and correct mistakes in the reasoning process.
* **Encourages detailed responses**: Generates richer and more informative outputs.

## Tips for effective Chain-of-Thought prompting

* Be explicit and direct in your request.
* Provide examples to demonstrate the process.
* Use open-ended questions to encourage elaboration.
* Maintain clarity and focus to avoid ambiguity.
* Limit the scope for complex topics.

***

<Accordion title="Need more help?">
  Additional questions or feedback? Reach out to
  [help@helicone.ai](mailto:help@helicone.ai) or [schedule a
  call](https://cal.com/team/helicone/helicone-discovery) with us.
</Accordion>