MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers

MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers

Wenhui Wang

Furu Wei

Li Dong

Hangbo Bao

Nan Yang

Ming Zhou

Abstract

Pre-trained language models (e.g., BERT (Devlin et al., 2018) and its variants) have achieved remarkable success in varieties of NLP tasks. However, these models usually consist of hundreds of millions of parameters which brings challenges for fine-tuning and online serving in real-life applications due to latency and capacity constraints. In this work, we present a simple and effective approach to compress large Transformer (Vaswani et al., 2017) based pre-trained models, termed as deep self-attention distillation. The small model (student) is trained by deeply mimicking the self-attention module, which plays a vital role in Transformer networks, of the large model (teacher). Specifically, we propose distilling the self-attention module of the last Transformer layer of the teacher, which is effective and flexible for the student. Furthermore, we introduce the scaled dot-product between values in the self-attention module as the new deep self-attention knowledge, in addition to the attention distributions (i.e., the scaled dot-product of queries and keys) that have been used in existing works. Moreover, we show that introducing a teacher assistant (Mirzadeh et al., 2019) also helps the distillation of large pre-trained Transformer models. Experimental results demonstrate that our monolingual model $^{1}$ outperforms state-of-the-art baselines in different parameter size of student models. In particular, it retains more than 99% accuracy on SQuAD 2.0 and several GLUE benchmark tasks using 50% of the Transformer parameters and computations of the teacher model. We also obtain competitive results in applying deep self-attention distillation to multilingual pre-trained models.

Correspondence to: Furu Wei [email protected].
$^{1}$ The code and models are publicly available at https://aka.ms/minilm.

Executive Summary: Large pre-trained Transformer models such as BERT have delivered strong results across natural language processing tasks, yet their hundreds of millions of parameters create practical barriers to fine-tuning and low-latency serving in production. Latency and memory limits are especially acute for real-time applications and edge deployment, prompting interest in compression techniques that preserve capability without task-specific retraining.

This paper introduces deep self-attention distillation, a task-agnostic method that trains a compact student model by mimicking the self-attention behavior of a larger teacher. The approach distills attention distributions together with a new value-relation signal (the scaled dot-product among value vectors) drawn solely from the teacher’s final Transformer layer. Experiments were performed on English Wikipedia and BookCorpus data, distilling BERT_BASE into students of varying depth and width; a teacher-assistant stage was added for the smallest models. Performance was measured on SQuAD 2.0 and the GLUE benchmark after standard fine-tuning, with additional checks on question generation, summarization, and cross-lingual tasks.

The resulting six-layer, 768-hidden-dimension student retains more than 99 percent of the teacher’s accuracy on SQuAD 2.0 and several GLUE tasks while using roughly half the Transformer parameters and running twice as fast. It outperforms prior task-agnostic baselines (DistilBERT and TinyBERT) by 3-plus F1 points on SQuAD and 5-plus accuracy points on CoLA. Adding the value-relation objective yields a further one-point F1 gain; the teacher-assistant step improves results for models one-quarter the teacher’s size. Comparable retention of accuracy with substantially fewer parameters is also demonstrated for multilingual distillation from XLM-R.

These outcomes show that last-layer self-attention knowledge is sufficient to transfer core representational capacity, removing the need for layer-by-layer mapping or matching hidden dimensions. Organizations can therefore deploy smaller, faster models in latency-sensitive or capacity-constrained settings while keeping downstream performance nearly intact.

Teams facing deployment constraints should evaluate the publicly released MiniLM checkpoints for their target tasks. Where the gap between teacher and student is large, inserting a teacher-assistant stage is advisable. Future work should test the method on still-larger teachers and collect additional data on non-English languages to confirm breadth.

The reported gains rest on standard pre-training corpora and a limited set of downstream benchmarks; results on very small students or out-of-domain tasks could vary. Direct comparisons with MobileBERT were omitted because of its specially engineered teacher architecture.

1. Introduction

Section Summary: Pre-trained language models such as BERT deliver strong results across NLP tasks but contain hundreds of millions of parameters, creating practical difficulties for fine-tuning and deployment. Knowledge distillation offers a way to train much smaller “student” models that mimic these large “teacher” models without first adapting the teacher to any specific task. The paper introduces a distillation method that transfers self-attention knowledge—both attention patterns and value relationships—from only the teacher’s final layer, removing the need for strict layer matching or identical hidden sizes and allowing flexible, efficient student architectures that still retain nearly all of the original accuracy.

Language model (LM) pre-training has achieved remarkable success for various natural language processing tasks [4, 5, 6, 1, 7, 8, 9, 10]. The pre-trained language models, such as BERT [1] and its variants, learn contextualized text representations by predicting words given their context using large scale text corpora, and can be fine-tuned with additional task-specific layers to adapt to downstream tasks. However, these models usually contain hundreds of millions of parameters which brings challenges for fine-tuning and online serving in real-life applications for latency and capacity constraints.

Knowledge distillation [11, 12] (KD) has been proven to be a promising way to compress a large model (called the teacher model) into a small model (called the student model), which uses much fewer parameters and computations while achieving competitive results on downstream tasks. There have been some works that task-specifically distill pre-trained large LMs into small models [13, 14, 15, 16]. They first fine-tune the pre-trained LMs on specific tasks and then perform distillation. Task-specific distillation is effective, but fine-tuning large pre-trained models is still costly, especially for large datasets. Different from task-specific distillation, task-agnostic LM distillation mimics the behavior of the original pre-trained LMs and the student model can be directly fine-tuned on downstream tasks [17, 18, 19, 20].

Previous works use soft target probabilities for masked language modeling predictions or intermediate representations of the teacher LM to guide the training of the task-agnostic student. DistilBERT [18] employs a soft-label distillation loss and a cosine embedding loss, and initializes the student from the teacher by taking one layer out of two. But each Transformer layer of the student is required to have the same architecture as its teacher. TinyBERT [19] and $\textsc{MobileBERT}$ [20] utilize more fine-grained knowledge, including hidden states and self-attention distributions of Transformer networks, and transfer these knowledge to the student model layer-to-layer. To perform layer-to-layer distillation, TinyBERT adopts a uniform function to determine the mapping between the teacher and student layers, and uses a parameter matrix to linearly transform student hidden states. $\textsc{MobileBERT}$ assumes the teacher and student have the same number of layers and introduces the bottleneck module to keep their hidden size the same.

In this work, we propose the deep self-attention distillation framework for task-agnostic Transformer based LM distillation. The key idea is to deeply mimic the self-attention modules which are the fundamentally important components in the Transformer based teacher and student models. Specifically, we propose distilling the self-attention module of the last Transformer layer of the teacher model. Compared with previous approaches, using knowledge of the last Transformer layer rather than performing layer-to-layer knowledge distillation alleviates the difficulties in layer mapping between the teacher and student models, and the layer number of our student model can be more flexible. Furthermore, we introduce the scaled dot-product between values in the self-attention module as the new deep self-attention knowledge, in addition to the attention distributions (i.e., the scaled dot-product of queries and keys) that has been used in existing works. Using scaled dot-product between self-attention values also converts representations of different dimensions into relation matrices with the same dimensions without introducing additional parameters to transform student representations, allowing arbitrary hidden dimensions for the student model. Finally, we show that introducing a teacher assistant [3] helps the distillation of large pre-trained Transformer based models and the proposed deep self-attention distillation can further boost the performance.

We conduct extensive experiments on downstream NLP tasks. Experimental results demonstrate that our monolingual model outperforms state-of-the-art baselines in different parameter size of student models. Specifically, the $6$-layer model of $768$ hidden dimensions distilled from BERT $\text{BASE}$ is $2.0\times$ faster, while retaining more than $99%$ accuracy on SQuAD 2.0 and several GLUE benchmark tasks. Moreover, our multilingual model distilled from XLM-R $\text{Base}$ also achieves competitive performance with much fewer Transformer parameters.

2. Preliminary

Section Summary: The preliminary section introduces the core components of Transformer-based models like BERT, starting with how text inputs are tokenized into subwords and represented as vectors combining token, position, and segment embeddings. It then describes the Transformer architecture, which uses stacked layers of self-attention mechanisms—where multiple heads calculate attention distributions from queries, keys, and values—and feed-forward networks to produce contextualized representations. Finally, it covers knowledge distillation techniques for compressing large pre-trained Transformers into smaller models by having the student mimic the teacher's outputs, attention patterns, and intermediate features.

Multi-layer Transformers [2] have been the most widely-used network structures in state-of-the-art pre-trained models. In this section, we present a brief introduction to the Transformer network and the self-attention mechanism, which is the core component of the Transformer. We also present the existing approaches on knowledge distillation for Transformer networks, particularly in the context of distilling a large Transformer based pre-trained model into a small Transformer model.

2.1 Input Representation

Texts are tokenized to subword units by WordPiece [21] in BERT [1]. For example, the word "forecasted" is split to "forecast" and "##ed", where "##" indicates the pieces are belong to one word. A special boundary token [SEP] is used to separate segments if the input text contains more than one segment. At the beginning of the sequence, a special token [CLS] is added to obtain the representation of the whole input. The vector representations (${\textbf{x}i}{i=1}^{|x|}$) of input tokens are computed via summing the corresponding token embedding, absolute position embedding, and segment embedding.

2.2 Backbone Network: Transformer

Transformer [2] is used to encode contextual information for input tokens. The input vectors ${\textbf{x}i}{i=1}^{|x|}$ are packed together into $\mathbf{H}^0 = [\mathbf{x}1, \cdot s, \mathbf{x}{|x|}]$. Then stacked Transformer blocks compute the encoding vectors as:

$ \mathbf{H}^l = \mathrm{Transformer}_{l}(\mathbf{H}^{l-1}), ~l \in [1, L]\tag{1} $

where $L$ is the number of Transformer layers, and the final output is $\mathbf{H}^L = [\mathbf{h}1^L, \cdot s, \mathbf{h}{|x|}^L]$. The hidden vector $\mathbf{h}_i^L$ is used as the contextualized representation of $\mathbf{x}_i$. Each Transformer layer consists of a self-attention sub-layer and a fully connected feed-forward network. Residual connection [22] is employed around each of the two sub-layers, followed by layer normalization [23].

**Figure 1:** Overview of Deep Self-Attention Distillation. The student is trained by deeply mimicking the self-attention behavior of the last Transformer layer of the teacher. In addition to the self-attention distributions, we introduce the self-attention value-relation transfer to help the student achieve a deeper mimicry. Our student models are named as $\textsc{MiniLM}$.

Self-Attention

In each layer, Transformer uses multiple self-attention heads to aggregate the output vectors of the previous layer. For the $l$-th Transformer layer, the output of a self-attention head $\mathbf{AO}_{l, a}, ~a \in [1, A_h]$ is computed via:

$ \begin{gathered} \mathbf{Q}{l, a} = \mathbf{H}^{l-1} \mathbf{W}{l, a}^Q, ~\mathbf{K}{l, a} = \mathbf{H}^{l-1} \mathbf{W}{l, a}^K, ~\mathbf{V}{l, a} = \mathbf{H}^{l-1} \mathbf{W}{l, a}^V \ \mathbf{A}{l, a} = \mathrm{softmax}(\frac{\mathbf{Q}{l, a} \mathbf{K}{l, a}^{\intercal}}{ \sqrt{d_k}}) \ \mathbf{AO}{l, a} = \mathbf{A}{l, a}\mathbf{V}{l, a} \end{gathered} $

where the previous layer's output $\mathbf{H}^{l-1} \in \mathbb{R}^{|x| \times d_h}$ is linearly projected to a triple of queries, keys and values using parameter matrices $\mathbf{W}{l, a}^Q, \mathbf{W}{l, a}^K, \mathbf{W}{l, a}^V \in \mathbb{R}^{d_h \times d_k}$, respectively. $\mathbf{A}{l, a} \in \mathbb{R}^{|x| \times |x|}$ indicates the attention distributions, which is computed by the scaled dot-product of queries and keys. $A_h$ represents the number of self-attention heads. $d_k \times A_h$ is equal to the hidden dimension $d_h$ in BERT.

2.3 Transformer Distillation

Knowledge distillation [11, 12] is to train the small student model $S$ on a transfer feature set with soft labels and intermediate representations provided by the large teacher model $T$. Knowledge distillation is modeled as minimizing the differences between teacher and student features:

$ \mathcal{L}{\text{KD}} = {\sum{e\in \mathcal{D}}{L(f^{S}(e), f^{T}(e))}}\tag{2} $

Where $\mathcal{D}$ denotes the training data, $f^{S}(\cdot)$ and $f^{T}(\cdot)$ indicate the features of student and teacher models respectively, $L(\cdot)$ represents the loss function. The mean squared error (MSE) and KL-divergence are often used as loss functions.

For Transformer based LM distillation, soft target probabilities for masked language modeling predictions, embedding layer outputs, self-attention distributions and outputs (hidden states) of each Transformer layer of the teacher model are used as features to help the training of the student. Soft labels and embedding layer outputs are used in DistillBERT. TinyBERT and $\textsc{MobileBERT}$ further utilize self-attention distributions and outputs of each Transformer layer. For $\textsc{MobileBERT}$, the student is required to have the same number of layers as its teacher to perform layer-to-layer distillation. Besides, bottleneck and inverted bottleneck modules are introduced to keep the hidden size of the teacher and student are also the same. To transfer knowledge layer-to-layer, TinyBERT employs a uniform-function to map teacher and student layers. Since the hidden size of the student can be smaller than its teacher, a parameter matrix is introduced to transform the student features.

::: caption="Table 1: Comparison with previous task-agnostic Transformer based LM distillation approaches."

:::

3. Deep Self-Attention Distillation

Section Summary: The core approach trains a compact student model to deeply imitate the self-attention behavior of a larger teacher Transformer, concentrating on the teacher's final layer rather than matching layers one-to-one. In addition to copying attention distributions between queries and keys, the method transfers relations among value vectors through scaled dot-product similarities, allowing the student to adopt flexible hidden sizes without extra projection parameters. When the student is much smaller than the teacher, an intermediate teacher-assistant model first bridges the gap before guiding the final student.

Figure 1 gives an overview of the deep self-attention distillation. The key idea is three-fold. First, we propose to train the student by deeply mimicking the self-attention module, which is the vital component in the Transformer, of the teacher's last layer. Second, we introduce transferring the relation between values (i.e., the scaled dot-product between values) to achieve a deeper mimicry, in addition to performing attention distributions (i.e., the scaled dot-product of queries and keys) transfer in the self-attention module. Moreover, we show that introducing a teacher assistant [3] also helps the distillation of large pre-trained Transformer models when the size gap between the teacher model and student model is large.

3.1 Self-Attention Distribution Transfer

The attention mechanism [24] has been a highly successful neural network component for NLP tasks, which is also crucial for pre-trained LMs. Some works show that self-attention distributions of pre-trained LMs capture a rich hierarchy of linguistic information [25, 26]. Transferring self-attention distributions has been used in previous works for Transformer distillation [19, 20, 16]. We also utilize the self-attention distributions to help the training of the student. Specifically, we minimize the KL-divergence between the self-attention distributions of the teacher and student:

$ \mathcal{L}{\text{AT}} = \frac{1}{A_h|x|}{\sum{a=1}^{A_h}{\sum_{t=1}^{|x|}{D_{KL}(\mathbf{A}^{T}{L, a, t} \parallel \mathbf{A}^{S}{M, a, t})}}}\tag{2} $

Where $|x|$ and $A_h$ represent the sequence length and the number of attention heads. $L$ and $M$ represent the number of layers for the teacher and student. $\mathbf{A}^{T}{L}$ and $\mathbf{A}^{S}{M}$ are the attention distributions of the last Transformer layer for the teacher and student, respectively. They are computed by the scaled dot-product of queries and keys.

Different from previous works which transfer teacher's knowledge layer-to-layer, we only use the attention maps of the teacher's last Transformer layer. Distilling attention knowledge of the last Transformer layer allows more flexibility for the number of layers of our student models, avoids the effort of finding the best layer mapping.

3.2 Self-Attention Value-Relation Transfer

In addition to the attention distributions, we propose using the relation between values in the self-attention module to guide the training of the student. The value relation is computed via the multi-head scaled dot-product between values. The KL-divergence between the value relation of the teacher and student is used as the training objective:

$ \begin{gathered} \mathbf{VR}{L, a}^T = \mathrm{softmax}(\frac{\mathbf{V}{L, a}^{T} \mathbf{V}{L, a}^{T\intercal}}{ \sqrt{d_k}}) \ \mathbf{VR}{M, a}^S = \mathrm{softmax}(\frac{\mathbf{V}{M, a}^{S} \mathbf{V}{M, a}^{S\intercal}}{ \sqrt{d_k^{\prime}}}) \ \mathcal{L}{\text{VR}} = \frac{1}{A_h|x|}{\sum{a=1}^{A_h}{\sum_{t=1}^{|x|}{D_{KL}(\mathbf{VR}^{T}{L, a, t} \parallel \mathbf{VR}^{S}{M, a, t})}}} \end{gathered}\tag{2} $

Where $\mathbf{V}{L, a}^{T} \in \mathbb{R}^{|x| \times d_k}$ and $\mathbf{V}{M, a}^{S} \in \mathbb{R}^{|x| \times d_k^{\prime}}$ are the values of an attention head in self-attention module for the teacher's and student's last Transformer layer. $\mathbf{VR}^{T}{L} \in \mathbb{R}^{A_h \times |x| \times |x|}$ and $\mathbf{VR}^{S}{M} \in \mathbb{R}^{A_h \times |x| \times |x|}$ are the value relation of the last Transformer layer for teacher and student, respectively.

The training loss is computed via summing the attention distribution transfer loss and value-relation transfer loss:

$ \mathcal{L} = \mathcal{L}{\text{AT}} + \mathcal{L}{\text{VR}} $

Introducing the relation between values enables the student to deeply mimic the teacher's self-attention behavior. Moreover, using the scaled dot-product converts vectors of different hidden dimensions into the relation matrices with the same size, which allows our students to use more flexible hidden dimensions and avoids introducing additional parameters to transform the student's representations.

::: {caption="Table 2: Comparison between the publicly released 6-layer models with 768 hidden size distilled from BERT _BASE . We compare task-agnostic distilled models without task-specific distillation and data augmentation. We report F1 for SQuAD 2.0, and accuracy for other datasets. The GLUE results of DistillBERT are taken from [18]. We report the SQuAD 2.0 result by fine-tuning their released model^3. For TinyBERT, we fine-tune the latest version of their public model^4 for a fair comparison. The results of our fine-tuning experiments are an average of 4 runs for each task."}

:::

3.3 Teacher Assistant

Following [3], we introduce a teacher assistant (i.e., intermediate-size student model) to further improve the model performance of smaller students.

Assuming the teacher model consists of $L$-layer Transformer with $d_{h}$ hidden size, the student model has $M$-layer Transformer with $d_{h}^{\prime}$ hidden size. For smaller students ($M\leq\frac{1}{2}L$, $d_{h}^{\prime}\leq\frac{1}{2}d_{h}$), we first distill the teacher into a teacher assistant with $L$-layer Transformer and $d_{h}^{\prime}$ hidden size. The assistant model is then used as the teacher to guide the training of the final student. The introduction of a teacher assistant bridges the size gap between teacher and smaller student models, helps the distillation of Transformer based pre-trained LMs. Moreover, combining deep self-attention distillation with a teacher assistant brings further improvements for smaller student models.

3.4 Comparison with Previous Work

Table 1 presents the comparison with previous approaches [18, 19, 20]. $\textsc{MobileBERT}$ proposes using a specially designed inverted bottleneck model, which has the same model size as BERT $\text{LARGE}$, as the teacher. The other methods utilize BERT $\text{BASE}$ to conduct experiments. For the knowledge used for distillation, our method introduces the scaled dot-product between values in the self-attention module as the new knowledge to deeply mimic teacher's self-attention behavior. TinyBERT and $\textsc{MobileBERT}$ transfer knowledge of the teacher to the student layer-to-layer. $\textsc{MobileBERT}$ assumes the student has the same number of layers as its teacher. TinyBERT employs a uniform strategy to determine its layer mapping. DistillBERT initializes the student with teacher's parameters, therefore selecting layers of the teacher model is still needed. $\textsc{MiniLM}$ distills the self-attention knowledge of the teacher's last Transformer layer, which allows the flexible number of layers for the students and alleviates the effort of finding the best layer mapping. Student hidden size of DistillBERT and $\textsc{MobileBERT}$ is required to be the same as its teacher. TinyBERT uses a parameter matrix to transform student hidden states. Using value relation allows our students to use arbitrary hidden size without introducing additional parameters.

4. Experiments

Section Summary: In the experiments, researchers distill a full-size BERT language model into various smaller student versions with fewer layers or dimensions, training them on a large corpus of English Wikipedia and book texts using standard optimization settings on multiple GPUs. They then test these compressed models on extractive question answering with the SQuAD 2.0 benchmark and on the nine sentence classification tasks that make up the GLUE benchmark. Results show that the distilled models match or exceed prior compressed versions in accuracy while running substantially faster, often retaining over 99 percent of the original performance at twice the speed.

We conduct distillation experiments in different parameter size of student models, and evaluate the distilled models on downstream tasks including extractive question answering and the GLUE benchmark.

::: {caption="Table 3: Comparison between student models of different architectures distilled from BERT _BASE . M and $d_h^{\prime}$ indicate the number of layers and hidden dimension of the student model. TA indicates teacher assistant^5. The fine-tuning results are averaged over 4 runs."}

:::

::: {caption="Table 4: The number of Embedding (Emd) and Transformer (Trm) parameters, and inference time for different models."}

:::

4.1 Distillation Setup

We use the uncased version of BERT $\text{BASE}$ as our teacher. BERT $\text{BASE}$ [1] is a $12$-layer Transformer with $768$ hidden size, and $12$ attention heads, which contains about $109$ M parameters. The number of heads of attention distributions and value relation are set to $12$ for student models. We use documents of English Wikipedia[^2] and BookCorpus [27] for the pre-training data, following the preprocess and the WordPiece tokenization of [1]. The vocabulary size is $30, 522$. The maximum sequence length is $512$. We use Adam [28] with $\beta_1=0.9$, $\beta_2=0.999$. We train the $6$-layer student model with $768$ hidden size using $1024$ as the batch size and 5e-4 as the peak learning rate for $400, 000$ steps. For student models of other architectures, the batch size and peak learning rate are set to $256$ and 3e-4, respectively. We use linear warmup over the first $4, 000$ steps and linear decay. The dropout rate is $0.1$. The weight decay is $0.01$.

[^2]: Wikipedia version: enwiki-20181101.

We also use an in-house pre-trained Transformer model in the BERT $_\text{BASE}$ size as the teacher model, and distill it into $12$-layer and $6$-layer student models with $384$ hidden size. For the $12$-layer model, we use Adam [28] with $\beta_1=0.9$, $\beta_2=0.98$. The model is trained using $2048$ as the batch size and 6e-4 as the peak learning rate for $400, 000$ steps. The batch size and peak learning rate are set to $512$ and 4e-4 for the $6$-layer model. The rest hyper-parameters are the same as above BERT based distilled models.

For the training of multilingual $\textsc{MiniLM}$ models, we use Adam [28] with $\beta_1=0.9$, $\beta_2=0.999$. We train the $12$-layer student model using $256$ as the batch size and 3e-4 as the peak learning rate for $1, 000, 000$ steps. The $6$-layer student model is trained using $512$ as the batch size and 6e-4 as the peak learning rate for $400, 000$ steps.

We distill our student models using $8$ V100 GPUs with mixed precision training. Following [15] and [19], the inference time is evaluated on the QNLI training set with the same hyper-parameters. We report the average running time of $100$ batches on a single P100 GPU.

4.2 Downstream Tasks

Following previous language model pre-training [1, 10] and task-agnostic pre-trained language model distillation [18, 19, 20], we evaluate our distilled models on the extractive question answering and GLUE benchmark.

Extractive Question Answering

Given a passage $P$, the task is to select a contiguous span of text in the passage by predicting its start and end positions to answer the question $Q$. We evaluate on SQuAD 2.0 [29], which has served as a major question answering benchmark.

Following BERT [1], we pack the question and passage tokens together with special tokens, to form the input: ```[CLS]$Q$[SEP]$P$[SEP]". Two linear output layers are introduced to predict the probability of each token being the start and end positions of the answer span. The questions that do not have an answer are treated as having an answer span with start and end at the [CLS]` token.

GLUE

The General Language Understanding Evaluation (GLUE) benchmark [30] consists of nine sentence-level classification tasks, including Corpus of Linguistic Acceptability (CoLA) [31], Stanford Sentiment Treebank (SST) [32], Microsoft Research Paraphrase Corpus (MRPC) [33], Semantic Textual Similarity Benchmark (STS) [34], Quora Question Pairs (QQP) [35], Multi-Genre Natural Language Inference (MNLI) [36], Question Natural Language Inference (QNLI) [37], Recognizing Textual Entailment (RTE) [38, 39, 40, 41] and Winograd Natural Language Inference (WNLI) [42]. We add a linear classifier on top of the [CLS] token to predict label probabilities.

4.3 Main Results

Previous works [18, 15, 19] usually distill BERT $\text{BASE}$ into a $6$-layer student model with $768$ hidden size. We first conduct distillation experiments using the same student architecture. Results on SQuAD 2.0 and GLUE dev sets are presented in Table 2. Since $\textsc{MobileBERT}$ distills a specially designed teacher with the inverted bottleneck modules, which has the same model size as BERT $\text{LARGE}$, into a $24$-layer student using the bottleneck modules, we do not compare our models with $\textsc{MobileBERT}$. $\textsc{MiniLM}$ outperforms DistillBERT[^3] and TinyBERT[^4] across most tasks. Our model exceeds the two state-of-the-art models by $3.0$ + $%$ F1 on SQuAD 2.0 and $5.0$ + $%$ accuracy on CoLA. We present the inference time for models in different parameter size in Table 4. Our $6$-layer $768$-dimensional student model is $2.0\times$ faster than original BERT $_\text{BASE}$, while retaining more than $99%$ performance on a variety of tasks, such as SQuAD 2.0 and MNLI.

[^3]: The public model of DistillBERT is obtained from https://github.com/huggingface/transformers/tree/master/examples/distillation

[^4]: We use the 2nd version TinyBERT from https://github.com/huawei-noah/Pretrained-Language-Model/tree/master/TinyBERT

We also conduct experiments for smaller student models. We compare $\textsc{MiniLM}$ with our implemented MLM-KD (knowledge distillation using soft target probabilities for masked language modeling predictions) and TinyBERT, which are trained using the same data and hyper-parameters. The results on SQuAD 2.0, MNLI and SST-2 dev sets are shown in Table 3. $\textsc{MiniLM}$ outperforms soft label distillation and our implemented TinyBERT on the three tasks. Deep self-attention distillation is also effective for smaller models. Moreover, we show that introducing a teacher assistant[^5] is also helpful in Transformer based pre-trained LM distillation, especially for smaller models. Combining deep self-attention distillation with a teacher assistant achieves further improvement for smaller student models.

[^5]: The teacher assistant is only introduced for the model $\textsc{MiniLM}$ (w/ TA). The model $\textsc{MiniLM}$ in different tables is directly distilled from its teacher model.

::: {caption="Table 5: Effectiveness of self-attention value-relation (Value-Rel) transfer. The fine-tuning results are averaged over 4 runs."}

:::

4.4 Ablation Studies

We do ablation tests on several tasks to analyze the contribution of self-attention value-relation transfer. The dev results of SQuAD 2.0, MNLI and SST-2 are illustrated in Table 5, using self-attention value-relation transfer positively contributes to the final results for student models in different parameter size. Distilling the fine-grained knowledge of value relation helps the student model deeply mimic the self-attention behavior of the teacher, which further improves model performance.

We also compare different loss functions over values in the self-attention module. We compare our proposed value relation with mean squared error (MSE) over the teacher and student values. An additional parameter matrix is introduced to transform student values if the hidden dimension of the student is smaller than its teacher. The dev results on three tasks are presented in Table 6. Using value relation achieves better performance. Specifically, our method brings about $1.0%$ F1 improvement on the SQuAD benchmark. Moreover, there is no need to introduce additional parameters for our method. We have also tried to transfer the relation between hidden states. But we find the performance of student models are unstable for different teacher models.

To show the effectiveness of distilling self-attention knowledge of the teacher's last Transformer layer, we compare our method with layer-to-layer distillation. We transfer the same knowledge and adopt a uniform strategy as in [19] to map teacher and student layers to perform layer-to-layer distillation. The dev results on three tasks are presented in Table 7. $\textsc{MiniLM}$ achieves better results. It also alleviates the difficulties in layer mapping between the teacher and student. Besides, distilling the teacher's last Transformer layer requires less computation than layer-to-layer distillation, results in faster training speed.

::: {caption="Table 6: Comparison between different loss functions: KL-divergence over the value relation (the scaled dot-product between values) and mean squared error (MSE) over values. A parameter matrix is introduced to transform student values to have the same dimensions as the teacher values [19]. The fine-tuning results are an average of 4 runs for each task."}

:::

::: {caption="Table 7: Comparison between distilling knowledge of the teacher's last Transformer layer and layer-to-layer distillation. We adopt a uniform strategy as in [19] to determine the mapping between teacher and student layers. The fine-tuning results are an average of 4 runs for each task."}

:::

::: {caption="Table 8: The results of MiniLM distilled from an in-house pre-trained Transformer model (BERT _BASE size, 12-layer Transformer, 768-hidden size, and 12 self-attention heads) on SQuAD 2.0 and GLUE benchmark. We report our 12-layer^a and 6-layer^b models with 384 hidden size. The fine-tuning results are averaged over 4 runs."}

:::

::: {caption="Table 9: Question generation results of our 12-layer^a and 6-layer^b models with 384 hidden size on SQuAD 1.1. The first block follows the data split in [43], while the second block is the same as in [44]. MTR is short for METEOR, RG for ROUGE, and B for BLEU."}

:::

\begin{tabular}{lclccclccc}
\toprule
\multirow{2}{*}${\bf Model}$ & \multirow{2}{*}${\bf #Param}$ & & \multicolumn{3}{c}${\bf CNN/DailyMail}$ & & \multicolumn{3}{c}${\bf XSum}$ \\
& & & RG-1 & RG-2 & RG-L & & RG-1 & RG-2 & RG-L \\ \midrule
$\textsc{Lead}$-3 & & & 40.42 & 17.62 & 36.67 & & 16.30 & 1.60 & 11.95 \\
$\textsc{PtrNet}$ [46] & & & 39.53 & 17.28 & 36.38 & & 28.10 & 8.02 & 21.72 \\
Bottom-Up [47] & & & 41.22 & 18.68 & 38.34 & & - & - & - \\
 $\textsc{UniLM}$ $_{\textsc{large}}$ [7] & 340M & & 43.08 & 20.43 & 40.34 & & - & - & - \\
 BART $_{\textsc{large}}$ [48] & 400M & & 44.16 & 21.28 & 40.90 & & 45.14 & 22.27 & 37.25 \\
 {T5 $_{\textsc{11B}}$} [49] & 11B & & 43.52 & 21.55 & 40.69 & & - & - & - \\
{MASS $_{\textsc{base}}$} [50] & 123M & & 42.12 & 19.50 & 39.01 & & 39.75 & 17.24 & 31.95 \\
$\textsc{BERTSumAbs}$ [51] & 156M & & 41.72 & 19.39 & 38.76 & & 38.76 & 16.33 & 31.15 \\
{T5 $_{\textsc{base}}$} [49] & 220M & & 42.05 & 20.34 & 39.40 & & - & - & - \\ \midrule
$\textsc{MiniLM}$^{a}$ & 33M & & 42.66 & 19.91 & 39.73 & & 40.43 & 17.72 & 32.60 \\
$\textsc{MiniLM}$^{b}$ (w/ TA) & 22M & & 41.57 & 19.21 & 38.64 & & 38.79 & 16.39 & 31.10 \\
\bottomrule
\end{tabular}

::: {caption="Table 11: Cross-lingual classification results of our 12-layer^a and 6-layer^b multilingual models with 384 hidden size on XNLI. We report the accuracy on each of the 15 XNLI languages and the average accuracy. Results of mBERT, XLM-100 and XLM-R _Base are from [52]."}

:::

::: {caption="Table 12: The number of Transformer (Trm) and Embedding (Emd) parameters for different multilingual pre-trained models and our distilled models."}

:::

::: {caption="Table 13: Cross-lingual question answering results of our 12-layer^a and 6-layer^b multilingual models with 384 hidden size on MLQA. We report the F1 and EM (exact match) scores on each of the 7 MLQA languages. Results of mBERT and XLM- 15 are taken from [53]. † indicates results of XLM-R _Base taken from [52]. We also report our fine-tuned results (‡) of XLM-R _Base ."}

:::

5. Discussion

Section Summary: The discussion shows that MiniLM distillation benefits substantially from a stronger teacher model trained on larger data, yielding compact 6- and 12-layer students that match or exceed BERT-base accuracy on SQuAD and GLUE while running several times faster. The same approach extends successfully to natural-language generation, where the distilled models produce competitive results on question generation and abstractive summarization despite having far fewer parameters than prior systems. Finally, the method scales to multilingual settings by distilling XLM-R, delivering strong performance on XNLI and MLQA with substantially reduced training cost because only the teacher’s self-attention relations are transferred.

5.1 Better Teacher Better Student

We report the results of $\textsc{MiniLM}$ distilled from an in-house pre-trained Transformer model following $\textsc{UniLM}$ [7, 54] in the BERT $\text{BASE}$ size. The teacher model is trained using similar pre-training datasets as in RoBERTa ${\textsc{base}}$ [10], which includes $160$ GB text corpora from English Wikipedia, BookCorpus [27], OpenWebText^6, CC-News [10], and Stories [55]. We distill the teacher model into $12$-layer and $6$-layer models with $384$ hidden size using the same corpora. The $12$ x $384$ model is used as the teacher assistant to train the $6$ x $384$ model. We present the dev results of SQuAD 2.0 and GLUE benchmark in Table 8, the results of $\textsc{MiniLM}$ are significantly improved. The $12$ x $384$ $\textsc{MiniLM}$ achieves $2.7\times$ speedup while performs competitively better than BERT $_\text{BASE}$ in SQuAD 2.0 and GLUE benchmark datasets.

5.2 $\textsc{MiniLM}$ for NLG Tasks

We also evaluate $\textsc{MiniLM}$ on natural language generation tasks, such as question generation and abstractive summarization. Following [7], we fine-tune $\textsc{MiniLM}$ as a sequence-to-sequence model by employing a specific self-attention mask.

Question Generation

We conduct experiments for the answer-aware question generation task [43]. Given an input passage and an answer, the task is to generate a question that asks for the answer. The SQuAD 1.1 dataset [37] is used for evaluation. The results of $\textsc{MiniLM}$, $\textsc{UniLM}$ $_{\textsc{large}}$ and several state-of-the-art models are presented in Table 9, our $12$ x $384$ and $6$ x $384$ distilled models achieve competitive performance on the question generation task.

Abstractive Summarization

We evaluate $\textsc{MiniLM}$ on two abstractive summarization datasets, i.e., XSum [56], and the non-anonymized version of CNN/DailyMail [46]. The generation task is to condense a document into a concise and fluent summary, while conveying its key information. We report ROUGE scores [57] on the datasets. Table 10 presents the results of $\textsc{MiniLM}$, baseline, several state-of-the-art models and pre-trained Transformer models. Our $12$ x $384$ model outperforms BERT based method $\textsc{BERTSumAbs}$ [51] and the pre-trained sequence-to-sequence model MASS $_{\textsc{base}}$ [50] with much fewer parameters. Moreover, our $6$ x $384$ $\textsc{MiniLM}$ also achieves competitive performance.

5.3 Multilingual $\textsc{MiniLM}$

We conduct experiments on task-agnostic knowledge distillation of multilingual pre-trained models. We use the XLM-R $_\text{Base}$ [^7] [52] as the teacher and distill the model into $12$-layer and $6$-layer models with 384 hidden size using the same corpora. The $6$ x $384$ model is trained using the $12$ x $384$ model as the teacher assistant. Given the vocabulary size of multilingual pre-trained models is much larger than monolingual models (30k for monolingual BERT, 250k for XLM-R), soft-label distillation for multilingual pre-trained models requires more computation. $\textsc{MiniLM}$ only uses the deep self-attention knowledge of the teacher's last Transformer layer. The training speed of $\textsc{MiniLM}$ is much faster than soft-label distillation for multilingual pre-trained models.

[^7]: We use the v $0$ version of XLM-R $_\text{Base}$ in our distillation and fine-tuning experiments.

We evaluate the student models on cross-lingual natural language inference (XNLI) benchmark [58] and cross-lingual question answering (MLQA) benchmark [53].

XNLI

Table 11 presents XNLI results of our distilled students and several pre-trained LMs. Following [52], we select the best single model on the joint dev set of all the languages. We present the number of Transformer and embedding parameters for different multilingual pre-trained models and our distilled models in Table 12. $\textsc{MiniLM}$ achieves competitive performance on XNLI with much fewer Transformer parameters. Moreover, the $12$ x $384$ $\textsc{MiniLM}$ compares favorably with mBERT [1] and XLM [59] trained on the MLM objective.

MLQA

Table 13 shows cross-lingual question answering results. Following [53], we adopt SQuAD 1.1 as training data and use MLQA English development data for early stopping. The $12$ x $384$ $\textsc{MiniLM}$ performs competitively better than mBERT and XLM. Our $6$-layer $\textsc{MiniLM}$ also achieves competitive performance.

6. Related Work

Section Summary: Recent advances in natural-language processing have come from large pre-trained language models such as BERT, which learn rich contextual representations through masked-language-modeling objectives and have inspired many variants aimed at both understanding and generation tasks. A parallel line of research has explored knowledge distillation, in which a compact “student” model is trained to mimic the behavior of a much larger “teacher” model; some approaches perform this distillation after the teacher is fine-tuned on a specific task, while others do so in a task-agnostic fashion so the resulting student can later be fine-tuned on any downstream problem. The reviewed methods differ in the kinds of internal signals they transfer—soft predictions, hidden states, attention distributions—and in the constraints they place on the student’s architecture, setting the stage for the current work’s simpler, last-layer attention-based distillation scheme that avoids many of these restrictions.

6.1 Pre-trained Language Models

Unsupervised pre-training of language models [4, 5, 6, 1, 60, 50, 7, 8, 9, 10, 48, 49] has achieved significant improvements for a wide range of NLP tasks. Early methods for pre-training [4, 6] were based on standard language models. Recently, BERT [1] proposes to use a masked language modeling objective to train a deep bidirectional Transformer encoder, which learns interactions between left and right context. [10] show that very strong performance can be achieved by training the model longer over more data. [9] extend BERT by masking contiguous random spans. [8] predict masked tokens auto-regressively in a permuted order.

To extend the applicability of pre-trained Transformers for NLG tasks. [7] extend BERT by utilizing specific self-attention masks to jointly optimize bidirectional, unidirectional and sequence-to-sequence masked language modeling objectives. [49] employ an encoder-decoder Transformer and perform sequence-to-sequence pre-training by predicting the masked tokens in the encoder and decoder. Different from [49], [48] predict tokens auto-regressively in the decoder.

6.2 Knowledge Distillation

Knowledge distillation has proven a promising way to compress large models while maintaining accuracy. It transfers the knowledge of a large model or an ensemble of neural networks (teacher) to a single lightweight model (student). [11] first propose transferring the knowledge of the teacher to the student by using its soft target distributions to train the distilled model. [12] introduce intermediate representations from hidden layers of the teacher to guide the training of the student. Knowledge of the attention maps [61, 62] is also introduced to help the training.

In this work, we focus on task-agnostic knowledge distillation of large pre-trained Transformer based language models. There have been some works that task-specifically distill the fine-tuned language models on downstream tasks. [13] distill fine-tuned BERT into an extremely small bidirectional LSTM. [63] initialize the student with a small pre-trained LM during task-specific distillation. [15] introduce the hidden states from every $k$ layers of the teacher to perform knowledge distillation layer-to-layer. [16] further introduce the knowledge of self-attention distributions and propose progressive and stacked distillation methods. Task-specific distillation requires to first fine-tune the large pre-trained LMs on downstream tasks and then perform knowledge transfer. The procedure of fine-tuning large pre-trained LMs is costly and time-consuming, especially for large datasets.

For task-agnostic distillation, the distilled model mimics the original large pre-trained LM and can be directly fine-tuned on downstream tasks. In practice, task-agnostic compression of pre-trained LMs is more desirable. MiniBERT [17] uses the soft target distributions for masked language modeling predictions to guide the training of the multilingual student model and shows its effectiveness on sequence labeling tasks. DistillBERT [18] uses the soft label and embedding outputs of the teacher to train the student. TinyBERT [19] and $\textsc{MobileBERT}$ [20] further introduce self-attention distributions and hidden states to train the student. $\textsc{MobileBERT}$ employs inverted bottleneck and bottleneck modules for teacher and student to make their hidden dimensions the same. The student model of $\textsc{MobileBERT}$ is required to have the same number of layers as its teacher to perform layer-to-layer distillation. Besides, $\textsc{MobileBERT}$ proposes a bottom-to-top progressive scheme to transfer teacher's knowledge. TinyBERT uses a uniform-strategy to map the layers of teacher and student when they have different number of layers, and a linear matrix is introduced to transform the student hidden states to have the same dimensions as the teacher. TinyBERT also introduces task-specific distillation and data augmentation for downstream tasks, which brings further improvements.

Different from previous works, our method employs the self-attention distributions and value relation of the teacher's last Transformer layer to help the student deeply mimic the self-attention behavior of the teacher. Using knowledge of the last Transformer layer instead of layer-to-layer distillation avoids restrictions on the number of student layers and the effort of finding the best layer mapping. Distilling relation between self-attention values allows the hidden size of students to be more flexible and avoids introducing linear matrices to transform student representations.

7. Conclusion

Section Summary: Researchers have developed a straightforward technique for shrinking large language models based on Transformer architecture by training a smaller "student" version to closely imitate the attention patterns inside the teacher's final processing layer. Adding an intermediate-sized teacher assistant further improves results, allowing the compressed model to match or exceed previous methods on question-answering and language-understanding tasks. The same approach can be extended to even bigger models, which remains a goal for future study.

In this work, we propose a simple and effective knowledge distillation method to compress large pre-trained Transformer based language models. The student is trained by deeply mimicking the teacher's self-attention modules, which are the vital components of the Transformer networks. We propose using the self-attention distributions and value relation of the teacher's last Transformer layer to guide the training of the student , which is effective and flexible for the student models. Moreover, we show that introducing a teacher assistant also helps pre-trained Transformer based LM distillation, and the proposed deep self-attention distillation can further boost the performance. Our student model distilled from BERT $_\text{BASE}$ retains high accuracy on SQuAD 2.0 and the GLUE benchmark tasks, and outperforms state-of-the-art baselines. The deep self-attention distillation can also be applied to compress pre-trained models in larger size. We leave it as our future work.

Appendix

Section Summary: The appendix provides supporting details for language model evaluations and training procedures. It first summarizes the GLUE benchmark datasets along with SQuAD 2.0 statistics and metrics. It then specifies the hyper-parameters used for fine-tuning both 6-layer and 12-layer distilled models on extractive question answering, GLUE tasks, question generation, abstractive summarization, and cross-lingual inference and QA, including choices for sequence length, batch size, learning rate, epochs, and decoding settings.

A. GLUE Benchmark

The summary of datasets used for the General Language Understanding Evaluation (GLUE) benchmark^8 [30] is presented in Table 14.

We present the dataset statistics and metrics of SQuAD 2.0^9 [29] in Table 15.

B. Fine-tuning Hyper-parameters

Extractive Question Answering

For SQuAD 2.0, the maximum sequence length is $384$ and a sliding window of size $128$ if the lengths are longer than $384$. For the $12$-layer model distilled from our in-house pre-trained model, we fine-tune $3$ epochs using $48$ as the batch size and 4e-5 as the peak learning rate. The rest distilled models are trained using $32$ as the batch size and 6e-5 as the peak learning rate for $3$ epochs.

GLUE

The maximum sequence length is $128$ for the GLUE benchmark. We set batch size to $32$, choose learning rates from 2e-5, 3e-5, 4e-5, 5e-5 and epochs from $3$, $4$, $5$ for student models distilled from BERT $_\text{BASE}$ . For student models distilled from our in-house pre-trained model, the batch size is chosen from $32$, $48$. We fine-tune several tasks (CoLA, RTE and MRPC) with longer epochs (up to $10$ epochs), which brings slight improvements. For the $12$-layer model, the learning rate used for CoLA, RTE and MRPC tasks is 1.5e-5.

\begin{tabular}{lcccc}
\toprule \textbf{Corpus} & \textbf{\#Train} & \textbf{\#Dev} & \textbf{\#Test} & \textbf{Metrics} \\ \midrule
\multicolumn{5}{l}{*Single-Sentence Tasks*} \\
CoLA & 8.5k & 1k & 1k & Matthews Corr \\
SST-2 & 67k & 872 & 1.8k & Accuracy \\
\midrule
\multicolumn{5}{l}{*Similarity and Paraphrase Tasks*} \\
QQP & 364k & 40k & 391k & Accuracy/F1 \\
MRPC & 3.7k & 408 & 1.7k & Accuracy/F1\\
STS-B & 7k & 1.5k & 1.4k & Pearson/Spearman Corr \\
\midrule
\multicolumn{5}{l}{*Inference Tasks*} \\
MNLI & 393k & 20k &20k & Accuracy\\
RTE &2.5k & 276 & 3k & Accuracy \\
QNLI & 105k & 5.5k & 5.5k & Accuracy\\
WNLI & 634 & 71 & 146 & Accuracy\\
\bottomrule
\end{tabular}

: Table 15: Dataset statistics and metrics of SQuAD 2.0.

#Train #Dev #Test Metrics
130, 319 11, 873 8, 862 Exact Match/F1

C. SQuAD 2.0

Question Generation

For the question generation task, we set batch size to $32$, and total length to $512$. The maximum output length is $48$. The learning rates are 3e-5 and 8e-5 for the $12$-layer and $6$-layer models, respectively. They are both fine-tuned for $25$ epochs. We also use label smoothing [64] with rate of $0.1$. During decoding, we use beam search with beam size of $5$. The length penalty [21] is $1.3$.

Abstractive Summarization

For the abstractive summarization task, we set batch size to $64$, and the rate of label smoothing to $0.1$. For the CNN/DailyMail dataset, the total length is $768$ and the maximum output length is $160$. The learning rates are 1e-4 and 1.5e-4 for the $12$-layer and $6$-layer models, respectively. They are both fine-tuned for $25$ epochs. During decoding, we set beam size to $5$, and the length penalty to $0.7$. For the XSum dataset, the total length is $512$ and the maximum output length is $48$. The learning rates are 1e-4 and 1.5e-4 for the $12$-layer and $6$-layer models, respectively. We fine-tune $30$ epochs for the $12$-layer model and $50$ epochs for the $6$-layer model. During decoding, we use beam search with beam size of $5$. The length penalty is set to $0.9$.

Cross-lingual Natural Language Inference

The maximum sequence length is $128$ for XNLI. We fine-tune $5$ epochs using $128$ as the batch size, choose learning rates from 3e-5, 4e-5, 5e-5, 6e-5.

Cross-lingual Question Answering

For MLQA, the maximum sequence length is $512$ and a sliding window of size $128$ if the lengths are longer than $512$. We fine-tune $3$ epochs using $32$ as the batch size. The learning rates are chosen from 3e-5, 4e-5, 5e-5, 6e-5.

References

Section Summary: This section lists academic citations for research papers focused on transformer-based language models such as BERT and its variants, along with related advances in pre-training and contextual word representations. It also includes multiple works on knowledge distillation methods designed to compress large models into smaller, faster versions while preserving performance. The references span key publications from 2015 to 2019 in natural language processing and machine learning.

[1] Devlin, J., Chang, M., Lee, K., and Toutanova, K. BERT: pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018.

[2] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., and Polosukhin, I. Attention is all you need. In Advances in Neural Information Processing Systems 30, pp. 5998–6008. Curran Associates, Inc., 2017. URL http://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf.

[3] Mirzadeh, S., Farajtabar, M., Li, A., and Ghasemzadeh, H. Improved knowledge distillation via teacher assistant: Bridging the gap between student and teacher. CoRR, abs/1902.03393, 2019. URL http://arxiv.org/abs/1902.03393.

[4] Peters, M., Neumann, M., Iyyer, M., Gardner, M., Clark, C., Lee, K., and Zettlemoyer, L. Deep contextualized word representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 2227–2237, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. URL http://www.aclweb.org/anthology/N18-1202.

[5] Howard, J. and Ruder, S. Universal language model fine-tuning for text classification. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 328–339, Melbourne, Australia, July 2018. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/P18-1031.

[6] Radford, A., Narasimhan, K., Salimans, T., and Sutskever, I. Improving language understanding by generative pre-training. 2018. URL [https://s3-us-west-2.amazonaws.com/openaiassets/research-covers/language-unsupervised/language understanding paper.pdf](https://s3-us-west-2.amazonaws.com/openaiassets/research-covers/language-unsupervised/language understanding paper.pdf).

[7] Dong, L., Yang, N., Wang, W., Wei, F., Liu, X., Wang, Y., Gao, J., Zhou, M., and Hon, H.-W. Unified language model pre-training for natural language understanding and generation. In 33rd Conference on Neural Information Processing Systems (NeurIPS 2019), 2019.

[8] Yang, Z., Dai, Z., Yang, Y., Carbonell, J., Salakhutdinov, R., and Le, Q. V. XLNet: Generalized autoregressive pretraining for language understanding. In 33rd Conference on Neural Information Processing Systems (NeurIPS 2019), 2019.

[9] Joshi, M., Chen, D., Liu, Y., Weld, D. S., Zettlemoyer, L., and Levy, O. Spanbert: Improving pre-training by representing and predicting spans. arXiv preprint arXiv:1907.10529, 2019.

[10] Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., and Stoyanov, V. RoBERTa: A robustly optimized BERT pretraining approach. arXiv preprint arXiv:1907.11692, 2019.

[11] Hinton, G. E., Vinyals, O., and Dean, J. Distilling the knowledge in a neural network. CoRR, abs/1503.02531, 2015. URL http://arxiv.org/abs/1503.02531.

[12] Romero, A., Ballas, N., Kahou, S. E., Chassang, A., Gatta, C., and Bengio, Y. Fitnets: Hints for thin deep nets. In 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.org/abs/1412.6550.

[13] Tang, R., Lu, Y., Liu, L., Mou, L., Vechtomova, O., and Lin, J. Distilling task-specific knowledge from BERT into simple neural networks. CoRR, abs/1903.12136, 2019. URL http://arxiv.org/abs/1903.12136.

[14] Turc, I., Chang, M., Lee, K., and Toutanova, K. Well-read students learn better: The impact of student initialization on knowledge distillation. CoRR, abs/1908.08962, 2019b. URL http://arxiv.org/abs/1908.08962.

[15] Sun, S., Cheng, Y., Gan, Z., and Liu, J. Patient knowledge distillation for BERT model compression. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing, EMNLP-IJCNLP 2019, Hong Kong, China, November 3-7, 2019, pp. 4322–4331, 2019a.

[16] Aguilar, G., Ling, Y., Zhang, Y., Yao, B., Fan, X., and Guo, E. Knowledge distillation from internal representations. CoRR, abs/1910.03723, 2019. URL http://arxiv.org/abs/1910.03723.

[17] Tsai, H., Riesa, J., Johnson, M., Arivazhagan, N., Li, X., and Archer, A. Small and practical BERT models for sequence labeling. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing, EMNLP-IJCNLP 2019, Hong Kong, China, November 3-7, 2019, pp. 3630–3634, 2019.

[18] Sanh, V., Debut, L., Chaumond, J., and Wolf, T. Distilbert, a distilled version of BERT: smaller, faster, cheaper and lighter. CoRR, abs/1910.01108, 2019. URL http://arxiv.org/abs/1910.01108.

[19] Jiao, X., Yin, Y., Shang, L., Jiang, X., Chen, X., Li, L., Wang, F., and Liu, Q. Tinybert: Distilling BERT for natural language understanding. CoRR, abs/1909.10351, 2019. URL http://arxiv.org/abs/1909.10351.

[20] Sun, Z., Yu, H., Song, X., Liu, R., Yang, Y., and Zhou, D. Mobilebert: Task-agnostic compression of bert by progressive knowledge transfer, 2019b. URL https://openreview.net/pdf?id=SJxjVaNKwB.

[21] Wu, Y., Schuster, M., Chen, Z., Le, Q. V., Norouzi, M., Macherey, W., Krikun, M., Cao, Y., Gao, Q., Macherey, K., Klingner, J., Shah, A., Johnson, M., Liu, X., Kaiser, L., Gouws, S., Kato, Y., Kudo, T., Kazawa, H., Stevens, K., Kurian, G., Patil, N., Wang, W., Young, C., Smith, J., Riesa, J., Rudnick, A., Vinyals, O., Corrado, G., Hughes, M., and Dean, J. Google's neural machine translation system: Bridging the gap between human and machine translation. CoRR, abs/1609.08144, 2016. URL http://arxiv.org/abs/1609.08144.

[22] He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pp. 770–778, 2016.

[23] Ba, L. J., Kiros, J. R., and Hinton, G. E. Layer normalization. CoRR, abs/1607.06450, 2016. URL http://arxiv.org/abs/1607.06450.

[24] Bahdanau, D., Cho, K., and Bengio, Y. Neural machine translation by jointly learning to align and translate. In 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015.

[25] Jawahar, G., Sagot, B., and Seddah, D. What does BERT learn about the structure of language? In Proceedings of the 57th Conference of the Association for Computational Linguistics, ACL 2019, Florence, Italy, July 28- August 2, 2019, Volume 1: Long Papers, pp. 3651–3657, 2019. URL https://www.aclweb.org/anthology/P19-1356/.

[26] Clark, K., Khandelwal, U., Levy, O., and Manning, C. D. What does BERT look at? an analysis of bert's attention. CoRR, abs/1906.04341, 2019. URL http://arxiv.org/abs/1906.04341.

[27] Zhu, Y., Kiros, R., Zemel, R., Salakhutdinov, R., Urtasun, R., Torralba, A., and Fidler, S. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In Proceedings of the IEEE international conference on computer vision, pp. 19–27, 2015.

[28] Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. In 3rd International Conference on Learning Representations, San Diego, CA, 2015. URL http://arxiv.org/abs/1412.6980.

[29] Rajpurkar, P., Jia, R., and Liang, P. Know what you don't know: Unanswerable questions for SQuAD. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics, ACL 2018, Melbourne, Australia, July 15-20, 2018, Volume 2: Short Papers, pp. 784–789, 2018.

[30] Wang, A., Singh, A., Michael, J., Hill, F., Levy, O., and Bowman, S. R. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=rJ4km2R5t7.

[31] Warstadt, A., Singh, A., and Bowman, S. R. Neural network acceptability judgments. arXiv preprint arXiv:1805.12471, 2018.

[32] Socher, R., Perelygin, A., Wu, J., Chuang, J., Manning, C. D., Ng, A., and Potts, C. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 conference on empirical methods in natural language processing, pp. 1631–1642, 2013.

[33] Dolan, W. B. and Brockett, C. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005.

[34] Cer, D., Diab, M., Agirre, E., Lopez-Gazpio, I., and Specia, L. Semeval-2017 task 1: Semantic textual similarity-multilingual and cross-lingual focused evaluation. arXiv preprint arXiv:1708.00055, 2017.

[35] Chen, Z., Zhang, H., Zhang, X., and Zhao, L. Quora question pairs. 2018.

[36] Williams, A., Nangia, N., and Bowman, S. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi:10.18653/v1/N18-1101. URL https://www.aclweb.org/anthology/N18-1101.

[37] Rajpurkar, P., Zhang, J., Lopyrev, K., and Liang, P. SQuAD: 100,000+ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383–2392, Austin, Texas, November 2016. Association for Computational Linguistics. doi:10.18653/v1/D16-1264. URL https://www.aclweb.org/anthology/D16-1264.

[38] Dagan, I., Glickman, O., and Magnini, B. The pascal recognising textual entailment challenge. In Proceedings of the First International Conference on Machine Learning Challenges: Evaluating Predictive Uncertainty Visual Object Classification, and Recognizing Textual Entailment, MLCW'05, pp. 177–190, Berlin, Heidelberg, 2006. Springer-Verlag. ISBN 3-540-33427-0, 978-3-540-33427-9. doi:10.1007/1173679$0_9$. URL http://dx.doi.org/10.1007/1173679$0_9$.

[39] Bar-Haim, R., Dagan, I., Dolan, B., Ferro, L., and Giampiccolo, D. The second PASCAL recognising textual entailment challenge. In Proceedings of the Second PASCAL Challenges Workshop on Recognising Textual Entailment, 01 2006.

[40] Giampiccolo, D., Magnini, B., Dagan, I., and Dolan, B. The third PASCAL recognizing textual entailment challenge. In Proceedings of the ACL-PASCAL Workshop on Textual Entailment and Paraphrasing, pp. 1–9, Prague, June 2007. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/W07-1401.

[41] Bentivogli, L., Dagan, I., Dang, H. T., Giampiccolo, D., and Magnini, B. The fifth pascal recognizing textual entailment challenge. In In Proc Text Analysis Conference (TAC’09, 2009.

[42] Levesque, H., Davis, E., and Morgenstern, L. The winograd schema challenge. In Thirteenth International Conference on the Principles of Knowledge Representation and Reasoning, 2012.

[43] Du, X. and Cardie, C. Harvesting paragraph-level question-answer pairs from wikipedia. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics, ACL 2018, Melbourne, Australia, July 15-20, 2018, Volume 1: Long Papers, pp. 1907–1917, 2018.

[44] Zhao, Y., Ni, X., Ding, Y., and Ke, Q. Paragraph-level neural question generation with maxout pointer and gated self-attention networks. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 3901–3910, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/D18-1424.

[45] Zhang, S. and Bansal, M. Addressing semantic drift in question generation for semi-supervised question answering. CoRR, abs/1909.06356, 2019.

[46] See, A., Liu, P. J., and Manning, C. D. Get to the point: Summarization with pointer-generator networks. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1073–1083, Vancouver, Canada, July 2017. Association for Computational Linguistics. doi:10.18653/v1/P17-1099. URL https://www.aclweb.org/anthology/P17-1099.

[47] Gehrmann, S., Deng, Y., and Rush, A. Bottom-up abstractive summarization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 4098–4109, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/D18-1443.

[48] Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., and Zettlemoyer, L. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019a.

[49] Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.

[50] Song, K., Tan, X., Qin, T., Lu, J., and Liu, T.-Y. Mass: Masked sequence to sequence pre-training for language generation. arXiv preprint arXiv:1905.02450, 2019.

[51] Liu, Y. and Lapata, M. Text summarization with pretrained encoders. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing, pp. 3730–3740, Hong Kong, China, 2019.

[52] Conneau, A., Khandelwal, K., Goyal, N., Chaudhary, V., Wenzek, G., Guzmán, F., Grave, E., Ott, M., Zettlemoyer, L., and Stoyanov, V. Unsupervised cross-lingual representation learning at scale. CoRR, abs/1911.02116, 2019. URL http://arxiv.org/abs/1911.02116.

[53] Lewis, P. S. H., Oguz, B., Rinott, R., Riedel, S., and Schwenk, H. MLQA: evaluating cross-lingual extractive question answering. CoRR, abs/1910.07475, 2019b. URL http://arxiv.org/abs/1910.07475.

[54] Bao, H., Dong, L., Wei, F., Wang, W., Yang, N., Liu, X., Wang, Y., Piao, S., Gao, J., Zhou, M., and Hon, H.-W. Unilmv2: Pseudo-masked language models for unified language model pre-training. arXiv preprint arXiv:2002.12804, 2020.

[55] Trinh, T. H. and Le, Q. V. A simple method for commonsense reasoning. ArXiv, abs/1806.02847, 2018.

[56] Narayan, S., Cohen, S. B., and Lapata, M. Don't give me the details, just the summary! topic-aware convolutional neural networks for extreme summarization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 1797–1807, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi:10.18653/v1/D18-1206. URL https://www.aclweb.org/anthology/D18-1206.

[57] Lin, C.-Y. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out: Proceedings of the ACL-04 Workshop, pp. 74–81, Barcelona, Spain, July 2004. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/W04-1013.

[58] Conneau, A., Lample, G., Rinott, R., Williams, A., Bowman, S. R., Schwenk, H., and Stoyanov, V. Xnli: Evaluating cross-lingual sentence representations. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2018.

[59] Lample, G. and Conneau, A. Cross-lingual language model pretraining. Advances in Neural Information Processing Systems (NeurIPS), 2019.

[60] Baevski, A., Edunov, S., Liu, Y., Zettlemoyer, L., and Auli, M. Cloze-driven pretraining of self-attention networks. arXiv preprint arXiv:1903.07785, 2019.

[61] Zagoruyko, S. and Komodakis, N. Paying more attention to attention: Improving the performance of convolutional neural networks via attention transfer. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings, 2017. URL https://openreview.net/forum?id=Sks9_ajex.

[62] Hu, M., Peng, Y., Wei, F., Huang, Z., Li, D., Yang, N., and Zhou, M. Attention-guided answer distillation for machine reading comprehension. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, Brussels, Belgium, October 31 - November 4, 2018, pp. 2077–2086, 2018. URL https://www.aclweb.org/anthology/D18-1232/.

[63] Turc, I., Chang, M., Lee, K., and Toutanova, K. Well-read students learn better: The impact of student initialization on knowledge distillation. CoRR, abs/1908.08962, 2019a. URL http://arxiv.org/abs/1908.08962.

[64] Szegedy, C., Vanhoucke, V., Ioffe, S., Shlens, J., and Wojna, Z. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2818–2826, 2016. doi:10.1109/cvpr.2016.308.