Enhancing In-Context Learning via Implicit Demonstration Augmentation

Xiaoling Zhou, Wei Ye, Yidong Wang, Chaoya Jiang, Zhemg Lee, Rui Xie, Shikun Zhang

Abstract

In-Context Learning (ICL) is a powerful capability of Large Language Models (LLMs), yet it remains highly sensitive to prompt variations and constrained by context window limits. This paper presents Implicit Demonstration Augmentation (IDAICL), a novel framework that enhances ICL by performing augmentation in the model's deep feature space. The authors mathematically demonstrate that infinite augmentation converges to a specific logit calibration, leading to the efficient IDA-Softmax method. Empirical results across multiple benchmarks show that IDAICL significantly boosts performance and stability without increasing computational overhead or input length.

Introduction

In-Context Learning (ICL) enables LLMs to adapt to new tasks by prepending a few examples (demonstrations) to the input prompt. Despite its success, ICL is notoriously "brittle"—performance fluctuates significantly based on example selection, ordering, and prompt templates. Furthermore, the finite context window of LLMs limits the number of demonstrations that can be included, often preventing the model from capturing the full distribution of the task.

Existing solutions typically focus on selecting better examples or post-hoc calibration. However, these methods often fail to address the underlying data scarcity within the prompt. IDAICL addresses this by leveraging the latent space of the model to implicitly expand the set of demonstrations.

Methodology: Implicit Demonstration Augmentation (IDAICL)

The core idea of IDAICL is to perform Semantic Augmentation within the model's deep feature space rather than the text space.

1. Feature-Level Augmentation

The authors observe that deep features in neural networks often exhibit linear properties. By sampling semantic directions ($\delta$) from the distribution of known examples, the representation of a demonstration can be "shifted" to create augmented versions.

2. The Infinite Augmentation Trick

Instead of generating a finite number of augmented features, which would be computationally expensive, the authors theoretically derive the limit as the number of augmented copies ($\mathcal{M}$) approaches infinity.

The IDAICL pipeline: from demonstration feature extraction to infinite augmentation and calibrated prediction.

3. IDA-Softmax and Logit Adjustment

This derivation results in a closed-form solution called IDA-Softmax. It refines the standard Softmax function by incorporating the mean ($\mu$) and covariance ($\Sigma$) of the demonstration features. To further improve performance on imbalanced datasets, a post-hoc logit adjustment term based on class proportions is added. This approach is "implicit" because it requires no additional text generation or multiple model passes; it simply modifies the final layer's output calculation based on the statistics of the demonstration pool.

Experimental Evaluation

The researchers evaluated IDAICL across 10 text classification benchmarks, including sentiment analysis (SST-2, SST-5, MR, CR, Amazon), subjectivity (Subj), question classification (TREC), and natural language inference (CB). These were tested on a variety of models ranging from GPT-2 (0.1B) to LLaMA (33B).

Key Results

IDAICL demonstrates substantial improvements over Vanilla ICL and other calibration baselines:

  • Performance Gains: On GPT-2, IDAICL improved average accuracy by approximately 18%.
  • Robustness: The method significantly reduces performance variance across different prompt templates and example orderings.
  • Scalability: The benefits of IDAICL persist and often increase as model size grows, outperforming state-of-the-art calibration methods like PROCA on LLaMA-33B.
Performance comparison of IDAICL vs. Vanilla ICL across various datasets, showing consistent accuracy improvements and reduced variance.

Discussion and Conclusion

The most significant contribution of IDAICL is the mathematical bridge it builds between data augmentation and logit calibration. By treating augmentation as a statistical adjustment in the latent space, IDAICL bypasses context window limitations and provides a more stable, "global" view of the task distribution.

Limitations

While effective, IDAICL requires access to the model's internal hidden states and final layer weights, limiting its applicability to open-source models. Future work includes extending this framework to open-ended generation tasks and exploring non-Gaussian feature distributions to further refine the augmentation process.

Summary updated

BibTeX
@inproceedings{zhou2024enhancing,
  author = {Xiaoling Zhou and Wei Ye and Yidong Wang and Chaoya Jiang and Zhemg Lee and Rui Xie and Shikun Zhang},
  title = {{Enhancing In-Context Learning via Implicit Demonstration Augmentation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.155},
}
Figure