Skip to main content
QUICK REVIEW

[Paper Review] Analyzing Transformers in Embedding Space

Guy Dar, Mor Geva|arXiv (Cornell University)|Sep 6, 2022
Explainable Artificial Intelligence (XAI)Computer Science7 citations
TL;DR

This paper introduces a zero-pass, input-independent framework to interpret all parameters of trained Transformers by projecting them into the embedding space—the space of vocabulary items. By leveraging the embedding matrix and its right-inverse, the authors reinterpret attention and feed-forward weights as interactions between vocabulary items, enabling model alignment and zero-shot parameter transfer without fine-tuning, with strong empirical validation on GPT-2 and BERT.

ABSTRACT

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.

Motivation & Objective

  • To develop an input-independent method for interpreting trained Transformer parameters without forward or backward passes.
  • To unify and extend prior work on interpreting specific components (e.g., FFN values, attention weights) into a single framework operating in the embedding space.
  • To enable cross-model comparison and parameter transfer between models sharing a tokenizer by aligning their parameters in embedding space.
  • To validate the framework empirically on GPT-2 and BERT, demonstrating interpretability and transferability of projected parameters.
  • To show that model behavior can be abstracted and understood through vocabulary-level interactions in the embedding space.

Proposed method

  • Project all Transformer parameters (keys, values, attention weights) into the embedding space using the embedding matrix and its right-inverse to enable interpretation in vocabulary terms.
  • Reframe inner products in the model as interactions between pairs of vocabulary items, enabling intuitive interpretation of attention and feed-forward operations.
  • Use the embedding space as a shared linear space to compare and align parameters across different models trained with the same tokenizer.
  • Perform zero-shot parameter translation by multiplying fine-tuned classifier parameters with the inverse of the embedding matrix of a target model, enabling transfer without retraining.
  • Apply the framework to analyze changes in GPT-2 parameters after fine-tuning on sentiment analysis, interpreting shifts as word-level sentiment signals.
  • Validate the approach empirically on GPT-2 medium and BERT models, showing that projected parameters yield meaningful, interpretable vocabulary-level patterns.

Experimental results

Research questions

  • RQ1Can all trained Transformer parameters—beyond just FFN values or attention weights—be meaningfully interpreted in the embedding space?
  • RQ2To what extent can parameter changes after fine-tuning be interpreted as shifts in vocabulary-level activation patterns?
  • RQ3Can models with the same tokenizer be aligned in embedding space without relying on input data or forward passes?
  • RQ4Is it possible to transfer a fine-tuned classifier’s behavior to a pretrained-only model via embedding-space parameter translation?
  • RQ5Does interpreting parameters in the embedding space yield semantically meaningful and consistent interpretations across different models and tasks?

Key findings

  • The framework successfully interprets all Transformer parameters—including keys, values, and attention weights—in the embedding space, revealing meaningful vocabulary-level interactions.
  • After fine-tuning on sentiment analysis, changes in GPT-2 parameters projected into embedding space correspond to words that characterize sentiment, such as 'worse', 'incompetent', and 'boring'.
  • Two BERT models pretrained from different random seeds can be aligned layer-by-layer using the embedding space framework, demonstrating cross-model comparability.
  • Zero-shot parameter transfer from a fine-tuned classifier to a pretrained-only model is feasible via embedding-space translation, achieving functional transfer without retraining.
  • Despite theoretical limitations due to non-linearities in the LM head, the framework performs well in practice on BERT, suggesting robustness to architectural variations.
  • The embedding space serves as a universal linear space for comparing and transferring information across models, abstracting away model-specific details.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.