Analyzing Transformers in Embedding Space

Guy Dar, Mor Geva, Ankit Gupta, Jonathan Berant
9/6/2022
cs.CLcs.LG
transformer-attention

Official code: guy-dar/embedding-space (58 stars, Jupyter Notebook, Apache-2.0, last commit 2023-06-15).

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

Apache-2.0
588Jupyter Notebook, PythonJun 13, 20223 years agoApache-2.0

Similar Papers

Cite this paper

@article{dar2022analyzing,
  title  = {Analyzing Transformers in Embedding Space},
  author = {Guy Dar and Mor Geva and Ankit Gupta and Jonathan Berant},
  year   = {2022},
  eprint = {2209.02535},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2209.02535}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2209.02535.svg)](https://codeofpaper.com/paper/2209.02535)

Discussion