[Paper Review] BERT-EMD: Many-to-Many Layer Mapping for BERT Compression with Earth Mover's Distance
This paper proposes BERT-EMD, a novel BERT distillation method that enables many-to-many layer mapping between teacher and student networks using Earth Mover’s Distance (EMD) to optimize knowledge transfer. By learning adaptive layer weights via a cost attention mechanism, BERT-EMD achieves state-of-the-art compression performance, outperforming BERT-Base on 7 out of 9 GLUE tasks with only 50% of the parameters and inference time.
Pre-trained language models (e.g., BERT) have achieved significant success in various natural language processing (NLP) tasks. However, high storage and computational costs obstruct pre-trained language models to be effectively deployed on resource-constrained devices. In this paper, we propose a novel BERT distillation method based on many-to-many layer mapping, which allows each intermediate student layer to learn from any intermediate teacher layers. In this way, our model can learn from different teacher layers adaptively for various NLP tasks. %motivated by the intuition that different NLP tasks require different levels of linguistic knowledge contained in the intermediate layers of BERT. In addition, we leverage Earth Mover's Distance (EMD) to compute the minimum cumulative cost that must be paid to transform knowledge from teacher network to student network. EMD enables the effective matching for many-to-many layer mapping. %EMD can be applied to network layers with different sizes and effectively measures semantic distance between the teacher network and student network. Furthermore, we propose a cost attention mechanism to learn the layer weights used in EMD automatically, which is supposed to further improve the model's performance and accelerate convergence time. Extensive experiments on GLUE benchmark demonstrate that our model achieves competitive performance compared to strong competitors in terms of both accuracy and model compression.
Motivation & Objective
- To address the limitations of one-to-one layer mapping in BERT distillation, which lacks theoretical guidance and fails to adapt to diverse NLP tasks.
- To enable each student layer to dynamically learn from any intermediate teacher layers, adapting to task-specific linguistic knowledge requirements.
- To optimize knowledge transfer by formulating the teacher-student layer distance as an optimal transport problem using Earth Mover’s Distance (EMD).
- To automatically learn the importance of each teacher layer via a cost attention mechanism, improving performance and accelerating convergence.
- To achieve high compression efficiency without performance sacrifice, enabling deployment on resource-constrained devices.
Proposed method
- Proposes a many-to-many layer mapping strategy where each intermediate student layer can attend to all intermediate teacher layers, enabling adaptive knowledge transfer across tasks.
- Uses Earth Mover’s Distance (EMD) to compute the minimum cumulative cost of transforming knowledge from teacher to student, modeling the optimal transport of hidden representations.
- Introduces a cost attention mechanism that learns task-specific layer weights for EMD, dynamically assigning importance to different teacher layers.
- Employs a transportation problem formulation to solve the EMD-based knowledge distillation, ensuring holistic and efficient knowledge transfer.
- Trains the student model using knowledge distillation loss based on EMD and attention-weighted layer matching, with end-to-end optimization.
- Releases code and data for reproducibility at https://github.com/lxk00/BERT-EMD.
Experimental results
Research questions
- RQ1Can a many-to-many layer mapping strategy improve knowledge distillation in BERT compression compared to one-to-one mappings?
- RQ2Does using Earth Mover’s Distance (EMD) as a distance metric lead to better knowledge transfer and model performance in BERT distillation?
- RQ3Can a learnable cost attention mechanism improve the adaptability and convergence speed of the distillation process?
- RQ4Does BERT-EMD achieve competitive performance with significantly reduced model size and inference time across diverse NLP tasks?
- RQ5How does the model’s performance vary across tasks with different linguistic complexity, such as RTE vs. MNLI?
Key findings
- BERT-EMD with 6 layers outperforms the original 12-layer BERT-Base model on 7 out of 9 GLUE tasks, demonstrating strong compression efficiency.
- On the RTE task, BERT-EMD achieves a 5.3% accuracy improvement over BERT-Base, highlighting its effectiveness on complex reasoning tasks.
- On the STS-B task, BERT-EMD achieves a 1% improvement in Spearman correlation over BERT-Base, indicating better performance on regression-style tasks.
- Ablation studies show that removing the EMD module causes a sharp performance drop, especially on STS-B, validating EMD’s critical role in optimal transport of knowledge.
- The cost attention mechanism further improves performance and accelerates convergence, confirming its value in learning task-specific layer importance.
- Visualization of flow matrices shows that different tasks emphasize different teacher layers—e.g., RTE uses non-diagonal mappings, unlike MNLI, proving adaptive, task-aware knowledge transfer.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.