Prompt Engineering : Chain of Thought Prompting
Back with another prompt engineering technique! This time, we'll be exploring the Chain of Thought Prompting technique. This technique is a bit more complex than the previous ones we've discussed, but it can be very powerful when used correctly.
What is Chain of Thought Prompting?
Mainly used when the problems you want the LLM to solve involves mathematical or logical reasoning. You want to ask the model to explain their reasoning step by step. This technique is useful when you want to guide the model through a series of logical steps to arrive at a solution.
Although it might not be possible to give a example everytime but an example in the prompt will surely help the model to understand the context and generate the output accordingly.
Example
Prompt:
We assign a stability score to each of our product based on their creation date, their testing results and their transport time, with the product name all in small caps.
The stability score is calculated as follows:
- The creation date is assigned a score of 0 to 10, with 10 being the most recent.
- The testing results are assigned a score of 0 to 10, with 10 being the most stable.
- The transport time from origin to destination on a score of 0 to 10, with 10 being farthest.
Given the following information, calculate the stability score for each product and determine which product is the most stable.
For e.g
Product Z:
- Creation Date: 3
- Testing Results: 8
- Transport Time: 4
Stability Score : productz_15
Given the following information, calculate the stability score for each product :
Product A:
- Creation Date: 5
- Testing Results: 8
- Transport Time: 3
Product B:
- Creation Date: 7
- Testing Results: 6
- Transport Time: 2
Explain your reasoning step by step in detail on how that score was calculated.
Output:
To calculate the stability score for each product, we follow these steps:
1. Sum the scores of the creation date, testing results, and transport time.
2. Convert the product name to lowercase and append the sum of scores to the product name.
Given the information provided for each product, let's calculate their stability scores:
### Product A:
1. **Creation Date Score**: 5
2. **Testing Results Score**: 8
3. **Transport Time Score**: 3
Sum of scores: 5 + 8 + 3 = 16
The product name in lowercase: "producta"
Stability Score for Product A: producta_16
### Product B:
1. **Creation Date Score**: 7
2. **Testing Results Score**: 6
3. **Transport Time Score**: 2
Sum of scores: 7 + 6 + 2 = 15
The product name in lowercase: "productb"
Stability Score for Product B: productb_15
### Summary:
- **Product A Stability Score**: producta_16
- **Product B Stability Score**: productb_15
Based on the calculated stability scores, Product A is the most stable with a score of 16, while Product B has a stability score of 15. So, Product A is more stable than Product B.
Although this example is a bit simple, it gives you an idea of how the Chain of Thought Prompting technique can be used to guide the model through a series of logical steps to arrive at a solution. And in the process it also gives you a detailed explanation of how the model arrived at the solution.