arXiv:2409.04185cs.LGcs.CL2024-09ICLR被引 21

用统一模型分析跨层残差流,发现激活模式随文本变化

Residual Stream Analysis with Multi-Layer SAEs

  • 用一个自编码器同时训练所有层的残差流激活向量
  • 单个激活单元通常只在特定层活跃,跨层激活差异大
  • 大模型中跨层激活更普遍,适合研究表示演化过程

稀疏自编码器(SAEs)是解释Transformer语言模型内部表征的有前景方法。然而,传统SAE通常在每层单独训练,难以研究信息跨层流动。为此,我们提出多层SAE(MLSAE):一个在所有Transformer层的残差流激活向量上联合训练的单一SAE。由于残差流被认为能保留跨层信息,我们预期MLSAE的隐变量会在某令牌位置激活后持续保持活跃。但有趣的是,我们发现大多数隐变量对特定提示或令牌仅在一个层活跃,且不同提示下激活的层数可能不同。通过定义层分布并分析其方差,我们发现:当聚合多个令牌时,隐变量激活的层方差比单个令牌高出约两个数量级。对于更大规模的模型,隐变量在多层活跃的程度更高,这与相邻层残差流向量更相似的事实一致。最后,我们通过引入预训练微调透镜(tuned-lens)放松了残差流基底相同的假设,结果仍保持定性一致。我们的工作为理解表征在Transformer中的演化提供了新视角。代码已开源:https://github.com/tim-lawson/mlsae。

原文摘要 · Abstract (English)

Sparse autoencoders (SAEs) are a promising approach to interpreting the internal representations of transformer language models. However, SAEs are usually trained separately on each transformer layer, making it difficult to use them to study how information flows across layers. To solve this problem, we introduce the multi-layer SAE (MLSAE): a single SAE trained on the residual stream activation vectors from every transformer layer. Given that the residual stream is understood to preserve information across layers, we expected MLSAE latents to 'switch on' at a token position and remain active at later layers. Interestingly, we find that individual latents are often active at a single layer for a given token or prompt, but the layer at which an individual latent is active may differ for different tokens or prompts. We quantify these phenomena by defining a distribution over layers and considering its variance. We find that the variance of the distributions of latent activations over layers is about two orders of magnitude greater when aggregating over tokens compared with a single token. For larger underlying models, the degree to which latents are active at multiple layers increases, which is consistent with the fact that the residual stream activation vectors at adjacent layers become more similar. Finally, we relax the assumption that the residual stream basis is the same at every layer by applying pre-trained tuned-lens transformations, but our findings remain qualitatively similar. Our results represent a new approach to understanding how representations change as they flow through transformers. We release our code to train and analyze MLSAEs at https://github.com/tim-lawson/mlsae.

Transformer表征分析稀疏编码

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。