Layer by layer, module by module: Choose both for optimal OOD probing of ViT

📄 arXiv: 2603.05280v1 📥 PDF

作者: Ambroise Odonnat, Vasilii Feofanov, Laetitia Chapel, Romain Tavenard, Ievgen Redko

分类: cs.CV, cs.LG, stat.ML

发布日期: 2026-03-05

备注: Accepted at ICLR 2026 CAO Workshop


💡 一句话要点

针对ViT,提出层与模块选择性OOD探测方法,优化分布偏移下的性能。

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 视觉Transformer 分布偏移 线性探测 OOD探测 中间层表示

📋 核心要点

  1. 现有研究表明,深度模型中间层可能比最后一层包含更具区分性的信息,但原因尚不明确。
  2. 该论文提出一种选择性探测方法,针对不同分布偏移程度,选择Transformer中不同层和模块进行探测。
  3. 实验表明,在分布偏移较大时,探测前馈网络激活更优;偏移较小时,多头自注意力模块归一化输出更优。

📝 摘要(中文)

最近的研究表明,基础模型的中间层通常比最后一层产生更具区分性的表示。虽然最初归因于自回归预训练,但在通过监督和判别自监督目标训练的模型中也发现了这种现象。本文对预训练视觉Transformer中中间层的行为进行了全面研究。通过对各种图像分类基准进行广泛的线性探测实验,我们发现预训练和下游数据之间的分布偏移是导致更深层性能下降的主要原因。此外,我们还进行了模块级别的细粒度分析。我们的研究结果表明,Transformer块输出的标准探测方法并非最优;相反,在显著的分布偏移下,探测前馈网络中的激活能产生最佳性能,而在偏移较弱时,多头自注意力模块的归一化输出是最优的。

🔬 方法详解

问题定义:论文旨在解决视觉Transformer(ViT)在预训练和下游任务存在分布偏移(Distribution Shift)时,如何选择最优的中间层和模块进行Out-of-Distribution (OOD)探测的问题。现有方法通常直接探测Transformer块的输出,忽略了不同层和模块对分布偏移的敏感性差异,导致性能下降。

核心思路:论文的核心思路是,通过细粒度的分析,揭示ViT中不同层和模块对分布偏移的响应差异,并根据分布偏移的程度,自适应地选择最佳的探测位置。这种选择性探测能够更有效地利用ViT的中间层表示,提升OOD探测的性能。

技术框架:论文的技术框架主要包括以下几个步骤:1) 对预训练的ViT模型进行线性探测,分别探测不同层和模块的输出;2) 通过一系列图像分类基准测试,评估不同探测位置的性能;3) 分析性能与分布偏移之间的关系,确定最佳的探测策略。主要模块包括Transformer块、多头自注意力(MHSA)模块和前馈网络(FFN)。

关键创新:论文的关键创新在于,它首次揭示了ViT中不同模块对分布偏移的敏感性差异,并提出了基于分布偏移程度的选择性探测方法。与现有方法相比,该方法能够更有效地利用ViT的中间层表示,提升OOD探测的性能。

关键设计:论文的关键设计包括:1) 细粒度的模块级分析,区分了MHSA和FFN对分布偏移的不同响应;2) 基于线性探测的性能评估,客观地反映了不同探测位置的表示能力;3) 针对不同分布偏移程度的自适应选择策略,实现了性能的优化。

📊 实验亮点

实验结果表明,在存在显著分布偏移的情况下,探测前馈网络(FFN)的激活能够获得最佳性能,而在分布偏移较弱时,多头自注意力(MHSA)模块的归一化输出是最优选择。该方法在多个图像分类基准测试中均取得了显著的性能提升,验证了其有效性。

🎯 应用场景

该研究成果可应用于各种需要检测分布偏移的场景,例如自动驾驶中的异常检测、医疗图像诊断中的疾病识别、以及金融风控中的欺诈检测。通过选择最优的探测位置,可以提高检测的准确性和鲁棒性,从而降低风险,提升系统的可靠性。

📄 摘要(原文)

Recent studies have observed that intermediate layers of foundation models often yield more discriminative representations than the final layer. While initially attributed to autoregressive pretraining, this phenomenon has also been identified in models trained via supervised and discriminative self-supervised objectives. In this paper, we conduct a comprehensive study to analyze the behavior of intermediate layers in pretrained vision transformers. Through extensive linear probing experiments across a diverse set of image classification benchmarks, we find that distribution shift between pretraining and downstream data is the primary cause of performance degradation in deeper layers. Furthermore, we perform a fine-grained analysis at the module level. Our findings reveal that standard probing of transformer block outputs is suboptimal; instead, probing the activation within the feedforward network yields the best performance under significant distribution shift, whereas the normalized output of the multi-head self-attention module is optimal when the shift is weak.