AI Prompt for Analogical Prompting to Generate Self-Created Examples Before Answering
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
Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.
Example input
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.