Solutions Found in Similarity, Analogical Prompting
Analogical Prompting
is a technique that guides AI to solve complex problems by referring to similar situations or cases. It works on the principle similar to how humans solve new problems by referencing past experiences.
Analogous cases can be directly generated by AI when creating an answer, or provided directly in the prompt for the AI to refer to.
Analogical Prompting has shown performance improvement in coding and mathematical problem-solving. Particularly, in the GSM8K
dataset which evaluates mathematical problem-solving, it improved the answer accuracy by 17.9% compared to CoT (Chain of Thought) prompting.
How to Construct Analogical Prompts?
Analogical prompts are constructed as follows.
Step 1: Present the Problem Situation
Summarize and present the problem situation to be solved (e.g., coding, marketing strategy development, event planning).
Step 2: Present Similar Cases and Request Solutions
Present several similar cases to the problem situation mentioned in Step 1, and encourage the AI to devise solutions for each.
According to research on analogical prompting, offering 3-5 similar situations was most effective in improving answer accuracy.
The number of exemplars to generate (K): Through experimentation, we have found that generating K = 3 to 5 exemplars works the best.
Step 3: Generate an Answer
Encourage AI to generate a solution to the problem given in Step 1 by referencing the similar cases and solutions provided in Step 2.
Template for Analogical Prompts
An analogical prompt can be composed as follows.
### Problem: [Enter Problem Content]
### Instructions
1. Related Issue: Think of 3 similar problems (or cases). Describe each problem (or case) and propose its solution.
- Problem 1: [Problem Description]
- Solution: [Proposed Solution]
- Problem 2: [Problem Description]
- Solution: [Proposed Solution]
- Problem 3: [Problem Description]
- Solution: [Proposed Solution]
2. Solve the problem stated in the first line: Using the above 3 problems and solutions, solve the initially presented problem.
Using the template above, a prompt can be crafted as follows.
### Problem: How to create a diet plan
### Instructions
1. Related Issue: Think of 3 similar problems. Briefly describe each problem and provide the solution.
- Problem 1: [Problem Description]
- Solution: [Proposed Solution]
- Problem 2: [Problem Description]
- Solution: [Proposed Solution]
- Problem 3: [Problem Description]
- Solution: [Proposed Solution]
2. Solve the problem stated in the first line: Use the 3 problems and solutions above to solve the initially presented problem.
How is it Utilized?
When crafting an analogical prompt, you can directly present similar situations for the AI to refer to, like the example below.
### Problem: Formulating a market entry strategy for a new product
### Instructions
1. Related Issues: Think of 3 similar problems. Briefly describe each problem and provide the solution.
Problem 1: Increasing existing customer churn
- Description: The churn rate of existing customers has recently increased.
- Solution: Identify the reasons for the increasing churn rate through surveys and encourage repurchases through discount programs.
Problem 2: Price competition with competing products
- Description: Market share is declining due to cheaper products from competitors.
- Solution: Focus on the distinct value and competitiveness of our products, emphasizing a premium product line.
Problem 3: Poor advertising performance
- Description: The recent advertising campaign did not meet expectations.
- Solution: Reanalyze the target customer base and revise advertising strategies with tailored messages.
2. Solve the initial problem: Using the solutions to the above problems, devise a strategy to tackle the market entry issue for the new product.
Analogical prompting guides problem-solving by having the AI directly propose or refer to similar problems and cases and their solutions.
A suitable number of similar problems for prompting is approximately 3-5
.
Exercises
Send a prompt example and compare AI's responses.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.