English

Batch-ICL: Effective, Efficient, and Order-Agnostic In-Context Learning

Machine Learning 2024-06-06 v3 Computation and Language

Abstract

In this paper, by treating in-context learning (ICL) as a meta-optimization process, we explain why LLMs are sensitive to the order of ICL examples. This understanding leads us to the development of Batch-ICL, an effective, efficient, and order-agnostic inference algorithm for ICL. Differing from the standard N-shot learning approach, Batch-ICL employs NN separate 1-shot forward computations and aggregates the resulting meta-gradients. These aggregated meta-gradients are then applied to the forward computation of a zero-shot query to generate the final prediction. This batch processing approach renders the LLM agnostic to the order of ICL examples. Through extensive experiments and analysis, we demonstrate that Batch-ICL consistently outperforms most permutations of ICL examples. In some cases, it even exceeds the performance of the best order for standard ICL, all while reducing the computational resources required. Furthermore, we develop a novel variant of Batch-ICL featuring multiple "epochs" of meta-optimization. This variant implicitly explores permutations of ICL examples, further enhancing ICL performance.

Keywords

Cite

@article{arxiv.2401.06469,
  title  = {Batch-ICL: Effective, Efficient, and Order-Agnostic In-Context Learning},
  author = {Kaiyi Zhang and Ang Lv and Yuhan Chen and Hansen Ha and Tao Xu and Rui Yan},
  journal= {arXiv preprint arXiv:2401.06469},
  year   = {2024}
}

Comments

This paper has been accepted by ACL 2024 (Findings)

R2 v1 2026-06-28T14:15:05.449Z