P

Analogical Prompting: Definition and Examples

Prompt engineering technique that consists of asking the model to generate or rely on analogical examples before solving a problem, drawing inspiration from human reasoning by analogy.

Full definition

Analogical Prompting is an advanced prompt engineering technique introduced by researchers at Google DeepMind in 2023. It relies on a fundamental cognitive principle: humans often solve new problems by drawing on similar situations they have already encountered. This method asks the language model to generate analogous problems and their solutions before tackling the target problem.

Unlike classic few-shot prompting, where the user manually provides examples, Analogical Prompting lets the model produce its own relevant examples. The model identifies structurally similar problems, solves them step by step, then transfers the reasoning to the given problem. This self-generation of analogies exploits the model's internal knowledge in a more targeted and contextual way.

The process generally unfolds in three phases: first, the model recalls or constructs analogous problems; second, it details the resolution of these analogies; finally, it applies the identified reasoning patterns to the original problem. This approach proves particularly effective for tasks involving mathematical reasoning, programming, and complex problem-solving.

Analogical Prompting represents a significant evolution because it combines the advantages of zero-shot (no need to provide examples) with those of few-shot (benefiting from concrete examples to guide reasoning). Studies show it often outperforms standard Chain-of-Thought prompting on reasoning benchmarks like GSM8K and MATH.

Etymology

The term combines "analogical", from the Greek analogia meaning "proportion" or "correspondence", and "prompting". It directly refers to reasoning by analogy studied in cognitive science, where one solves a problem by comparing it to a known problem of similar structure.

Concrete examples

Solving a complex math problem

Before solving the following problem, recall similar problems you know. Generate 2-3 analogous problems with their detailed solutions, then use these reasonings to solve: "A train leaves Paris at 9 am at 120 km/h. Another leaves Lyon at 10 am at 150 km/h in opposite direction. The distance Paris-Lyon is 450 km. At what time do they meet?"

Debugging code by relying on similar bugs

Before analyzing this bug, think of analogous debugging situations you have encountered. Describe 2 similar bugs in structure and how they were resolved, then apply this reasoning to my problem: [CODE_WITH_BUG]

Software architecture design

I need to design a distributed queue system. Before proposing an architecture, generate 2-3 examples of analogous systems (distributed systems with similar constraints), explain their architectural choices, then propose a solution for my case building on these analogies.

Practical usage

To apply Analogical Prompting, add an instruction in your prompt asking the model to generate similar problems before answering. For example: "Before answering, recall 2-3 analogous situations and their solutions, then apply this reasoning to my problem." This technique is particularly useful for complex reasoning problems where classic zero-shot lacks precision.

Related concepts

Chain-of-Thought PromptingFew-Shot PromptingSelf-Generated ExemplarsReasoning by analogy

FAQ

What is the difference between Analogical Prompting and few-shot prompting?
In few-shot prompting, the user manually provides examples in the prompt. In Analogical Prompting, the model itself generates its own analogous examples. This eliminates the need to find relevant examples and allows the model to draw on its knowledge to produce analogies more suited to the specific problem.
Does Analogical Prompting work with all language models?
This technique works best with large language models (GPT-4, Claude, Gemini) that have enough internal knowledge to generate relevant and high-quality analogies. Smaller models may produce less relevant or incorrect analogies, which would degrade the final result rather than improve it.
When to use Analogical Prompting instead of Chain-of-Thought?
Analogical Prompting is particularly suited for new or unusual problems where the model benefits from "recalling" similar cases. Chain-of-Thought remains sufficient for more straightforward problems that simply require step-by-step reasoning. The two techniques can also be combined: the model generates analogies, then reasons step by step drawing inspiration from them.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.