Don't Feed Your AI Examples. Ask It to Generate Its Own.
Most of us have learned the same prompting trick: give the AI a few examples before asking your actual question. It works. But it creates a persistent problem — someone has to write those examples, curate them, keep them relevant. For a one-off task in a familiar domain, that's manageable. For anything complex, varied, or new, it becomes the bottleneck.
There's a different approach that inverts the workflow entirely. Instead of supplying examples yourself, you ask the model to generate its own. The technique is called analogical prompting, and it does this without requiring you to prepare a single labeled example in advance.
One caveat before going further: the performance gains documented in research apply to sufficiently large, capable models. With smaller models, self-generated examples can be weak or irrelevant, and retrieval-based few-shot prompting tends to outperform it. Keep that in mind when deciding where to try this first.
What It Is
Analogical prompting works by instructing the model, within your prompt, to first surface relevant example problems from its own training knowledge before attempting to solve your actual question. You're not providing examples — you're asking the model to construct and demonstrate them itself, then use that self-generated context to work through your problem. Large language models have absorbed an enormous amount of structured problem-solving during training; this technique gives them a structured way to surface that knowledge at the moment it's needed, matched to the specific problem at hand rather than pulled from a fixed library you assembled earlier.
Before and After
Before — standard prompt:
"Write a professional email declining a vendor proposal without damaging the relationship."
This gets you a reasonable response, but the model has no scaffolding. It's working cold.
After — analogical prompting:
"Your task is to draft a professional business communication. Before writing the email, recall three examples of situations where someone needed to decline a request professionally while preserving goodwill. For each example, briefly describe the situation and what made the response effective. Then use those principles to write an email declining a vendor proposal without damaging the relationship."
The second version prompts the model to generate its own relevant analogues first — a declined job offer, a passed-on partnership, a rejected client request — and reason from those examples to your specific case. The output is more considered, more structurally sound, and draws on a broader range of communication strategies. You wrote no examples yourself.
For code generation specifically, there's an extended version: before asking for analogues, you ask the model to identify the core concepts or algorithms involved and write a brief tutorial on them. The research tested this on competitive programming tasks, and the evidence for it is scoped to that domain.
When to Use It
-
You're working in an unfamiliar domain. Drafting a contract clause, writing a financial summary, producing technical documentation outside your expertise — you don't have good examples on hand. Analogical prompting means you don't need them.
-
Your tasks are heterogeneous. A fixed example set works well when every prompt is roughly the same shape. When your work spans different problem types — mixed-format reports, varied client communications, diverse research questions — static examples go stale. Self-generated exemplars match the current problem.
-
You're doing structured reasoning. Comparative analysis, risk evaluations, logical arguments — these benefit from the model recalling how similar reasoning problems have been approached before tackling yours.
-
You want better code without writing a tutorial yourself. The knowledge-plus-exemplars variant, where you ask the model to identify relevant algorithms or methods and explain them before generating code, moved first-attempt solve rates from 9% to 15% on competitive programming benchmarks in the original research, using GPT-3.5-turbo-16k.
-
You're prototyping across multiple use cases. Traditional few-shot prompting requires per-task prompt engineering. Analogical prompting uses the same structural pattern regardless of domain, which makes it faster to adapt.
A Few Things to Keep in Mind
This technique works best with capable, modern models — GPT-4, GPT-3.5-turbo, PaLM 2, and similar. With smaller or older models, the self-generation can produce weak or irrelevant examples, which hurts performance rather than helping it.
There's also a token cost. Because the model generates examples as part of its output rather than receiving them as input, each request is longer. For low-stakes tasks, that overhead probably isn't worth it. For anything client-facing, analytically complex, or technically demanding, the quality gain justifies it.
The research tested three to five self-generated examples as the effective range. Three is a reasonable default. Beyond five, you're paying token costs without proportional return.
Try It
If you want to start small, pick one recurring task where your current examples feel stale or where you've been writing them from scratch each time. Swap in the analogical structure — ask the model to generate three relevant cases, reason through them briefly, then apply that reasoning to your actual problem. That's one extra sentence or two in the prompt. Run it against your usual approach on the same task and compare the outputs directly.
When the examples come from the model rather than you, the prompt generalizes. The same structural pattern works across domains without rebuilding your example library each time.
Source: Yasunaga, Chen, Li, Pasupat, Leskovec, Liang, Chi, Zhou (2024). Large Language Models as Analogical Reasoners.