Analogical prompting is a prompting technique in which a large language model is instructed to recall or generate relevant example problems and their solutions on its own, and then use them as guidance to solve the target problem. Within artificial intelligence, it belongs to the family of reasoning-oriented prompting methods and combines the strengths of few-shot prompting and chain-of-thought reasoning without requiring a human to write any examples.
The idea draws on analogical reasoning in human cognition: when people meet an unfamiliar problem, they often ask themselves which similar problem they have solved before. Analogical prompting asks the model to perform that same recall step explicitly in its output, so the self-generated exemplars are tailored to each individual problem rather than fixed across all inputs.
How analogical prompting works
Analogical prompting works by inserting a self-generation step before the answer. A single prompt tells the model to first describe several relevant problems, explain how each was solved, and only then solve the problem at hand. Everything happens in one model call, so no retrieval system or example database is needed.
A typical instruction reads: recall three relevant and distinct problems, describe each problem and its solution, then solve the initial problem. Asking for distinct exemplars matters, because near-identical examples add tokens without adding guidance.
The table below breaks the method into its stages and explains what each one contributes.
| Stage | What the model does | Why it helps |
|---|---|---|
| Problem statement | Reads the target problem | Anchors all later recall to the actual task |
| Exemplar recall | Writes several similar problems | Activates relevant knowledge from training |
| Exemplar solutions | Solves each recalled problem step by step | Rehearses a reasoning pattern before use |
| Optional knowledge step | States core concepts or a short tutorial | Supplies high-level principles, not only cases |
| Target solution | Solves the original problem | Transfers the rehearsed pattern to the new case |
Variants and key parameters
Analogical prompting has two main variants. The basic form generates exemplars only, while an extended form also asks the model to produce high-level knowledge, such as the key concept or algorithm a problem requires, before writing exemplars. The extended form tends to help on harder tasks such as competitive programming, where recognizing the right technique matters more than seeing a similar surface problem.
Several parameters shape results. The following table lists the most influential ones and typical settings.
| Parameter | Typical setting | Effect of changing it |
|---|---|---|
| Number of exemplars | Three to five | Fewer gives less guidance; more adds cost with diminishing returns |
| Distinctness requirement | Explicitly requested | Prevents repetitive exemplars that waste tokens |
| Knowledge step | Enabled for complex tasks | Improves recognition of the underlying method |
| Output structure | Labeled sections or delimiters | Makes the final answer easy to extract |
| Model scale | Large, capable models | Small models often recall irrelevant or wrong examples |
How it compares with other prompting techniques
Analogical prompting sits between zero-shot chain-of-thought and manual few-shot prompting. It keeps the zero effort of zero-shot methods while recovering much of the guidance that hand-written examples provide, and its exemplars adapt to each input instead of staying fixed.
| Technique | Source of examples | Main strength | Main weakness |
|---|---|---|---|
| Analogical prompting | Generated by the model per problem | Tailored guidance with no labeling | Longer outputs and recall errors |
| Zero-shot chain-of-thought | None | Simplest to apply | No demonstration of solution style |
| Few-shot chain-of-thought | Written by a human | Precise, verified demonstrations | Fixed examples may not fit every input |
| Auto-CoT | Clustered from a question pool | Automated, diverse exemplars | Needs a dataset of questions |
| Step-back prompting | None; derives principles first | Strong on concept-heavy questions | No worked cases to imitate |
| Generated knowledge prompting | Model-generated facts | Adds background context | Facts are not worked solutions |
In published evaluations on mathematical reasoning, code generation and logical reasoning benchmarks, analogical prompting matched or outperformed both zero-shot and manual few-shot chain-of-thought on average with large models. Gains are task- and model-dependent, so results on one benchmark should not be assumed to transfer to every workload.
When to use analogical prompting
Analogical prompting is most useful when good examples would help but are expensive to write or vary too much between inputs. The decision table below summarizes common situations.
| Situation | Recommendation | Reason |
|---|---|---|
| Diverse math or logic problems | Use analogical prompting | Each problem receives fitting exemplars |
| Algorithmic coding tasks | Use the knowledge-plus-exemplar variant | Naming the right technique guides the code |
| Narrow task with stable format | Prefer curated few-shot examples | Verified examples are cheaper and safer |
| Strict latency or token budget | Prefer zero-shot chain-of-thought | Self-generated exemplars add many tokens |
| Small or weak model | Avoid or test carefully | Recalled examples are often unreliable |
A practical approach is to evaluate against a baseline on a representative test set. Analogical prompting should earn its extra tokens with measurably better accuracy, not merely look more thorough.
Limitations and common mistakes
The central weakness is that self-generated exemplars are not verified. A model can recall a plausible-looking problem with a flawed solution and then transfer the flaw to the target answer, which makes errors look more confident because they arrive with supporting cases.
- Higher token cost: three solved exemplars can multiply output length several times.
- Irrelevant analogies: surface similarity, such as shared wording, can mislead the model toward the wrong method.
- Answer extraction problems: without clear delimiters, downstream code may parse an exemplar answer instead of the final one.
- Possible memorization effects: on public benchmarks, recalled exemplars may echo training data, which can inflate measured gains.
- Hidden reasoning in production: long exemplar text often needs to be stripped before showing results to end users.
The idea in brief
Analogical prompting asks an AI model to remember similar problems first and then solve the new one. It is like a student who faces a tricky exam question. The student thinks of a few homework problems that looked alike and recalls how those were solved. Then the student applies the same approach.
Nobody has to write the practice examples for the model. It creates them itself, so they fit each question. The catch is that its memories can be wrong. A good check on the final answer is still needed.
A practical scenario
A company that builds a tutoring application for high school mathematics needs step-by-step solutions for thousands of word problems covering probability, geometry and algebra. Writing curated examples for every problem type would take an editor weeks, and a fixed set of examples fits geometry questions poorly when the input is about probability.
The engineering team switches to an analogical prompt that asks the model to recall three distinct related problems with solutions, state the key concept, and then solve the student’s problem inside a clearly labeled final section. The application displays only that final section, while the recalled exemplars stay in the logs for review.
On an internal test set of 500 problems checked by teachers, the team observes fewer reasoning errors than with zero-shot prompting, at roughly three times the output tokens. Because some recalled exemplars contain mistakes, the team adds an automated answer check against a symbolic solver, and problems that fail the check go to human review before students see them.