Abstract
Large language models struggle to synthesize disparate pieces of information into a coherent plan when approaching a complex procedural task. In this work, we introduce a novel formalism and structure for such procedural knowledge. Based on this formalism, we present a novel procedural knowledge dataset called LCStep, which we created from LangChain tutorials. To leverage this procedural knowledge to solve new tasks, we propose analogy-augmented generation (AAG), which draws inspiration from the human ability to assimilate past experiences to solve unfamiliar problems. AAG uses a custom procedure memory store to retrieve and adapt specialized domain knowledge to answer new procedural tasks. We demonstrate that AAG outperforms few-shot and RAG baselines on LCStep, RecipeNLG, and CHAMP datasets under a pairwise LLM-based evaluation, corroborated by human evaluation in the case of RecipeNLG.
Introduction
While Large Language Models (LLMs) excel at retrieving factual information ("knowledge-that"), they often struggle with procedural knowledge ("knowledge-how"). Complex tasks—such as using a software library released after a model's training cutoff or creating a recipe from obscure ingredients—require planning and sequential reasoning. Standard Retrieval-Augmented Generation (RAG) often fails in these scenarios because it retrieves isolated text snippets that lack the underlying logical structure of a complete process.
Humans solve such problems by thinking through analogy: recalling how a similar problem was solved and mapping that structure to the current task. This paper introduces Analogy-Augmented Generation (AAG), a system designed to mimic this cognitive process by retrieving and adapting past procedural experiences from a specialized memory store.
Methodology: The AAG Framework
AAG moves beyond simple document retrieval by implementing a multi-step "Rewrite-Retrieve-Read" pipeline. The system relies on a specialized Procedural Memory Store, where procedures are represented as structured objects containing inputs, outputs, and a sequence of steps rather than raw text chunks.
The pipeline consists of four primary components:
- Query Generator: Instead of using raw prompts, an LLM generates a high-level outline and specific sub-questions to find "analogical examples" in the memory store—past experiences with similar logical structures.
- Answer Generator: This module acts as a filter, extracting the essential "how-to" logic from retrieved analogies to construct a candidate response.
- Update Response: The system integrates the generated logic into a coherent plan.
- Iterative Self-Refinement: An "LLM Critic" evaluates the candidate plan and suggests edits, which an "LLM Edit Performer" executes. This cycle repeats (up to three times) to ensure technical soundness and coherence.
Experimental Results
The researchers evaluated AAG across three domains: LCStep (a new dataset of 276 LangChain procedures), RecipeNLG (cooking recipes), and CHAMP (math competition problems).
As shown in the results table, AAG consistently outperformed Zero-Shot, Few-Shot, and RAG baselines in pairwise evaluations. On the LCStep dataset, AAG achieved a 69.64% win rate against standard RAG. On RecipeNLG, the win rate exceeded 85%. Human evaluation further validated these results; in a blind study on recipes, human raters preferred AAG-generated instructions 56% of the time, compared to only 16% for RAG (with 28% resulting in a tie).
Ablation studies highlighted the importance of specific components. Notably, removing the Answer Generator (NO AG) led to a significant performance drop, with win rates falling to 39.28% on LCStep, underscoring its role in filtering and adapting retrieved logic. In the CHAMP math dataset, while AAG outperformed RAG, it performed slightly worse than Few-Shot prompting, suggesting that in highly rigid domains, filtering out context can occasionally remove crucial logical steps.
Discussion and Limitations
AAG's success is rooted in the Systematicity Principle, which suggests that effective analogies map relationships between actions rather than just keyword matches. While RAG might provide shallow instructions, AAG provides detailed function signatures and testing steps by "remembering" successful past procedures.
However, the system has limitations. It currently assumes procedures are linear, lacking explicit support for loops or conditional branching. Additionally, the multi-step pipeline is computationally intensive, requiring approximately 13 LLM calls per query, making it roughly 7x slower than standard RAG. Future work will focus on developing a "skill library" for finer-grained reasoning over sub-procedures.
Summary updated