模型越遇陌生输入,内部表征越稀疏,这是应对复杂任务的自适应机制。
Farther the Shift, Sparser the Representation: Analyzing OOD Mechanisms in LLMs
- 通过分析模型隐藏状态,发现输入越偏离分布,表征越稀疏。
- 在不同模型和任务中,表征稀疏性与任务难度呈稳定正相关。
- 利用稀疏性设计新学习策略,显著提升少样本推理性能。
本文研究大型语言模型(LLMs)在面对越来越困难的输入时,其内部表征如何变化,以偏移程度衡量出域(OOD)程度。我们发现一个一致且可量化的现象:随着任务难度增加——无论是更复杂的推理问题、更长的上下文,还是加入选项——模型最后一层隐藏状态变得显著稀疏。简言之,'越远离分布,表征越稀疏'。这一稀疏性-难度关系在多种模型和领域中均可见,表明语言模型会将计算集中到最后一层隐藏状态的特定子空间,以应对陌生或复杂输入。通过一系列受控分析,我们证明这种稀疏性并非偶然,而是稳定推理的自适应机制。基于此洞察,我们提出‘稀疏性引导的课程式上下文学习’(SG-ICL),显式利用表征稀疏性来调度少样本示例,带来显著性能提升。本研究为理解模型如何内化OOD挑战提供了新的机制视角。代码已开源:https://github.com/MingyuJ666/sparsityLLM。
原文摘要 · Abstract (English)
In this work, we investigate how Large Language Models (LLMs) adapt their internal representations when encountering inputs of increasing difficulty, quantified as the degree of out-of-distribution (OOD) shift. We reveal a consistent and quantifiable phenomenon: as task difficulty increases, whether through harder reasoning questions, longer contexts, or adding answer choices, the last hidden states of LLMs become substantially sparser. In short, \textbf{\textit{the farther the shift, the sparser the representations}}. This sparsity--difficulty relation is observable across diverse models and domains, suggesting that language models respond to unfamiliar or complex inputs by concentrating computation into specialized subspaces in the last hidden state. Through a series of controlled analyses with a learning dynamic explanation, we demonstrate that this sparsity is not incidental but an adaptive mechanism for stabilizing reasoning under OOD. Leveraging this insight, we design \textit{Sparsity-Guided Curriculum In-Context Learning (SG-ICL)}, a strategy that explicitly uses representation sparsity to schedule few-shot demonstrations, leading to considerable performance enhancements. Our study provides new mechanistic insights into how LLMs internalize OOD challenges. The source code is available at the URL: https://github.com/MingyuJ666/sparsityLLM.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。