Back to cookbook

AI Prompt for Analogical Prompting to Generate Self-Created Examples Before Answering

0 views Published

Make this prompt yours

Share

Analogical prompting is a technique where, instead of you writing few-shot examples by hand, you ask the model to first recall or invent similar problems it has solved before, work through those, and then apply the same reasoning to your actual question. It's useful for anyone writing prompts for ChatGPT, Claude, or Gemini who wants few-shot-style accuracy without maintaining a library of hand-picked examples for every possible question type.

The idea comes from research on having language models generate their own relevant exemplars and knowledge before tackling a problem, rather than relying on a fixed set of examples chosen by the prompt writer. This matters because hand-picked examples can be a poor match for the specific problem a user actually asks about, while a model generating its own analogous cases can tailor them to the exact structure of the question.

This technique works especially well for problems with a recognizable pattern, like math word problems, code logic puzzles, or structured writing tasks, where "here's a similar problem and how it was solved" genuinely helps the model reason more carefully before committing to an answer.

Prompt template

Make this prompt yours

prompt-template
147 tokens
You are solving a problem using analogical reasoning. STEP 1: Before solving the problem below, recall or generate 2 related problems that share a similar underlying structure or reasoning pattern. For each one, briefly state the problem and how it would be solved. STEP 2: Identify what reasoning approach or pattern those examples have in common. STEP 3: Apply that same reasoning approach to solve the actual problem below. Show your work step by step. ACTUAL PROBLEM: [YOUR QUESTION OR PROBLEM HERE] OUTPUT FORMAT: - Related Examples: (2 short examples with solutions) - Shared Pattern: (1-2 sentences) - Final Answer: (clearly labeled, with step-by-step reasoning for the actual problem)

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
50 tokens
Actual problem: A train leaves Station A at 60 mph heading toward Station B, 300 miles away. At the same time, a second train leaves Station B heading toward Station A at 90 mph. How long until the two trains meet?

When to use it

  • You're solving a problem with a clear underlying pattern, like a math word problem, logic puzzle, or structured coding task
  • You don't have good hand-written few-shot examples on hand and don't want to spend time crafting them
  • Few-shot prompting with generic examples hasn't improved accuracy because the examples don't match your specific problem type
  • You want the model to "show its reasoning" by relating the new problem to something it already understands well

Best practices

  • Explicitly ask the model to generate 1-3 related problems AND their solutions before it attempts your actual question, rather than jumping straight to an answer
  • Make sure your actual question is stated clearly and separately from the instruction to generate analogous examples, so the model doesn't blend them together
  • Use this technique for problems with transferable structure (math, logic, code patterns) rather than open-ended creative or subjective questions where "similar problems" don't really exist
  • Compare outputs with and without the analogical step on a few test questions to confirm it's actually improving your specific use case before adopting it everywhere

Common mistakes

  • Asking for analogous examples but not asking the model to explicitly apply the same reasoning pattern, so the examples end up disconnected from the final answer
  • Using this technique on purely subjective or creative tasks where there's no real "similar problem" to recall
  • Letting the model generate too many examples (5+), which adds length and cost without improving accuracy
  • Forgetting to ask for the final answer separately and clearly after the analogous reasoning, so it gets buried in the example-generation text

FAQs

What is analogical prompting in AI?

Analogical prompting is a technique where you ask a language model to generate or recall similar problems and their solutions before answering your actual question, so it can apply a proven reasoning pattern instead of starting from scratch.

How is analogical prompting different from few-shot prompting?

Few-shot prompting uses examples you write and provide yourself. Analogical prompting asks the model to generate its own relevant examples on the fly, which can adapt better to the specific structure of your exact question.

Does analogical prompting work for creative writing tasks?

It works best for problems with a transferable structure, like math, logic, or coding tasks. For open-ended creative writing, there usually isn't a meaningful "similar problem" to recall, so other techniques like role prompting tend to work better.

Can I combine analogical prompting with chain-of-thought prompting?

Yes, they work well together. The analogical step helps the model identify the right reasoning pattern, and chain-of-thought instructions ensure it shows that reasoning step by step when applying the pattern to your actual question.

What tool pairs well with testing a reasoning prompt like this one?

Prompt Debugger — it scans multi-step prompts like this for vague constraints or logical gaps before you rely on them, and Compare & Diff lets you test this prompt against a plain version side by side to confirm the analogical step is actually improving accuracy.

Found this prompt useful? Share it.

Share

More in Prompt Fundamentals & Techniques

Prompt Fundamentals & Techniques

AI Prompt for Multi-Persona Debate to Stress-Test an Idea

Multi persona debate prompting is a technique where you ask a model to argue a decision or idea from several distinct, opposing viewpoints b…

You are facilitating a structured debate between multiple expert personas to help evaluate a decision.

DECISION TO EVALUATE:
[DESCRIBE THE DECISION OR IDEA, e.g. "Should we raise our subscription price by 20% for new customers?"]

CONTEXT:
[RELEVANT BACKGROUND: company size, current numbers, constraints, timeline]

PERSONAS:
1. [PERSONA 1 — e.g. "Risk-Averse CFO who prioritizes cash flow stability and customer retention"]
2. [PERSONA 2 — e.g. "Aggressive Growth Lead who prioritizes revenue growth and market share"]
3. [PERSONA 3 — e.g. "Customer Success Manager who prioritizes existing customer satisfaction"]

TASK:
1. Have each persona give a 2-3 sentence opening argument from their specific incentive and priorities
2. Run one round of rebuttal where each persona directly challenges at least one point from another persona
3. After the debate, provide a neutral synthesis that lists the strongest point from each side
4. End with a short, clearly labeled recommendation and the key risk to monitor if that recommendation is followed

CONSTRAINTS:
- Keep each persona's arguments distinct and grounded in their stated priorities, not generic pros/cons
- Do not let the synthesis simply average the positions — it should make an actual call
- Flag any assumption the personas are relying on that isn't confirmed in the context provided

OUTPUT FORMAT:
Label each section clearly: Opening Arguments, Rebuttals, Synthesis, Recommendation.

Make this prompt yours

Prompt Fundamentals & Techniques

AI Prompt for Step-Back Prompting to Improve Reasoning Accuracy

Step back prompting is a technique for getting more accurate answers from ChatGPT, Claude, or Gemini by asking the model to first state the…

ROLE: You are a careful reasoning assistant that solves problems by first identifying general principles.

TASK: Answer the following specific question: [SPECIFIC QUESTION OR PROBLEM]

CONSTRAINTS:
1. Before answering, state the general principle, rule, or concept that applies to this type of problem. Write this as a standalone statement that would be true for any similar problem, not just this one.
2. Then explain how that general principle applies to the specific details given.
3. Only after steps 1 and 2, give your final answer.
4. If your final answer seems to contradict the general principle you stated, flag the contradiction and revise instead of ignoring it.

OUTPUT FORMAT:
General Principle: [the abstracted rule]
Application: [how the rule applies to this specific case]
Final Answer: [the specific answer]

DOMAIN CONTEXT: [OPTIONAL: SUBJECT AREA, E.G. PHYSICS, TAX LAW, SOFTWARE DEBUGGING]

Make this prompt yours

Prompt Fundamentals & Techniques

AI Prompt for Self-Consistency Prompting to Get More Reliable Reasoning Answers

This prompt applies self consistency prompting , a technique where you ask a model to work through the same reasoning problem several times…

ROLE: You are a careful problem solver who verifies answers before committing to them.

CONTEXT:
Problem: [DESCRIBE THE PROBLEM, QUESTION, OR DATA POINT TO EVALUATE]
Domain: [MATH / LOGIC / CLASSIFICATION / OTHER]

TASK:
1. Solve the problem above [NUMBER, e.g. 4] separate times, using an independent line of reasoning each time. Do not let earlier attempts influence later ones.
2. For each attempt, show the step-by-step reasoning, then state the final answer on its own line in the format "Answer: [VALUE]".
3. After all attempts, list the final answers side by side and identify which answer appears most often.
4. State the majority answer as the final result. If there is no clear majority, say so explicitly and explain what caused the attempts to diverge.

CONSTRAINTS:
- Keep each reasoning attempt self-contained; do not reference other attempts while solving
- Use the same problem statement for every attempt
- Flag any attempt that relies on an assumption not stated in the problem

OUTPUT FORMAT:
Attempt 1: [reasoning] / Answer: [value]
Attempt 2: [reasoning] / Answer: [value]
(repeat for each attempt)
Summary: [majority answer and confidence note, or divergence explanation]

Make this prompt yours