Greenformers: Improving Computation and Memory Efficiency in Transformer Models via Low-Rank Approximation

Samuel CahyawijayaarXiv 2021

Abstract

The rapid advancement of Transformer-based models has led to unprecedented performance in artificial intelligence, yet this progress comes with substantial environmental and economic costs. As model sizes scale from millions to trillions of parameters, the demand for massive GPU clusters creates a barrier to accessibility and sustainability. This paper presents Greenformers, a framework designed to mitigate these challenges through low-rank approximation. By strategically implementing Low-Rank Transformers (LRT) for short-sequence tasks and Linformers for long-sequence analysis, the framework achieves up to an 8x reduction in model size and a 35% improvement in inference speed. Experimental results across vision, speech recognition, and genomics demonstrate that Greenformers can maintain or even enhance task performance, offering a viable path toward "Green AI."

Introduction

Since the introduction of the Transformer architecture in 2017, the field of AI has witnessed a "Transformer revolution." However, the scaling of these models—from 100 million parameters to over 1.6 trillion—has resulted in an alarming carbon footprint and prohibitive hardware requirements. Most state-of-the-art models are now over-parameterized, containing significant redundancy that contributes to computational inefficiency.

The Greenformers framework addresses the "Green AI" challenge: maintaining state-of-the-art performance while making models efficient enough for on-device deployment and environmentally responsible training. This research explores how low-rank approximation can be used to prune this redundancy without losing the expressive power of the original architecture.

Methodology

The core of the Greenformers framework is Low-Rank Approximation, which involves decomposing large, computationally expensive weight matrices into two smaller, "thinner" matrices.

1. Low-Rank Transformer (LRT)

LRT targets the linear projection layers within the Transformer. Instead of utilizing a standard weight matrix $W$, it employs a factorized version where $W \approx E \times D$. This factorization significantly reduces both the parameter count and the number of floating-point operations (FLOPs) required during inference.

2. Linformer

While LRT is effective for standard layers, the self-attention mechanism presents a unique bottleneck due to its $O(N^2)$ computational complexity relative to sequence length $N$. The Linformer technique applies low-rank projection to the attention mechanism itself, reducing complexity to $O(N)$. This allows the model to process significantly longer sequences than standard Transformers.

3. Genomic Encoding and Tokenization

For specialized applications like Alzheimer’s risk prediction, the paper introduces a "diplotype" representation that maps DNA into 66 unique tokens. By applying SentencePiece subword tokenization to this genomic data, the author creates a novel bridge between natural language processing (NLP) techniques and bioinformatics, further enhancing data efficiency.

Experimental Setup

The Greenformers framework was evaluated across three distinct domains:

  • General Vision: MNIST datasets (flattened into sequences of 784 pixels) served as a baseline for testing basic effectiveness.
  • Speech Recognition (ASR): The models were tested on AiShell-1 (170 hours of Mandarin speech) and HKUST (161 hours of Mandarin telephone conversations).
  • Genomics: A Chinese Cohort dataset of 626 elderly subjects was used to predict Alzheimer’s Disease risk by focusing on the APOE region of Chromosome 19.

Key Insights

The Sequence Length Threshold

A critical finding of this research is that the optimal efficiency method is dependent on the input data's sequence length. LRT is most effective for short sequences ($\le 512$ tokens), making it the preferred choice for on-device tasks like speech-to-text. Conversely, Linformer excels in long-sequence tasks ($> 512$ tokens), such as comprehensive genomic analysis.

Efficiency as Regularization

Interestingly, reducing the rank of the matrices did not merely save space; in many cases, it improved accuracy. By forcing the model to operate within a lower-rank approximation, the framework effectively filters out "parameter noise." This acts as a form of regularization, helping the model generalize better to unseen data.

The Power of Tokenization

In genomic experiments, the choice of tokenization (subword vs. unitary) proved to be as impactful as the architectural changes. Combining Linformer with subword tokenization enabled the model to process sequences 35 times longer than previous state-of-the-art methods.

Results

The implementation of Greenformers yielded significant improvements across all metrics:

  • Model Compression: LRT achieved up to an 8x reduction in model size at rank 64.
  • Speech Recognition: On the AiShell-1 task, LRT halved the parameter count while increasing GPU inference speed by 1.35x and CPU speed by 1.25x. Notably, it achieved a slightly better Character Error Rate (CER) than the full Transformer baseline.
  • Genomics: The Linformer-based model successfully processed sequences up to 35,000 nucleotides long, outperforming FDA-approved risk-scoring models by approximately 5% AUC.
  • Economic and Environmental Impact: Estimates suggest that applying LRT to BERT-base pre-training could reduce computational, economic, and environmental costs by over 30%.

Conclusion

Greenformers demonstrates that massive Transformer models can be made more sustainable without sacrificing performance. While the current implementation of Linformer requires a pre-defined sequence length—limiting its flexibility for variable-length inputs—the overall framework provides a robust foundation for "Green AI." Future research will focus on extending these techniques to even larger architectures like GPT-3 and exploring applications in video processing and long-document summarization.

Summary updated

BibTeX
@misc{cahyawijaya2021greenformers,
  author = {Samuel Cahyawijaya},
  title = {{Greenformers: Improving Computation and Memory Efficiency in Transformer Models via Low-Rank Approximation}},
  year = {2021},
  eprint = {2108.10808},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.10808},
}
Figure