mlsanityData to 14 Oct 2026

From Compression to Expression: A Layerwise Analysis of In-Context Learning

arXiv 2505.17322 ↗First posted 22 May 2025cs.CL cs.AI cs.LGcited by 6

On the map: Offline RL and imitation learning from data → Language-conditioned policies and VLAs

Abstract (arXiv)

In-context learning (ICL) enables large language models (LLMs) to adapt to new tasks without weight updates by learning from demonstration sequences. While ICL shows strong empirical performance, its internal representational mechanisms are not yet well understood. In this work, we conduct a statistical geometric analysis of ICL representations to investigate how task-specific information is captured across layers. Our analysis reveals an intriguing phenomenon, which we term *Layerwise Compression-Expression*: early layers progressively produce compact and discriminative representations that encode task information from the input demonstrations, while later layers express these representations to incorporate the query and generate the prediction. This phenomenon is observed consistently across diverse tasks and a range of contemporary LLM architectures. We demonstrate that it has important implications for ICL performance -- improving with model size and the number of demonstrations -- and for robustness in the presence of noisy examples. To further understand the effect of the compact task representation, we propose a bias-variance decomposition and provide a theoretical analysis showing how attention mechanisms contribute to reducing both variance and bias, thereby enhancing performance as the number of demonstrations increases. Our findings reveal an intriguing layerwise dynamic in ICL, highlight how structured representations emerge within LLMs, and showcase that analyzing internal representations can facilitate a deeper understanding of model behavior.

Key facts. Cited by 6 papers in the map (data through 14 Oct 2026). Placed in Language-conditioned policies and VLAs, one of 13 directions in Offline RL and imitation learning from data. Builds on 40 of its 51 references that are in the map. First posted on arXiv 22 May 2025.

Builds on

40 of 51 references.

References · 40

  1. 2020Language Models are Few-Shot Learnerscited by 32,419
  2. 2024The Llama 3 Herd of Modelscited by 14,715
  3. 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,718
  4. 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
  5. 2023Qwen Technical Reportcited by 3,344
  6. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
  7. 2023Pythia: A Suite for Analyzing Large Language Models Across Training and Scalingcited by 1,786
  8. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  9. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
  10. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
  11. 2022Transformers learn in-context by gradient descentcited by 732
  12. 2020Prevalence of Neural Collapse during the terminal phase of deep learning trainingcited by 719
28 more
  1. 2024ShortGPT: Layers in Large Language Models are More Redundant Than You Expectcited by 383
  2. 2018Efficient Attention: Attention with Linear Complexitiescited by 368
  3. 2020DeeBERT: Dynamic Early Exiting for Accelerating BERT Inferencecited by 332
  4. 2023In-Context Learning Creates Task Vectorscited by 312
  5. 2025Layer by Layer: Uncovering Hidden Representations in Language Modelscited by 311
  6. 2023Function Vectors in Large Language Modelscited by 308
  7. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
  8. 2023In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steeringcited by 245
  9. 2023Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learningcited by 236
  10. 2021A Geometric Analysis of Neural Collapse with Unconstrained Featurescited by 227
  11. 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
  12. 2021Exploring Deep Neural Networks via Layer-Peeled Model: Minority Collapse in Imbalanced Trainingcited by 166
  13. 2021Meta-learning via Language Model In-context Tuningcited by 164
  14. 2020Learning Diverse and Discriminative Representations via the Principle of Maximal Coding Rate Reductioncited by 142
  15. 2023LLM360: Towards Fully Transparent Open-Source LLMscited by 104
  16. 2021On the Role of Neural Collapse in Transfer Learningcited by 100
  17. 2023How Does Information Bottleneck Help Deep Learning?cited by 93
  18. 2023In-Context Learning Learns Label Relationships but Is Not Conventional Learningcited by 51
  19. 2023Generalized Neural Collapse for a Large Number of Classescited by 39
  20. 2024Tracing Representation Progression: Analyzing and Enhancing Layer-Wise Similaritycited by 36
  21. 2023Understanding Deep Representation Learning via Layerwise Feature Compression and Discriminationcited by 32
  22. 2025Adaptive Layer-skipping in Pre-trained LLMscited by 27
  23. 2022Nearest Class-Center Simplification through Intermediate Layerscited by 20
  24. 2024How do Large Language Models Learn In-Context? Query and Key Matrices of In-Context Heads are Two Towers for Metric Learningcited by 18
  25. 2024In-Context Learning State Vector with Inner and Momentum Optimizationcited by 15
  26. 2024A Law of Next-Token Prediction in Large Language Modelscited by 15
  27. 2024The representation landscape of few-shot learning and fine-tuning in large language modelscited by 15
  28. 2024DETAIL: Task DEmonsTration Attribution for Interpretable In-context Learningcited by 5

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 3; 2026: 3.

6 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024Does In-Context Learning Really Learn? Rethinking How Large Language Models Respond and Solve Tasks via In-Context Learning
  2. 2025On the Relationship Between the Choice of Representation and In-Context Learning
  3. 2023Is attention required for ICL? Exploring the Relationship Between Model Architecture and In-Context Learning Ability
  4. 2025Illusion or Algorithm? Investigating Memorization, Emergence, and Symbolic Processing in In-Context Learning
  5. 2026The Alchemy of Thought: Understanding In-Context Learning Through Supervised Classification
  6. 2024Revisiting In-context Learning Inference Circuit in Large Language Models
  7. 2024Can Custom Models Learn In-Context? An Exploration of Hybrid Architecture Performance on In-Context Learning Tasks
  8. 2024Focused Large Language Models are Stable Many-Shot Learners