Abstract
The Transformer architecture has become the standard for natural language processing, yet its core self-attention mechanism suffers from $O(n^2)$ computational complexity. This quadratic growth poses significant challenges for deploying large models in resource-constrained environments. In this work, we introduce three "light" Transformer variants—the Dilated Transformer, the Dilated Transformer with Memory, and the Cascade Transformer. These models utilize sparse and local connection patterns to reduce parameter counts by up to 70% and achieve linear computational complexity. Empirical results on Penn TreeBank and WikiText-2 demonstrate that these "diet" models can match or even exceed the performance of full Transformers while being significantly more efficient.
Introduction
Modern NLP giants like BERT and GPT-2 rely on the Transformer's ability to capture long-range dependencies through self-attention. However, the computational cost of this mechanism scales quadratically with the input sequence length ($n$). As models grow to billions of parameters, this $O(n^2)$ bottleneck limits their use in real-time industrial applications and on hardware with limited memory. To address this, we explore whether the fully-connected nature of standard Transformers is strictly necessary, or if a more sparse, "slimmer" architecture can suffice.
Proposed Architectures
We propose three alternative architectures that move away from dense self-attention toward more efficient connection patterns:
- Dilated Transformer: Inspired by dilated convolutions, this model uses sparse connections that skip nodes. By increasing the dilation factor exponentially with network depth, the model maintains a wide receptive field while processing only a fraction of the tokens at each layer.
- Dilated Transformer with Memory: This variant enhances the Dilated Transformer by caching nodes from previous dilated connections. This "memory" helps preserve local history that might otherwise be lost due to the sparsity of the dilated pattern.
- Cascade Transformer: This architecture prioritizes dense local context through "cascade connections." It employs a base window size and a cardinal number to flexibly manage connections at different levels, ensuring strong local dependency modeling.
Computational Complexity
A primary goal of these architectures is to reduce the theoretical complexity of the attention mechanism. While the standard Transformer scales at $O(n^2 \cdot h)$, our proposed models achieve linear scaling relative to the sequence length $n$.
As shown in the table above, the complexity is reduced to $O(n \cdot k \cdot h)$ or similar linear forms, where $k, c, b,$ and $m$ are small constants. This shift allows for the processing of much longer sequences without the exponential increase in memory and compute requirements.
Experimental Results
The models were evaluated on the Penn TreeBank (PTB) and WikiText-2 (WT-2) datasets using perplexity as the primary metric.
Efficiency and Parameter Reduction
The "diet" approach yielded massive reductions in model size. The Dilated Transformer, for instance, reduced the parameter count from 30 million in the full model to just 8.8 million—a 70% decrease.
Performance Benchmarks
Despite the reduction in parameters, the light models remained highly competitive. Notably, on the WikiText-2 test set, the Cascade Transformer achieved a perplexity of 136.02, outperforming the full Transformer's 140.74. This result is particularly impressive given that the Cascade Transformer uses less than half the parameters (13.5M vs 30M) of the baseline.
Key Insights
- Sparsity is Viable: Full connectivity is not a prerequisite for high performance. Strategic sparsity can maintain a large receptive field while discarding redundant computations.
- Local Context Importance: The success of the Cascade Transformer suggests that for language modeling, dense local context is often more critical than a fully-connected view of the distant past.
- Scalability: Linear complexity makes these models theoretically superior for long-document processing where standard Transformers would fail due to memory constraints.
Conclusion
By putting the Transformer on a "diet," we have shown that it is possible to build efficient, high-performing NLP models suitable for industrial deployment. Future research will focus on scaling these architectures to deeper networks and testing their efficacy on a broader range of tasks, such as machine translation and summarization.
Summary updated