Skip to main content
QUICK REVIEW

[Paper Review] Eigen Analysis of Self-Attention and its Reconstruction from Partial Computation

Srinadh Bhojanapalli, Ayan Chakrabarti|arXiv (Cornell University)|Jun 16, 2021
Advanced Neural Network ApplicationsComputer Science22 references5 citations
TL;DR

This paper proposes a method to reconstruct full self-attention matrices in transformers using only a partial set of computed dot-product attention scores, leveraging the observation that attention scores lie in a low-dimensional eigenspace. By selecting key query-key pairs via a greedy algorithm and reconstructing the rest via learned linear transforms, the approach reduces attention computation cost by 25–45% with only a minor drop in model accuracy on MLM and NLI tasks.

ABSTRACT

State-of-the-art transformer models use pairwise dot-product based self-attention, which comes at a computational cost quadratic in the input sequence length. In this paper, we investigate the global structure of attention scores computed using this dot product mechanism on a typical distribution of inputs, and study the principal components of their variation. Through eigen analysis of full attention score matrices, as well as of their individual rows, we find that most of the variation among attention scores lie in a low-dimensional eigenspace. Moreover, we find significant overlap between these eigenspaces for different layers and even different transformer models. Based on this, we propose to compute scores only for a partial subset of token pairs, and use them to estimate scores for the remaining pairs. Beyond investigating the accuracy of reconstructing attention scores themselves, we investigate training transformer models that employ these approximations, and analyze the effect on overall accuracy. Our analysis and the proposed method provide insights into how to balance the benefits of exact pair-wise attention and its significant computational expense.

Motivation & Objective

  • To investigate the low-dimensional structure of self-attention scores in transformer models on natural language inputs.
  • To determine whether attention score variation can be captured by a small number of principal components across layers and models.
  • To develop a method for approximating full attention matrices using only a subset of exact dot-product computations.
  • To evaluate the impact of partial attention computation on downstream model performance during end-to-end training.
  • To explore whether shared eigenspaces across models and layers can enable generalizable reconstruction methods.

Proposed method

  • Perform eigen analysis on full attention score matrices and individual query-row matrices to identify dominant principal components.
  • Use a greedy algorithm to select a subset of query-key pairs for exact attention computation, based on maximizing information gain.
  • Learn a reconstruction matrix R via least-squares optimization to map the selected scores to full attention vectors.
  • Integrate the partial computation and reconstruction into the transformer training pipeline, enabling backpropagation through the selection and reconstruction process.
  • Train the reconstruction matrix R jointly with model weights, either shared across layers or per-layer, to adapt to task-specific distributions.
  • Evaluate the method on BERT-base using masked language modeling pre-training and fine-tuning on the MNLI benchmark.

Experimental results

Research questions

  • RQ1Do self-attention scores computed on natural language inputs exhibit low-dimensional structure in their variation?
  • RQ2To what extent are the principal components of attention scores shared across different layers, heads, and transformer models?
  • RQ3Can a small subset of computed attention scores reconstruct the full matrix with low error using linear reconstruction?
  • RQ4Does training transformers with partial attention computation and reconstruction maintain competitive performance on downstream NLP tasks?
  • RQ5How does the choice of reconstruction matrix (fixed vs. trainable, shared vs. per-layer) affect model accuracy and efficiency?

Key findings

  • Attention scores across different layers and models exhibit significant overlap in their principal eigenspaces, indicating a shared low-dimensional structure.
  • The reconstruction error of full attention matrices using only 16–32 exact scores per query is low, with mean squared error minimized by the learned reconstruction matrix.
  • Training the reconstruction matrix R during backpropagation improves performance over using a fixed, precomputed R, especially for smaller k.
  • Using a shared R across layers improves performance for small k (e.g., k=16), while per-layer R is better for larger k (e.g., k=32).
  • The method reduces attention FLOPs by up to 45% while maintaining 97% of the baseline accuracy on the MNLI downstream task.
  • The model trained with partial attention achieves 79.7% accuracy on MNLI with k=32, compared to 81.6% for the full model, demonstrating a strong accuracy–efficiency trade-off.

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.