Distilling Many-Shot In-Context Learning into a Cheat Sheet

Ukyo Honda, Soichiro Murakami, Peinan Zhang

TL;DR

Researchers have developed Cheat-sheet ICL, a method that distills the knowledge from hundreds of "many-shot" in-context examples into a single, concise textual summary. This approach matches or exceeds the performance of many-shot learning while using up to 95% fewer tokens, eliminating the need for expensive test-time retrieval or massive input contexts.

What Problem Does This Paper Address?

In-context learning (ICL) allows Large Language Models (LLMs) to solve new tasks simply by looking at a few examples (few-shot). Recent "many-shot" ICL—providing hundreds of examples—has shown massive performance gains, but it comes with a steep "token tax." Processing 150+ examples for every single query is computationally expensive, slow, and hits context window limits.

Existing alternatives like Retrieval-based ICL (searching for the most relevant examples for each query) reduce the token count but introduce a new bottleneck: you have to perform a search operation at every inference step. The authors ask: Can we extract the underlying patterns from many examples once and use that "cheat sheet" for all future queries?

Methods

The authors propose a two-stage pipeline:

  1. Cheat-sheet Creation (Offline): The LLM is presented with a large pool of demonstrations (e.g., 150 examples). It is prompted to identify the most difficult patterns and distill the "core knowledge" into a concise textual summary—the cheat sheet. This happens only once per task.
  2. Inference (Online): When a new test question arrives, the LLM is given the cheat sheet, just two formatting examples (to ensure the output style is correct), and the test input.

Crucially, they use Rationale Augmentation (specifically X-ICL), where demonstrations include the "Chain of Thought" reasoning steps. This helps the model better understand the logic it needs to summarize.

Datasets

The study focuses on tasks where many-shot learning actually provides a significant boost over few-shot learning:

  • BIG-Bench Hard (BBH): Eight challenging reasoning tasks including Boolean Expressions, Causal Judgement, Disambiguation QA, and Geometric Shapes.
  • Academic Benchmarks: MATH500, GSM8K, and GPQA. Interestingly, the authors found many-shot ICL didn't significantly help here, likely because modern LLMs have already internalized this academic knowledge during pre-training.

Key Insights and Ideas

  • The "Aha" Moment - Interpretability: Unlike a list of 150 raw examples, a cheat sheet is human-readable. In the Disambiguation QA task, the model initially struggled. By reading the generated cheat sheet, the researchers found the model was over-relying on "common sense" instead of logic. They manually edited one line of the cheat sheet to tell the model to ignore world knowledge, which immediately boosted accuracy from 87.0 to 89.7.
  • Knowledge Transferability: A cheat sheet generated by a high-end model (like GPT-4) can be used effectively by a smaller, faster model (like Gemini 2.0 Flash). The "knowledge" distilled by the smarter model remains valid for the more efficient one.
  • Pattern Recognition vs. General Knowledge: The method works best on tasks that require "pattern recognition" within a specific dataset rather than general world knowledge. If a model already knows how to do math, 100 extra math examples don't help; but if a task has specific, quirky rules, the cheat sheet is invaluable.

Key Results

  • Efficiency: On the BBH benchmarks, Cheat-sheet ICL achieved 90.0% accuracy using only 2,036 tokens. For comparison, 150-shot ICL achieved 91.0% but required 42,461 tokens.
  • Cost & Speed: For the Boolean Expressions task, Cheat-sheet ICL was roughly 18x cheaper and 1.8x faster than many-shot ICL.
  • Vs. Retrieval: Cheat-sheet ICL performed comparably to state-of-the-art retrieval methods (like BM25 or Cosine similarity) but without the overhead of searching a database for every query.

Limitations and Future Work

  • Reasoning Focus: The study primarily looked at reasoning tasks where logic can be explicitly stated. It’s unclear how well this distills "vibe-based" tasks like creative writing or nuanced dialogue generation.
  • The "Many-Shot" Prerequisite: This method only provides a benefit if the task is one where many-shot ICL actually outperforms few-shot ICL. If the model is already "saturated" on a task, a cheat sheet won't help.
  • Distillation Cost: While inference is cheap, the initial step of creating the cheat sheet requires a model capable of processing a very long context (up to 250k tokens in this study). This limits the initial creation phase to top-tier proprietary models for now.

Summary updated

BibTeX
@misc{honda2025distilling,
  author = {Ukyo Honda and Soichiro Murakami and Peinan Zhang},
  title = {{Distilling Many-Shot In-Context Learning into a Cheat Sheet}},
  year = {2025},
  eprint = {2509.20820},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.20820},
}
Figure