Skip to main content
QUICK REVIEW

[Paper Review] Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernel

Yao-Hung Hubert Tsai, Shaojie Bai|arXiv (Cornell University)|Aug 30, 2019
Natural Language Processing TechniquesComputer Science5 citations
TL;DR

This paper introduces a kernel-based reformulation of the Transformer's attention mechanism, framing it as a kernel smoother that leverages similarity scores between inputs. By modeling attention through symmetric kernel products, the approach enables a unified understanding of attention components, reduces parameters, and achieves competitive performance on neural machine translation and sequence prediction tasks with improved interpretability and design flexibility.

ABSTRACT

Transformer is a powerful architecture that achieves superior performance on various sequence learning tasks, including neural machine translation, language understanding, and sequence prediction. At the core of the Transformer is the attention mechanism, which concurrently processes all inputs in the streams. In this paper, we present a new formulation of attention via the lens of the kernel. To be more precise, we realize that the attention can be seen as applying kernel smoother over the inputs with the kernel scores being the similarities between inputs. This new formulation gives us a better way to understand individual components of the Transformer's attention, such as the better way to integrate the positional embedding. Another important advantage of our kernel-based formulation is that it paves the way to a larger space of composing Transformer's attention. As an example, we propose a new variant of Transformer's attention which models the input as a product of symmetric kernels. This approach achieves competitive performance to the current state of the art model with less computation. In our experiments, we empirically study different kernel construction strategies on two widely used tasks: neural machine translation and sequence prediction.

Motivation & Objective

  • To provide a unified, kernel-based theoretical framework for understanding the attention mechanism in Transformers.
  • To identify the most effective kernel forms and positional embedding integration strategies for attention mechanisms.
  • To develop a new attention variant that maintains high performance with reduced computational cost.
  • To enable systematic categorization and design of attention mechanisms through the lens of kernel learning.

Proposed method

  • Reformulate the self-attention mechanism as a kernel smoother, where attention weights are derived from similarity (kernel) scores between input tokens.
  • Propose a new attention variant that models the input as a product of symmetric kernels, reducing parameter count while preserving performance.
  • Integrate positional embeddings via kernel construction, specifically using the product of non-positional and positional kernel functions.
  • Use exponential and RBF kernels—known for infinite-dimensional feature maps—as key kernel forms to evaluate performance.
  • Apply the kernel formulation to analyze and categorize existing attention variants, such as those in Vaswani et al. (2017), Shaw et al. (2018), and Dai et al. (2019).
  • Conduct ablation studies on positional embedding placement (query, key, value, or kernel) to determine optimal integration.

Experimental results

Research questions

  • RQ1How can the Transformer attention mechanism be reinterpreted through the lens of kernel methods?
  • RQ2Which kernel forms (e.g., RBF, exponential) yield the best performance in attention mechanisms?
  • RQ3Where should positional embeddings be integrated in the kernel-based attention mechanism for optimal performance?
  • RQ4Can a symmetric kernel-based attention variant achieve competitive performance with fewer parameters than existing models?
  • RQ5Does the kernel-based formulation allow for a unified categorization of existing attention variants?

Key findings

  • Using a product of symmetric kernels for attention achieves competitive performance with reduced parameter count, outperforming or matching state-of-the-art models.
  • The RBF and exponential kernels—both with infinite-dimensional feature maps—yield the best performance across both neural machine translation and sequence prediction tasks.
  • Integrating positional embeddings via the kernel function (as a product with the non-positional kernel) leads to the best performance, outperforming integration in query, key, or value heads.
  • Positional embedding in the value function provides no significant performance gain, suggesting it is unnecessary for attention output computation.
  • Removing positional embeddings from decoder self-attention causes a minor performance drop in NMT (34.71 to 34.49 BLEU), but removing them globally degrades performance drastically (to 14.47 BLEU), indicating their critical role in overall modeling.
  • The kernel-based formulation enables a systematic understanding and categorization of prior attention variants, revealing shared structural components under a unified framework.

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.