Unveiling the Flow of Input-label Mappings for In-context Learning

Authors: Chenghao Sun, Zhen Huang, Yonggang Zhang, Le Lu, Houqiang Li, Xinmei Tian, Xu Shen, Jieping Ye
Primary area: interpretability and explainable AI
Keywords: Large Language Model; In-Context Learning

Abstract:
Large language models (LLMs) excel at processing complex tasks by in-context learning (ICL). However, the internal mechanisms behind ICL remain mysteri- ous, e.g., where does the input-label mappings store inside LLMs, and which modules allow for generalizing these mappings to new question. In this work, we make a substantial step towards reverse-engineering the ICL: (1) Applying a linear model, i.e., Principle Component Analysis (PCA), on the hidden states, we find that LLMs distill the semantic mappings into the principal components (PC) at only a small number of layers. (2) Traditional method to identify the ability-related modules relies heavily on pairs of reference and counterfactual samples, which are designed to activate and not activate the behavior, respectively. However, because of the persistent nature of ICL ability, it is difficult to design counterfactual discrete texts which do not involve ICL. To address this, we introduce PC Patching, which engineers the representation with the identified semantic mappings, rather than text. By subtracting the PC from the original features, the input-label mappings are suppressed, resulting in the counterfactual continuous activations for ICL. The results of PC Patching unveil that there is a small fraction (5%) of attention heads that drive LLMs to process the input-label mappings for the final answer. These insights prompt us to investigate the potential benefits of selectively fine-tuning these essential heads to boost the LLMs’ ICL performance. We empirically find that such precise tuning can yield notable enhancements on unseen ICL tasks. The promising applications on other scenarios, i.e., trustworthiness, further validate the effectiveness of our method. Our work serves as an exploration into the ICL and pave the way to scaling ICL for more intricate tasks.

Decision: reject

Reviews and discussion:

Metareview: