
AraBERT
Language302 ops109.5M params
A 12-layer, 384-wide BERT-style encoder distilled by mimicking its teacher's last-layer self-attention.
Language · 302 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
How this diagram was made
transformers.AutoModel.from_config()
MiniLM is a distilled model: a compact Transformer encoder trained to mimic a large pre-trained language model. The checkpoint traced here is the uncased 12-layer model with a 384-dimensional hidden size, distilled from an in-house pre-trained UniLM v2 model in BERT-Base size. The card is blunt about how to use it: the checkpoint can be an in-place substitution for BERT, and it needs to be fine-tuned before use.
The paper's problem is practical: pre-trained models such as BERT usually consist of hundreds of millions of parameters, which brings challenges for fine-tuning and online serving due to latency and capacity constraints. Its answer is deep self-attention distillation, in which the small student is trained by deeply mimicking the self-attention module of the large teacher. Rather than matching the teacher layer by layer, the student mimics only the attention of the teacher's last Transformer layer, which leaves the student free to have a different number of layers. Alongside the usual attention distributions, the student also matches the scaled dot-product between values, which the paper calls the value relation. Because the scaled dot-product turns vectors of any hidden width into relation matrices of the same size, the student can use a more flexible hidden dimension without extra parameters to transform its representations.
For students much smaller than the teacher, the authors add a teacher assistant, an intermediate-size student model that is distilled first and then teaches the final student. In the in-house setup behind this checkpoint, the 12x384 model is used as the teacher assistant to train the 6x384 model. On the dev sets the card reports, MiniLM-L12xH384 reaches 81.7 on SQuAD 2.0 and 85.7 on MNLI-m with 33M parameters. The paper's own verdict on the 12x384 model is that it achieves a 2.7x speedup while performing competitively better than BERT-Base on SQuAD 2.0 and GLUE. What the graph shows is the student itself: MiniLMv1-L12-H384-uncased, a 12-layer, 384-hidden, 12-head encoder with 33M parameters that runs 2.7x faster than BERT-Base.
Key idea. Deep self-attention distillation: the student is trained by mimicking only the self-attention module of the teacher's last Transformer layer, which is effective and flexible for the student. In addition to attention distributions, it transfers the scaled dot-product between values as a new kind of self-attention knowledge.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{wang2020minilmdeepselfattentiondistillation,
title={MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers},
author={Wenhui Wang and Furu Wei and Li Dong and Hangbo Bao and Nan Yang and Ming Zhou},
year={2020},
eprint={2002.10957},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2002.10957},
}