Introduction
The Transformer architecture has revolutionized natural language processing, but its success comes at a high computational cost. A significant portion of a Transformer’s memory and compute footprint lies in its Multi-Head Attention (MHA) mechanism. In standard MHA, the model maintains several independent sets of weight matrices (heads) to capture different types of relationships in the data. This redundancy makes Transformers difficult to deploy in resource-constrained environments, such as mobile devices.
While previous research has explored compressing embedding layers or using pruning, compressing the core attention mechanism without sacrificing accuracy has remained a significant challenge. To address this, researchers introduce the Tensorized Transformer, which replaces the standard, parameter-heavy MHA with a novel "Multi-linear attention" layer based on Block-Term Tensor Decomposition (BTD). By sharing parameters across attention blocks and using low-rank approximations, the authors achieve up to an 8x reduction in attention parameters while actually improving performance on major language modeling and translation benchmarks.
The Tensorized Architecture
To compress the attention mechanism, the authors propose Multi-linear attention, which leverages Block-Term Tensor Decomposition (BTD)—a mathematical technique that combines the rigid structure of CP decomposition with the flexibility of Tucker decomposition.
The technical implementation involves several key steps:
- Linear Representation Proof: The authors first prove that the output of standard scaled dot-product attention can be represented as a linear combination of orthonormal basis vectors. This theoretical groundwork justifies using linear tensor operations to approximate attention.
- Parameter Sharing: Instead of having $h$ independent heads with their own unique weights, the model uses a group of linear projections to map queries, keys, and values into three shared factor matrices.
- BTD Construction: These shared matrices are used to construct a 3-order block tensor. By initializing a low-rank, trainable "core tensor," the model reconstructs the attention representation.
- Integration via Split-Concat: To make this work within a standard Transformer framework, the authors use a "Split-Concat" method. They split the 3-order tensor output and concatenate the resulting matrices, allowing the layer to plug directly into the next part of the network.
Key Insights and Results
The authors evaluated the Tensorized Transformer on four major benchmarks: PTB, WikiText-103, One-Billion Word, and WMT-2016 English-German.
A surprising insight from the experiments is that compression acts as a regularizer. The tensorized version often outperformed the original, suggesting that the low-rank approximation helps the model generalize better and alleviates overfitting. Furthermore, the authors found that "splitting" the tensor (rather than just summing it to perfectly reconstruct standard attention) led to better experimental accuracy. This indicates that the tensorized structure discovers more efficient ways to process information than the original design.
The Tensorized Transformer achieved state-of-the-art (SoTA) or near-SoTA results with a fraction of the parameters:
- WikiText-103: Achieved a Perplexity (PPL) of 18.9, outperforming the Transformer-XL Large (18.3) with significantly fewer parameters (85.3M vs. 257M).
- One-Billion Word: Reduced parameters from 0.8B (Transformer-XL Large) to 0.16B, while improving PPL from 21.8 to 19.5.
- Machine Translation: On WMT-16, the Tensorized version achieved 34.91 BLEU, surpassing the vanilla Transformer's 34.5 BLEU while using less than half the parameters (21.2M vs. 52M).
- Efficiency: In the attention layer specifically, the compression ratio can reach 8x (e.g., reducing parameters from 512 to 64 per head configuration).
Limitations and Future Work
While highly effective, the approach has a few limitations. The authors noted an overfitting risk if the number of "core tensors" (the rank of the decomposition) becomes too large. Additionally, the model's performance is sensitive to the dimension of word embeddings; very large embedding dimensions can lead to degradation in the tensorized setup.
Currently, this compression method focuses primarily on the attention layers, leaving other components like position-wise feed-forward networks untouched. In future work, the authors plan to explore the fundamental reasons why this tensorized structure improves performance and aim to apply the framework to a wider variety of NLP tasks beyond language modeling and translation.
Summary updated