# Chain Of Thoughts

Chain-of-Thought (CoT) prompting has been making waves in the world of large language models (LLMs) by encouraging users to reason out their answers step-by-step. While standard prompts simply ask for an output, CoT prompts guide the model through a series of intermediate reasoning steps, mimicking the thought process of a human solving a problem. This opens up exciting possibilities for improving:

Accuracy: By breaking down complex tasks into smaller, sequential steps, CoT allows the model to check its logic at each stage, reducing the risk of errors and misinterpretations.

Transparency: With CoT, you can see the model's internal reasoning, making it easier to understand how it arrived at its conclusion. This is crucial for building trust and ensuring that the model is not simply parroting back its training data.

Versatility: CoT is not limited to specific tasks or formats. It can be applied to anything requiring multi-step reasoning, from solving math problems to writing creative content.

Here's how CoT works:

Identify the task: Clearly define the problem or question you want the LLM to address.

Break it down: Deconstruct the task into a series of logical steps, each leading closer to the final answer. Aim for small, manageable steps that the model can easily understand and process.

Craft the chain: Write prompts for each step, explaining what the model needs to do at that stage. Use clear language and logical flow to guide the reasoning process.

Example-based learning (optional): For complex tasks, provide a few examples of complete CoT chains to demonstrate the desired way of thinking. This helps the model understand the overall structure and approach.

Run the prompt: Feed the complete CoT prompt to the LLM and analyze the output. Pay attention to how the model follows the specified steps and whether its reasoning aligns with your expectations.

Examples of CoT prompts:

Solving a math word problem:

Step 1: Read the problem carefully and identify the key information.

Step 2: Define the variables involved and write down the relevant equations.

Step 3: Solve the equations step-by-step, showing your work.

Step 4: Check your answer to make sure it makes sense in the context of the problem.

Writing a story:

Step 1: Introduce the main character and their initial situation.

Step 2: Describe the inciting incident that sets the story in motion.

Step 3: Follow the character through a series of challenges and setbacks.

Step 4: Resolve the conflict and bring the story to a satisfying conclusion.

Benefits of CoT:

Improved reasoning and problem-solving capabilities

Increased transparency and interpretability of model outputs

More accurate and reliable results for complex tasks

Greater flexibility and adaptability to different situations

Challenges of CoT:

Requires careful planning and effort to design effective CoT chains

May not be suitable for all tasks, especially those requiring creativity or intuition

Can be computationally expensive for large models

Overall, CoT is a powerful and promising technique for enhancing the capabilities of LLMs. With its focus on guiding the model's reasoning process, CoT opens up new possibilities for human-AI collaboration and problem-solving.

# CoT Example-1: Solving a Physics Problem

Before

When the user gives below Prompt to Solve a Physics Problem to GPT3.5 then see the result. The LLM was not able to solve the problem even though the numerical values for F, m1 and m2 were provided in the Prompt. (See the last para in the below response given by ChatGPT where it says the numerical values were not given).

After

Now lets use the CoT technique by expanding the prompt to Solve the same Physics Problem using GPT3.5. You would see that the LLM was able to solve the problem without any issues by following the Steps provided in the Prompt.

A force of 5 N gives a mass m1, an acceleration of 10 m s–2 and a mass m2, an acceleration of 20 m s-2. What acceleration would it give if both the masses were tied together?

Question: A force of 5 N gives a mass m1, an acceleration of 10 m s–2 and a mass m2, an acceleration of 20 m s-2. What acceleration would it give if both the masses were tied together?

Use the below Three Steps to solve the problem.

1) Individual accelerations:

Given a force of 5 N acting on mass m1, use Newton's second law (F = ma) to find its acceleration (a1).

Repeat the same equation for mass m2 and its acceleration (a2).

2) Combined masses:

Calculate the combined mass (m_combined) by adding m1 and m2.

3) Combined acceleration:

Apply Newton's second law again with the force (F) and combined mass (m_combined) to find the acceleration (a_combined) of both masses tied together.