Preprint
Large Language Models

Distil BERT

October 1, 2019

0

Citations

0

Influential Citations

Venue

2019

Year

Abstract

Distills BERT on very large batches leveraging gradient accumulation, using dynamic masking and without the next sentence prediction objective.

Analysis

Why This Paper Matters

DistilBERT addresses a critical bottleneck in deploying large language models: computational cost. BERT, with its 110 million parameters, is prohibitively expensive for many real-world applications, especially on edge devices or in latency-sensitive systems. By distilling BERT into a model that is 40% smaller and 60% faster while retaining 97% of its performance, DistilBERT makes state-of-the-art NLP accessible to a much wider audience. This paper is a landmark in model compression, demonstrating that knowledge distillation can be effectively applied to transformer architectures without significant loss in accuracy.

The paper also introduces practical training techniques—large-batch gradient accumulation and dynamic masking—that stabilize the distillation process and improve generalization. These innovations are not only useful for distillation but can be applied to other large-scale training scenarios. DistilBERT's success has spurred a wave of research into efficient transformers, including TinyBERT, MobileBERT, and ALBERT, cementing its influence on the field.

Technical Contributions

  • Knowledge Distillation with Triple Loss: Combines distillation loss (soft targets from teacher), masked language modeling loss (hard targets), and cosine embedding loss (aligning hidden states). This multi-objective approach ensures the student captures both output probabilities and internal representations.
  • Large-Batch Training via Gradient Accumulation: Uses batches of up to 4,000 sequences by accumulating gradients over multiple steps, enabling stable training without memory overflow.
  • Dynamic Masking: Applies different random masks each epoch, preventing overfitting to specific mask patterns and improving generalization.
  • Removal of Next Sentence Prediction (NSP): Simplifies the pre-training objective, reducing computational overhead without harming downstream performance on tasks like GLUE.
  • Architecture Reduction: Halves the number of layers (from 12 to 6) while keeping hidden size and attention heads, achieving a compact model that retains most of BERT's capacity.

Results

DistilBERT achieves a GLUE score of 77.0 (average across tasks) compared to BERT-base's 79.5, retaining 97% of performance. On individual tasks like MNLI (84.9 vs 86.7), QQP (89.2 vs 91.3), and SST-2 (91.3 vs 93.5), the drops are minimal. Inference speed is 60% faster on CPU and 40% faster on GPU, with a 40% reduction in model size (66 million parameters vs 110 million). The paper also shows that DistilBERT outperforms other compressed models like BERT-PKD and BERT-6L on several GLUE tasks.

Significance

DistilBERT democratizes access to BERT-level NLP by making it feasible to run on mobile devices, web servers, and low-resource environments. It establishes knowledge distillation as a standard technique for transformer compression, influencing subsequent models like TinyBERT, MobileBERT, and DistilGPT2. The paper's practical insights—such as dynamic masking and gradient accumulation—have been widely adopted in the training of efficient transformers. DistilBERT remains a popular choice for production systems where latency and memory are critical, and its methodology continues to inspire research into model compression, quantization, and pruning.