Unifying Attention Heads and Task Vectors via Hidden State Geometry in In-Context Learning

Haolin Yang, Hakaze Cho, Yiqiao Zhong, Naoya Inoue
5/24/2025
cs.CL
transformer-attention

No confident code implementation found for this paper.

Abstract

The unusual properties of in-context learning (ICL) have prompted investigations into the internal mechanisms of large language models. Prior work typically focuses on either special attention heads or task vectors at specific layers, but lacks a unified framework linking these components to the evolution of hidden states across layers that ultimately produce the model's output.

Show full abstract

In this paper, we propose such a framework for ICL in classification tasks by analyzing two geometric factors that govern performance: the separability and alignment of query hidden states. A fine-grained analysis of layer-wise dynamics reveals a striking two-stage mechanism: separability emerges in early layers, while alignment develops in later layers. Ablation studies further show that Previous Token Heads drive separability, while Induction Heads and task vectors enhance alignment. Our findings thus bridge the gap between attention heads and task vectors, offering a unified account of ICL's underlying mechanisms.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yang2025unifying,
  title  = {Unifying Attention Heads and Task Vectors via Hidden State Geometry in In-Context Learning},
  author = {Haolin Yang and Hakaze Cho and Yiqiao Zhong and Naoya Inoue},
  year   = {2025},
  eprint = {2505.18752},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.18752v2},
  journal = {NEURIPS 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.18752.svg)](https://codeofpaper.com/paper/2505.18752)

Discussion