Table of Contents
Fetching ...

Unveiling In-Context Learning: A Coordinate System to Understand Its Working Mechanism

Anhao Zhao, Fanghua Ye, Jinlan Fu, Xiaoyu Shen

TL;DR

This work provides a Two-Dimensional Coordinate System that unifies both views on ICL into a systematic framework and proposes the peak inverse rank metric to detect the task recognition ability of LLMs and study LLMs’ reactions to different definitions of similarity.

Abstract

Large language models (LLMs) exhibit remarkable in-context learning (ICL) capabilities. However, the underlying working mechanism of ICL remains poorly understood. Recent research presents two conflicting views on ICL: One emphasizes the impact of similar examples in the demonstrations, stressing the need for label correctness and more shots. The other attributes it to LLMs' inherent ability of task recognition, deeming label correctness and shot numbers of demonstrations as not crucial. In this work, we provide a Two-Dimensional Coordinate System that unifies both views into a systematic framework. The framework explains the behavior of ICL through two orthogonal variables: whether similar examples are presented in the demonstrations (perception) and whether LLMs can recognize the task (cognition). We propose the peak inverse rank metric to detect the task recognition ability of LLMs and study LLMs' reactions to different definitions of similarity. Based on these, we conduct extensive experiments to elucidate how ICL functions across each quadrant on multiple representative classification tasks. Finally, we extend our analyses to generation tasks, showing that our coordinate system can also be used to interpret ICL for generation tasks effectively.

Unveiling In-Context Learning: A Coordinate System to Understand Its Working Mechanism

TL;DR

This work provides a Two-Dimensional Coordinate System that unifies both views on ICL into a systematic framework and proposes the peak inverse rank metric to detect the task recognition ability of LLMs and study LLMs’ reactions to different definitions of similarity.

Abstract

Large language models (LLMs) exhibit remarkable in-context learning (ICL) capabilities. However, the underlying working mechanism of ICL remains poorly understood. Recent research presents two conflicting views on ICL: One emphasizes the impact of similar examples in the demonstrations, stressing the need for label correctness and more shots. The other attributes it to LLMs' inherent ability of task recognition, deeming label correctness and shot numbers of demonstrations as not crucial. In this work, we provide a Two-Dimensional Coordinate System that unifies both views into a systematic framework. The framework explains the behavior of ICL through two orthogonal variables: whether similar examples are presented in the demonstrations (perception) and whether LLMs can recognize the task (cognition). We propose the peak inverse rank metric to detect the task recognition ability of LLMs and study LLMs' reactions to different definitions of similarity. Based on these, we conduct extensive experiments to elucidate how ICL functions across each quadrant on multiple representative classification tasks. Finally, we extend our analyses to generation tasks, showing that our coordinate system can also be used to interpret ICL for generation tasks effectively.
Paper Structure (59 sections, 1 equation, 20 figures, 12 tables)

This paper contains 59 sections, 1 equation, 20 figures, 12 tables.

Figures (20)

  • Figure 1: An overview of the proposed two-dimensional coordinate system for ICL. The y-axis represents cognition, indicating the model's ability to recognize tasks during ICL, while the x-axis represents perception, reflecting whether similar examples are included in the demonstrations.
  • Figure 2: The PIR of "capital" at the last label token using Llama-2-7B, before and after replacing labels.
  • Figure 3: The average ICL accuracy for $\text{Similiar}({\text{T}}$) with correct and incorrect labels, and ICL without similar examples.
  • Figure 4: The PIR of "color" at the label token of $\text{Similiar}({\text{T}}$), when the label of $\text{Similiar}({\text{T}}$) is correct and incorrect.
  • Figure 5: In the 20th layer, the attention scores of the last token ":" for all tokens. All label tokens are marked in red.
  • ...and 15 more figures