Understanding Emergent In-Context Learning from a Kernel Regression Perspective
Chi Han Affiliation: Ziqi Wang Affiliation: Han Zhao Affiliation: Heng Ji Affiliation: Siebel School of Computing and Data Science Affiliation: University of Illinois Urbana-Champaign
Abstract
Large language models (LLMs) have initiated a paradigm shift in transfer learning. In contrast to the classic pretraining-then-finetuning procedure, in order to use LLMs for downstream prediction tasks, one only needs to provide a few demonstrations, known as in-context examples, without adding more or updating existing model parameters. This in-context learning (ICL) capability of LLMs is intriguing, and it is not yet fully understood how pretrained LLMs acquire such capabilities. In this paper, we investigate the reason why a transformer-based language model can accomplish in-context learning after pre-training on a general language corpus by proposing a kernel-regression perspective of understanding LLMs’ ICL bahaviors when faced with in-context examples. More concretely, we first prove that Bayesian inference on in-context prompts can be asymptotically understood as kernel regression $\hat{y}=\sum_{i}y_{i}K(x,x_{i})/\sum_{i}K(x,x_{i})$ as the number of in-context demonstrations grows. Then, we empirically investigate the in-context behaviors of language models. We find that during ICL, the attention and hidden features in LLMs match the behaviors of a kernel regression. Finally
原文 arXiv:2305.12766;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2305.12766v3