[论文解读] Analyzing Transformers in Embedding Space
本文提出了一种零次性、与输入无关的框架,通过将所有参数投影到词嵌入空间(即词汇项空间)来解释训练好的Transformer模型的所有参数。通过利用嵌入矩阵及其右逆矩阵,作者将注意力权重和前馈网络权重重新解释为词汇项之间的交互,从而实现无需微调的模型对齐与零样本参数迁移,并在GPT-2和BERT上获得了强有力的实证验证。
Understanding Transformer-based models has attracted significant attention, as they lie at the heart of recent technological advances across machine learning. While most interpretability methods rely on running models over inputs, recent work has shown that a zero-pass approach, where parameters are interpreted directly without a forward/backward pass is feasible for some Transformer parameters, and for two-layer attention networks. In this work, we present a theoretical analysis where all parameters of a trained Transformer are interpreted by projecting them into the embedding space, that is, the space of vocabulary items they operate on. We derive a simple theoretical framework to support our arguments and provide ample evidence for its validity. First, an empirical analysis showing that parameters of both pretrained and fine-tuned models can be interpreted in embedding space. Second, we present two applications of our framework: (a) aligning the parameters of different models that share a vocabulary, and (b) constructing a classifier without training by ``translating'' the parameters of a fine-tuned classifier to parameters of a different model that was only pretrained. Overall, our findings open the door to interpretation methods that, at least in part, abstract away from model specifics and operate in the embedding space only.
研究动机与目标
- 开发一种无需前向或反向传播的、与输入无关的训练后Transformer参数解释方法。
- 将先前对特定组件(如FFN值、注意力权重)的解释工作统一并扩展为一个在嵌入空间中运行的单一框架。
- 通过在嵌入空间中对齐参数,实现在共享分词器的不同模型之间的参数比较与迁移。
- 在GPT-2和BERT上对框架进行实证验证,证明投影后参数的可解释性与可迁移性。
- 表明模型行为可通过嵌入空间中的词汇级交互被抽象化并得以理解。
提出的方法
- 利用嵌入矩阵及其右逆矩阵,将所有Transformer参数(键、值、注意力权重)投影到嵌入空间,以实现基于词汇项的解释。
- 将模型中的内积运算重新表述为词汇项对之间的交互,从而直观地解释注意力与前馈运算。
- 将嵌入空间用作共享的线性空间,以比较和对齐使用相同分词器训练的不同模型的参数。
- 通过将微调后分类器参数与目标模型嵌入矩阵的逆矩阵相乘,实现零样本参数迁移,从而在无需重新训练的情况下实现行为迁移。
- 将该框架应用于分析在情感分析上微调后GPT-2参数的变化,将参数变化解释为词级情感信号。
- 在GPT-2 medium和BERT模型上对方法进行实证验证,表明投影后的参数能产生有意义且可解释的词汇级模式。
实验结果
研究问题
- RQ1是否所有训练好的Transformer参数(而不仅仅是FFN值或注意力权重)都能在嵌入空间中获得有意义的解释?
- RQ2微调后参数的变化在多大程度上可被解释为词汇级激活模式的偏移?
- RQ3是否可以在不依赖输入数据或前向传播的情况下,将使用相同分词器的模型在嵌入空间中对齐?
- RQ4是否可以通过嵌入空间中的参数迁移,将微调分类器的行为转移到仅预训练的模型上?
- RQ5在嵌入空间中解释参数是否能在不同模型和任务间产生语义上合理且一致的解释?
主要发现
- 该框架成功地在嵌入空间中解释了所有Transformer参数(包括键、值和注意力权重),揭示了有意义的词汇级交互。
- 在情感分析上微调后,GPT-2参数投影到嵌入空间后对应于表征情感的词汇,如“worse”、“incompetent”和“boring”。
- 通过嵌入空间框架,从不同随机种子预训练的两个BERT模型可实现逐层对齐,证明了跨模型可比性。
- 通过嵌入空间参数迁移,可实现从微调分类器到仅预训练模型的零样本参数迁移,实现无需重新训练的功能迁移。
- 尽管由于语言模型头中的非线性性存在理论限制,该框架在BERT上仍表现出色,表明其对架构差异具有鲁棒性。
- 嵌入空间作为跨模型比较与信息迁移的通用线性空间,有效抽象了模型特异性细节。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。