揭示大模型上下文学习中分层压缩与表达的内在机制
From Compression to Expression: A Layerwise Analysis of In-Context Learning
- 早期层压缩演示数据,提取任务特征;后期层结合查询生成预测
- 模型越大、示范越多,性能越强,且对噪声更鲁棒
- 首次从偏差-方差角度解释注意力提升表现的原理
上下文学习(ICL)使大语言模型在不更新权重的情况下,通过示例序列适应新任务。尽管其表现优异,但内部表征机制尚不明确。本文通过统计几何分析发现,各层存在一种分层压缩-表达现象:早期层逐步生成紧凑且具有区分性的表示,编码输入示例中的任务信息;后期层则将这些表示用于融合查询并生成预测。该现象在多种任务和主流大模型架构中一致出现。结果表明,此机制随模型规模和示例数量增加而增强,并提升对噪声示例的鲁棒性。我们进一步提出偏差-方差分解,理论分析显示注意力机制可同时降低偏差与方差,从而在更多示例下提升性能。研究揭示了大模型中结构化表示的形成动态,为理解模型行为提供了新视角。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。