Demonstration Augmentation for Zero-shot In-context Learning

Yi Su, Yunpeng Tai, Yixin Ji, Juntao Li, Yan Bowen, Min Zhang

Introduction

In-context Learning (ICL) has revolutionized how we interact with Large Language Models (LLMs), enabling them to perform complex tasks by simply providing a few examples within the prompt. However, traditional few-shot ICL relies heavily on high-quality, human-annotated datasets, which are costly and difficult to scale. Conversely, standard zero-shot methods often struggle with complex reasoning or specific formatting requirements.

To bridge this gap, researchers have introduced Demonstration Augmentation for In-context Learning (DAIL). DAIL transforms zero-shot inference into a "pseudo-few-shot" process by dynamically recycling a model's own previous predictions as demonstrations for future queries. This approach significantly boosts accuracy on benchmarks like MMLU and BBH—often outperforming human-labeled few-shot examples—without the massive latency overhead associated with generative zero-shot methods like Self-ICL.

Methodology: The DAIL Framework

DAIL treats the inference process as a continuous stream rather than isolated events. Instead of generating synthetic examples on the fly, it maintains a Memory Bank of the model's interaction history. The workflow is iterative, as illustrated in the following diagram:

The DAIL workflow showing the iterative update of the Memory Bank across steps t and t+1.

The framework relies on three core strategies:

  1. Entry Strategy: Once the model predicts a label for a user query, the resulting (Query, Predicted Label) pair is stored in a memory bank of size $M$. This allows the model to "learn" from its own recent outputs.
  2. Selection Strategy: For each new query, the system retrieves the $K$ most relevant demonstrations from the bank. This selection is governed by a multi-faceted scoring system including semantic similarity (via Sentence-BERT or BM25) and an Entropy Score. The Entropy Score analyzes the model's output distribution; lower entropy indicates higher confidence in the historical prediction, serving as a proxy for label reliability.
  3. Deletion Strategy: To manage the memory bank's capacity, a "Diverse" deletion strategy is used. When the bank is full, it removes samples that are most similar to others in the bank, preserving the overall representativeness of the history.

Experimental Results

The authors evaluated DAIL across several state-of-the-art LLMs, including LLaMA-2, Mistral, OpenChat, and GPT-4, using the MMLU (Massive Multitask Language Understanding) and BBH (BIG-bench Hard) benchmarks.

  • Performance Gains: On MMLU, DAIL consistently outperformed standard zero-shot baselines. For instance, using Mistral-7B, DAIL achieved an accuracy of 62.80%, surpassing both the zero-shot baseline (58.83%) and even human-labeled few-shot performance (61.90%).
  • State-of-the-Art in Zero-Shot: On the challenging BBH benchmark, DAIL paired with GPT-4 reached 73.47% accuracy, exceeding the previous state-of-the-art generative zero-shot method, Self-ICL, which scored 70.81%.
  • Robustness: DAIL proved more stable than synthetic generation methods. In tasks like "Causal Judgment," where Self-ICL caused performance to plummet (from 42% to 12%), DAIL improved it to 57%.

Efficiency Analysis

A critical advantage of DAIL is its computational efficiency. Generative zero-shot methods like Self-ICL require multiple generation passes per query to create synthetic demonstrations, leading to exponential increases in latency as sequence lengths grow. In contrast, DAIL only requires a fast similarity search within a small memory bank.

Comparison of latency (inference time) vs. token length for various methods, highlighting the high cost of Self-ICL compared to standard and few-shot approaches.

As shown in the figure above, the overhead for DAIL is virtually negligible compared to standard ICL, whereas Self-ICL's generation-heavy approach becomes prohibitively slow for long-context tasks. By recycling real human queries, DAIL also avoids the risk of "hallucinated" or low-quality synthetic demonstrations that can degrade model performance.

Conclusion and Limitations

DAIL offers a pragmatic path toward high-performance zero-shot learning by leveraging the "warm-up" effect of user interactions. By treating human queries as high-quality context and using pseudo-labels filtered by confidence, it achieves few-shot accuracy with zero-shot data requirements.

However, some limitations remain. Calculating the Entropy Score requires access to model logits, which are often unavailable in black-box APIs. Additionally, storing user queries in a memory bank introduces potential privacy concerns that must be addressed in production environments. Future work will likely explore DAIL's effectiveness in open-ended creative tasks and strategies to mitigate the "cold start" problem when the memory bank is initially empty.

Summary updated

BibTeX
@inproceedings{su2024demonstration,
  author = {Yi Su and Yunpeng Tai and Yixin Ji and Juntao Li and Yan Bowen and Min Zhang},
  title = {{Demonstration Augmentation for Zero-shot In-context Learning}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.846},
}
Figure