KroneckerBERT: Learning Kronecker Decomposition for Pre-trained Language Models via Knowledge Distillation

Marzieh S. Tahaei, Ella Charlaix, Vahid Partovi Nia, Ali Ghodsi, Mehdi RezagholizadeharXiv 2021

Introduction

Pre-trained Language Models (PLMs) like BERT have fundamentally transformed Natural Language Processing (NLP). However, their massive parameter counts—108 million for BERT-base—present significant barriers to deployment on edge devices such as smartphones and IoT hardware. These environments demand low latency, minimal memory footprints, and high energy efficiency.

KroneckerBERT addresses this challenge by achieving extreme compression (up to 19x) through Kronecker decomposition. By representing large weight matrices as products of much smaller ones and employing a specialized two-stage knowledge distillation process, the authors created a model that retains 95% of the original's performance while occupying only 5% of its memory.

Methodology

The core innovation of KroneckerBERT lies in its application of Kronecker products to the Transformer architecture, combined with a robust distillation framework.

Kronecker Factorization

Instead of storing a standard weight matrix $W$, the researchers represent it as the Kronecker product of two smaller matrices, $A$ and $B$ ($W = A \otimes B$). For a $768 \times 768$ matrix, $A$ and $B$ might be as small as $24 \times 32$, drastically reducing the total number of parameters stored.

The Kronecker product $A \otimes B$ allows a large matrix to be represented by two significantly smaller factor matrices.

Unlike Singular Value Decomposition (SVD), which forces a matrix to be low-rank, Kronecker products can maintain high-rank representations. This property is crucial for preserving the "expressiveness" and complexity of the model during extreme compression.

Efficient Embeddings

The embedding layer is typically one of the most memory-intensive components of a PLM, acting as a massive lookup table.

Conventional lookup tables in PLMs are highly over-parameterized and memory-intensive.

To optimize this, KroneckerBERT represents the embedding as a Kronecker product of a matrix and a row vector. This "disentangled" approach allows for significant memory savings while maintaining the speed necessary for real-time inference.

Two-Stage Knowledge Distillation (KD)

To bridge the performance gap between the compressed "student" and the original "teacher" (BERT-base), the authors utilized a two-stage KD process:

  1. Pre-training Distillation: The student is initialized using weights extracted from the teacher via $L_2$ norm approximation and trained on a subset of Wikipedia (5%) to capture general linguistic patterns.
  2. Task-specific Distillation: The model is fine-tuned on target tasks using the teacher’s outputs and intermediate layer features. A specialized projection loss is introduced to help the student's internal representations more closely mimic those of the teacher.

Experimental Results

The model was evaluated on the GLUE benchmark, SQuAD (v1.1 and v2.0), and several Out-of-Distribution (OOD) datasets like HANS and IMDb.

  • Extreme Compression: KroneckerBERT$_{19}$ (5.7M parameters) outperformed other high-compression baselines such as LadaBERT on GLUE tasks.
  • Robustness: In OOD testing, KroneckerBERT demonstrated superior robustness compared to TinyBERT, suggesting that the decomposition may act as a regularizer that prevents overfitting.
  • Hardware Performance: On mobile hardware, the 19x compressed model achieved a 2.4x inference speedup, validating its utility for edge deployment.

Conclusion and Future Work

KroneckerBERT demonstrates that Kronecker decomposition is a powerful tool for extreme model compression, particularly when paired with effective initialization and distillation strategies. While the serial nature of Kronecker operations can present a bottleneck for parallel processing on GPUs, the memory savings and mobile speedups are substantial. Future research may focus on optimizing low-level kernels for Kronecker operations or applying this framework to even larger architectures like GPT-4 or T5.

Summary updated

Abstract

The development of over-parameterized pre-trained language models has made a significant contribution toward the success of natural language processing. While over-parameterization of these models is the key to their generalization power, it makes them unsuitable for deployment on low-capacity devices. We push the limits of state-of-the-art Transformer-based pre-trained language model compression using Kronecker decomposition. We use this decomposition for compression of the embedding layer, all linear mappings in the multi-head attention, and the feed-forward network modules in the Transformer layer. We perform intermediate-layer knowledge distillation using the uncompressed model as the teacher to improve the performance of the compressed model. We present our KroneckerBERT, a compressed version of the BERT_BASE model obtained using this framework. We evaluate the performance of KroneckerBERT on well-known NLP benchmarks and show that for a high compression factor of 19 (5% of the size of the BERT_BASE model), our KroneckerBERT outperforms state-of-the-art compression methods on the GLUE. Our experiments indicate that the proposed model has promising out-of-distribution robustness and is superior to the state-of-the-art compression methods on SQuAD.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
GLUEKroneckerBERT_8average performance (excluding CoLA)81.7split: test · fine-tuned · variant=KroneckerBERT-8
Source quote
L269: Table \ref{tab:glue_test_results} summarizes the results. The results are divided into two categories: in the upper part of the table KroneckerBERT-8 are compared to several state-of-the-art KD methods that have a compression factor less than 10. In the lower part of the table, we compare the performance of KroneckerBERT-19 with state-of-the-art models that have a compression factor greater than 10. We can see that when the compression factor is less than 10, KroneckerBERT outperforms other baselines, except TinyBERT, on every task of GLUE. As for TinyBERT KroneckerBERT has a very similar performance in all the tasks except for CoLA. Note TinyBERT performs pre-training KD on the entire Wikipedia dataset and uses an extensive data augmentation (20 times the original data) in the fine-tuning stage to obtain these results. Moreover, the average performance of KroneckerBERT_8 excluding CoLA is 81.7 compared to 81.2 for TinyBERT. For higher compression factors, KroneckerBERT outperforms all other baselines on all available results.
SQuAD 1.1 · SQuAD1.1KroneckerBERT_8F184.2split: val · fine-tuned · variant=KroneckerBERT-8 · compression-factor=7.6x
Source quote
L244: KroneckerBERT_8 │ 7.6× │ 75.4 │ 84.2 │ 69.9 │ 73.5
SQuAD 2.0 · SQuAD2.0KroneckerBERT_8F173.5split: val · fine-tuned · variant=KroneckerBERT-8 · compression-factor=7.6x
Source quote
L244: KroneckerBERT_8 │ 7.6× │ 75.4 │ 84.2 │ 69.9 │ 73.5
PAWSKroneckerBERT_8OOD evaluation result (metric unspecified)61.4fine-tuned · variant=KroneckerBERT-8 · fine-tuning-dataset=MRPC
Source quote
L220: KroneckerBERT_8 │ 61.4 │ 52.7 │ 81.0
HANSKroneckerBERT_8OOD evaluation result (metric unspecified)52.7fine-tuned · variant=KroneckerBERT-8 · fine-tuning-dataset=RTE
Source quote
L220: KroneckerBERT_8 │ 61.4 │ 52.7 │ 81.0
IMDBKroneckerBERT_8OOD evaluation result (metric unspecified)81.0fine-tuned · variant=KroneckerBERT-8 · fine-tuning-dataset=SST-2
Source quote
L220: KroneckerBERT_8 │ 61.4 │ 52.7 │ 81.0
BibTeX
@misc{tahaei2021kroneckerbert,
  author = {Marzieh S. Tahaei and Ella Charlaix and Vahid Partovi Nia and Ali Ghodsi and Mehdi Rezagholizadeh},
  title = {{KroneckerBERT: Learning Kronecker Decomposition for Pre-trained Language Models via Knowledge Distillation}},
  year = {2021},
  eprint = {2109.06243},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.06243},
}
Figure