TL;DR
Transformer language models are powerful but too large for many applications. This paper introduces a novel autoencoder-based framework for "offline compression" that efficiently shrinks these models without requiring task-specific fine-tuning. Their method significantly outperforms traditional factorization techniques, especially when compressing modules across different layers collaboratively.
What Problem Does This Paper Address?
The incredible success of large transformer language models (like BERT, GPT) has led to models with billions of parameters. While this scale unlocks impressive performance on various Natural Language Processing (NLP) tasks, it creates significant challenges for deployment on resource-constrained devices (e.g., mobile phones, edge devices) due to memory and computational limitations. "Offline compression" aims to address this by creating smaller, more efficient models from pre-trained ones without needing further fine-tuning on downstream tasks. Existing methods often rely on matrix factorization techniques, which can be suboptimal. This paper seeks to improve upon these methods by proposing a more effective autoencoder-based approach.
Methods
The core of the proposed method is an autoencoder-based framework for compressing individual weight matrices within transformer models. Unlike traditional matrix factorization (like SVD) which decomposes a matrix into two smaller matrices, the autoencoder learns a compressed latent representation of the matrix and then reconstructs it. This allows for more flexibility in the compression process.
Key aspects of their approach include:
- Module-wise Compression: The autoencoder is applied to various weight matrices within the transformer, including token embeddings, keys, queries, values, and output-dense layers.
- Customizable Loss Function: They utilize a multi-objective loss function that combines L2 (RMSE) loss for reconstruction accuracy with a cosine distance loss to preserve the directional information of the weight vectors. This is crucial for maintaining performance, especially for token embeddings.
- Collaborative Layer Compression: A significant innovation is the ability to compress modules from different layers together. By sharing a common decoder for concatenated modules across layers, they enable cross-layer collaboration, which helps eliminate redundant information and boosts performance.
- Fisher Information Integration: They explore incorporating Fisher Information, derived from the upstream training data, into the loss function. This "sensitivity" measure helps the autoencoder focus on more important weights, further improving compression quality.
Datasets
The experiments were conducted using the BERTBASE model.
- Upstream Task: Masked language modeling on the WikiText-103 dataset was used for pre-training and for calculating Fisher Information.
- Downstream Tasks: Performance was evaluated on several datasets from the GLUE benchmark, specifically MRPC and SST2. Other GLUE tasks (RTE, QNLI, QQP) were also used in some experiments.
Key Insights and Ideas
- Autoencoders Outperform Factorization: The autoencoder-based approach, particularly with a well-designed loss function, offers superior compression quality compared to classical matrix factorization methods like SVD.
- Direction Matters: Preserving the directional information (cosine similarity) of weight vectors is crucial for effective compression, especially for token embeddings.
- Cross-Layer Collaboration is Key: Compressing modules from different layers together (concatenated mode) significantly improves performance over compressing each module independently. This suggests that redundancies and collaborative structures exist across layers.
- Fisher Information Adds Value: Leveraging unsupervised upstream data via Fisher Information can further enhance compression quality by guiding the model to focus on more critical parameters.
- Perplexity as a Proxy: Initial perplexity after compression serves as a good, low-cost indicator of downstream task performance, allowing for quicker evaluation of compression strategies.
Key Results
- The proposed autoencoder-based framework consistently outperforms factorization-based methods (like SVD) on downstream NLP tasks (MRPC, SST2) across various compression ratios (3x, 10x, 25x).
- Compressing modules from different layers together (concatenated mode) yielded better performance and faster training compared to compressing modules separately.
- Incorporating the cosine distance loss improved performance, especially for token embeddings, and showed benefits for other modules as well.
- Using Fisher Information in the loss function led to significant improvements in both perplexity and downstream task performance. For example, in Table 1, AE+Fisher achieved better scores than AE alone.
- In Table 5, the AE+Fisher method for token embeddings at CR=3 achieved a perplexity of 33.27 and downstream accuracy of 92.55/88.36, outperforming SVD+Fisher (71.05 perplexity, 91.74/88.74 accuracy).
Limitations and Future Work
- Module-Specific Tuning: The optimal compression strategy (e.g., choice of decoder, loss function parameters) can vary between different types of transformer modules, requiring some analysis for each module.
- Fisher Information Computation: Computing Fisher Information requires an unsupervised corpus and can be computationally more demanding than simpler offline methods.
- Future Work: The authors suggest exploring module-specific findings for other language models and investigating more computationally efficient ways to compute Fisher Information. They also believe their techniques could be applicable to compressing weight matrices in non-language models.
Summary updated