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

Ukyo Honda, Soichiro Murakami, Peinan Zhang

TL;DR

"Cheat-sheet In-Context Learning" (cheat-sheet ICL) is a novel approach that distills the knowledge from hundreds of many-shot demonstrations into a single, concise textual summary. By using this "cheat sheet" at inference time along with just two formatting examples, LLMs can match or exceed many-shot performance at a fraction of the computational and financial cost, completely bypassing the need for test-time retrieval.

What Problem Does This Paper Address?

In-context learning (ICL) has traditionally been limited to a few-shot setup due to strict context window constraints. However, recent large language models (LLMs) boast massive context windows, giving rise to "many-shot ICL"—a paradigm where models are fed dozens or hundreds of task examples. While many-shot ICL significantly boosts accuracy on complex reasoning tasks, it comes with a massive downside: high computational overhead, slower inference times, and soaring API costs.

Alternative methods like retrieval-based ICL mitigate this by searching for and injecting only the most relevant examples for each query. However, this introduces a new bottleneck: you must maintain a demonstration database and run a retrieval step for every single test input. The authors of this paper ask a compelling question: Can we compress the collective knowledge of hundreds of examples into a compact, static text format that the LLM can use directly?

Figure 1: Overview of many-shot, retrieval-based, and our cheat-sheet ICL. Many-shot ICL processes numer- ous demonstrations at every inference; retrieval-based ICL involves storing and searching them. Cheat-sheet ICL uses a compact cheat sheet distilled from demon- strations, which only needs to be created once.

Methods

The authors introduce cheat-sheet ICL, a training-free method divided into two main phases:

  1. Cheat-Sheet Creation (Preprocessing): The entire pool of training demonstrations is first augmented with model-generated rationales (using an efficient single-pass explanation sampling method based on X-ICL). The LLM is then presented with all of these rationale-augmented examples and prompted to act as a student creating an exam cheat sheet. It identifies difficult patterns and synthesizes the core knowledge, rules, and edge cases into a concise textual summary. Crucially, this step is performed only once per task.
  2. Inference: When a new test query arrives, the LLM is provided with the static cheat sheet, the test input, and exactly two demonstrations (used purely as formatting instructions).

Datasets

The authors evaluated their method on challenging reasoning benchmarks. To ensure a rigorous evaluation, they filtered for datasets where many-shot ICL genuinely provides a benefit over few-shot ICL (improving accuracy by more than one percentage point).

This resulted in the selection of eight tasks from BIG-Bench Hard (BBH):

  • Boolean Expressions
  • Causal Judgement
  • Disambiguation QA
  • Geometric Shapes
  • Movie Recommendation
  • Salient Translation Error Detection
  • Sports Understanding
  • Word Sorting

They also analyzed academic datasets (MATH500, GSM8K, and GPQA), but found that many-shot ICL actually degraded performance or offered no gains on these tasks due to formatting distractions and the general nature of the pre-trained knowledge required.

Key Insights and Ideas

  • LLMs as Meta-Learners: The core insight is that advanced LLMs possess sufficient language understanding to explicitly formalize their own latent task strategies into human-readable text.
  • Human-in-the-Loop Interpretability: Because the distilled cheat sheet is plain text, it is fully interpretable. In the Disambiguation QA task, the authors noticed the model was failing by over-relying on common-sense assumptions. By manually editing a single line in the cheat sheet to explicitly forbid common-sense priors, they boosted accuracy from 87.0% to 89.7%.
  • Cross-Model Transferability: Cheat sheets exhibit strong transferability. A cheat sheet generated by GPT-4.1 can be successfully utilized by a completely different model, such as Gemini 2.0 Flash, yielding similar performance gains.

Key Results

  • High Efficiency, Low Cost: On the Boolean Expressions task, a standard 150-shot prompt required an average of 23,921 input tokens and cost \$1.196 per test set run. Cheat-sheet ICL cut the input down to just 1,306 tokens (comparable to an 8-shot budget) and reduced the cost to \$0.065, while maintaining identical or superior accuracy.
  • Outperforming Many-Shot: As shown in the experimental results, cheat-sheet ICL consistently outperformed conventional few-shot baselines and achieved comparable or superior accuracy to full many-shot ICL across seven out of the eight BBH tasks.
Figure 2: Main results obtained with GPT-4.1. Scores are averaged over three runs.
  • Matching Retrieval Methods: Cheat-sheet ICL achieved an average accuracy of 90.0% across the BBH tasks, performing on par with or better than state-of-the-art retrieval methods like Cosine similarity (89.1%) and Set-BSR (89.0%), without any test-time search overhead.

Limitations and Future Work

  • Scope of Tasks: The study focused strictly on reasoning tasks where knowledge can be explicitly structured. The authors note that future work is needed to see if this approach translates well to less structured tasks like dialogue generation or creative writing.
  • Dependence on Many-Shot Viability: Cheat-sheet ICL is only effective on tasks where many-shot learning itself works. If an LLM's pre-trained weights already master a task (as seen in the academic math benchmarks), adding a cheat sheet provides no additional benefit.
  • Upfront Compute: Generating the cheat sheet requires a massive initial context call to process all demonstrations, though this cost is amortized over all subsequent inferences.

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