Emergent Mind

In-Context Principle Learning from Mistakes

Published Feb 8, 2024 in cs.CL and cs.AI


In-context learning (ICL, also known as few-shot prompting) has been the standard method of adapting LLMs to downstream tasks, by learning from a few input-output examples. Nonetheless, all ICL-based approaches only learn from correct input-output pairs. In this paper, we revisit this paradigm, by learning more from the few given input-output examples. We introduce Learning Principles (LEAP): First, we intentionally induce the model to make mistakes on these few examples; then we reflect on these mistakes, and learn explicit task-specific "principles" from them, which help solve similar problems and avoid common mistakes; finally, we prompt the model to answer unseen test questions using the original few-shot examples and these learned general principles. We evaluate LEAP on a wide range of benchmarks, including multi-hop question answering (Hotpot QA), textual QA (DROP), Big-Bench Hard reasoning, and math problems (GSM8K and MATH); in all these benchmarks, LEAP improves the strongest available LLMs such as GPT-3.5-turbo, GPT-4, GPT-4 turbo and Claude-2.1. For example, LEAP improves over the standard few-shot prompting using GPT-4 by 7.5% in DROP, and by 3.3% in HotpotQA. Importantly, LEAP does not require any more input or examples than the standard few-shot prompting settings.


  • LEAP introduces a novel methodology for improving in-context learning (ICL) of LLMs by learning from mistakes without requiring extra inputs.

  • This approach uses a zero-shot fashion to generate errors and then derives explicit task-specific principles to avoid such mistakes in the future, enhancing the model's reasoning and generalization capabilities.

  • Empirical validation shows LEAP significantly outperforming standard few-shot prompting on benchmarks like DROP and HotpotQA across various reasoning tasks, without additional examples.

  • LEAP emphasizes the potential of mistake-driven learning to advance AI adaptability and generalization, suggesting a new direction for AI development focused on self-improvement and sophisticated reasoning.

Introduction to In-Context Principle Learning from Mistakes (LEAP)

In the exploration of enhancing in-context learning (ICL) capabilities of LLMs, the novel methodology introduced as Learning Principles from Mistakes (LEAP) offers a groundbreaking approach. Unlike traditional ICL methodologies that focus exclusively on learning from correct input-output pairs, LEAP innovates by intentionally leading models to errors on given examples, followed by a self-reflective process where the models articulate explicit, task-specific "principles" from these mistakes. This process does not require more input or examples than the standard few-shot prompting settings, marking a significant progression in the efficiency of machine learning methodologies.

LEAP Methodology Explained

The process begins with the model generating errors in a zero-shot fashion, which involves sampling outputs with a non-zero temperature. Subsequently, these errors are analyzed to generate explicit principles that guide the avoidance of similar errors in future tasks. This approach is built upon the hypothesis that learning from errors can significantly enhance a model's ability to reason and generalize, a learning paradigm deeply rooted in both human cognitive development and classical machine learning theories.

The most compelling aspect of LEAP is its simplicity and effectiveness in utilizing the same set of given few-shot examples for both the generation of mistakes and the derivation of learning principles without any additional input. This attribute aligns seamlessly with the constraints of practical application scenarios where labeled data may be scarce.

Empirical Validation Across Benchmarks

LEAP was rigorously evaluated against a wide spectrum of reasoning benchmarks, demonstrating its capability to outperform the standard practice of few-shot prompting on powerful models like GPT-3.5-turbo, GPT-4, and GPT-4-turbo. Specifically, LEAP exhibited notable improvements in DROP by 7.5% and in HotpotQA by 3.3% when applied to GPT-4, without necessitating additional examples beyond the conventional few-shot scheme.

Furthermore, LEAP's performance was consistent across various reasoning tasks, reinforcing the premise that learning from mistakes can universally enhance the reasoning capabilities of LLMs. The methodology's ability to extract and apply general principles across different question sets without specific task retraining represents a significant advancement in the domain of adaptive learning for LLMs.

Insights and Future Directions

The introduction of LEAP marks a pivotal shift towards harnessing the inherent mistake-making propensity of LLMs as a powerful learning mechanism. By fostering a model's ability to reflect on its mistakes and derive generalizable principles, LEAP paves the way for more sophisticated, self-improving AI systems. This approach not only enriches the model's learning experience but also amplifies its reasoning abilities across unfamiliar tasks, embodying a significant leap towards achieving true AI adaptability and generalization.

Continued exploration and refinement of LEAP could unlock new dimensions in AI research, particularly in enhancing the efficiency and efficacy of in-context learning methodologies. The potential for LEAP to be applied in conjunction with other learning paradigms also opens avenues for innovative hybrid models that could further accelerate the evolution of machine intelligence.


LEAP represents a robust, efficient, and highly adaptable framework for enhancing the in-context learning capabilities of LLMs. By learning from mistakes—a fundamentally human approach to knowledge acquisition—LLMs can achieve a higher degree of reasoning and generalization. This breakthrough sets a new standard in the field, suggesting a promising horizon for AI development where models not only learn from their successes but also grow through their failures.

Get summaries of trending AI/ML papers delivered straight to your inbox

Unsubscribe anytime.