Probing Transformer Representations Layer by Layer, Module by Module

LLM Other LLM ML Transformer CV Backbone
在基于Transformer的基础模型中,究竟应探测哪一类表征?近期研究表明,当前普遍采用的仅探测最终层的做法往往并非最优,因为中间层有时能提供更优的特征。然而,现有研究仍主要沿“深度”这一单一维度考察表征,将每个Transformer模块块(block)视为不可分割的原子单元。本文则对Transformer的表征进行逐层、逐模块的细致分析。我们针对视觉基础模型(VFMs)和大语言模型(LLMs),开展了逾14.4万次线性探测评估,结果表明:层(layer)与模块(module)的选择应联合考虑——相较于固定使用残差流(residual stream)而仅优化选择哪一层,选取最优的“层–模块”组合能在最终层残差流基础上带来显著更大的性能提升。此外,同一模块在不同层上的表现差异可能极大,这说明仅凭深度无法充分刻画表征的有用性。基于上述发现,我们进一步评估了两种简单且固定的探测策略:对视觉任务采用最终层的前馈网络激活值(Act@100),对语言任务则采用位于模型60%深度处的第二个归一化层输出(LN2@60)。实验表明,这两种策略在多数评估任务中均优于标准探测基线;平均而言,它们分别可恢复最优“层–模块”组合探测增益的42%(视觉)和86%(语言)。对于视觉基础模型,此类增益随预训练数据与下游任务数据之间迁移难度的增大而进一步提升。
Which representation should be probed in a transformer-based foundation model? Recent work shows that the standard practice of probing the final layer is often suboptimal, as intermediate layers can provide better features. Yet, representations are still largely studied along depth alone, treating each transformer block as an atomic unit. In this work, we analyze transformer representations layer by layer, module by module. Through more than 144,000 linear probing evaluations of vision foundation models (VFMs) and large language models (LLMs), we show that layer and module choices should be considered jointly: the best layer-module pair yields substantially larger gains over the final-layer residual stream than the best layer with the residual stream fixed. Moreover, module performance can vary substantially across layers, showing that useful representations cannot be characterized by depth alone. Building on these findings, we evaluate simple fixed probing strategies: the final-layer feedforward activation (Act@100) for vision and the second normalization layer at 60% depth (LN2@60) for language. These strategies improve over the probing baseline in a majority of evaluations and recover, on average, 42% and 86% of the gains from probing the best layer-module pair for vision and language, respectively. For VFMs, these gains increase with the transfer difficulty between pretraining and downstream data.
许愿