Sparse*BERT: Sparse Models are Robust

Daniel Campos, Alexandre Marques, Tuan Nguyen, Mark Kurtz, ChengXiang Zhai

Abstract

Large Language Models have become the core architecture upon which most modern natural language processing (NLP) systems build. These models can consistently deliver impressive accuracy and robustness across tasks and domains, but their high computational overhead can make inference difficult and expensive. To make using these models less costly, recent work has explored leveraging structured and unstructured pruning, quantization, and distillation to improve inference speed and decrease size. This paper studies how models pruned using Gradual Unstructured Magnitude Pruning can transfer between domains and tasks. Our experimentation shows that models that are pruned during pretraining using general domain masked language models can transfer to novel domains and tasks without extensive hyperparameter exploration or specialized approaches. We demonstrate that our general sparse model Sparse*BERT can become SparseBioBERT simply by pretraining the compressed architecture on unstructured biomedical text. Moreover, we show that SparseBioBERT can match the quality of BioBERT with only 10% of the parameters.

Introduction

Large Language Models (LLMs) like BERT are the backbone of modern AI, but their massive size makes them slow and expensive to run. While researchers have found ways to "prune" (remove) unnecessary connections in these models to make them smaller, a critical question remained: Does a pruned model lose its ability to learn new things? Specifically, if you prune a model using general text (like Wikipedia), can it still be adapted to a highly specialized domain like medicine or law?

SparseBERT proves that heavily compressed language models are surprisingly "portable" across different fields. By using Gradual Unstructured Magnitude Pruning, the researchers created SparseBioBERT*, a model with 90% of its parameters removed that still matches the performance of the full-sized BioBERT on specialized medical tasks.

Methodology

The authors utilized Gradual Unstructured Magnitude Pruning (GMP). Instead of cutting 90% of the weights instantly—which causes the model to "collapse"—they slowly removed the smallest weights over thousands of training steps, allowing the remaining connections to adapt.

Key technical choices included:

  • Knowledge Distillation (KD): A full-sized "teacher" model guided the sparse "student" model during training to retain accuracy.
  • Stage Comparison: Pruning was tested at three different stages: during general pretraining, during domain-specific pretraining (medical), and during final task fine-tuning.
  • Architecture: The focus was on BERT-base (110 million parameters), pruning the encoder layers while keeping the embedding layers intact.

Experimental Setup

The study utilized a massive amount of data for both general and specialized training:

  • Pretraining: English Wikipedia and the Book Corpus (3.3 billion words) for general knowledge; the MEDLINE/PubMed corpus (4.5 billion words) for medical knowledge.
  • Evaluation: 10 established Biomedical NLP benchmarks covering Entity Recognition (e.g., BC5CDR, NCBI Disease), Relation Extraction (ChemProt, DDI), and Question Answering (PubMedQA, BioASQ).
  • General Baseline: The SQuAD dataset was used to measure general-purpose question-answering performance.

Results and Discussion

The experimental results demonstrate that SparseBioBERT (90% sparse) achieves an overall score of 80.42, which is nearly identical to the dense BioBERT score of 80.62. This indicates that the "essential" structure of language is remarkably universal across domains; the specific connections the model chooses to keep while reading Wikipedia are effective for reading medical journals.

Task metric comparison across different pruning strategies and task categories.

A critical finding is the "Prune Early" Rule: pruning during the initial general pretraining phase is far more effective than trying to prune during the final fine-tuning stage. Once a model is sparse, it can be "re-trained" on new domains almost as easily as a full-sized model. As shown in the performance breakdown below, models pruned during pretraining consistently outperform those pruned during the fine-tuning stage.

Performance metrics for BERT and BioBERT across different pruning stages.

Key Insights

  • Sparsity as a Regularizer: On very small datasets like PubMedQA, sparse models actually outperformed dense ones. Having fewer parameters likely prevents overfitting, forcing the model to generalize better.
  • Relation Extraction Gains: In Relation Extraction (RE), the sparse model (88.57) slightly outperformed the dense BioBERT (87.56).
  • Efficiency: 90% sparse models typically run inference approximately 4.5x faster and are significantly smaller in storage size than their dense counterparts.
  • Transferability: Pruning on general domain data and then transferring to medical data resulted in a ~4-point lead in Entity Extraction compared to models pruned directly on medical data.

Conclusion

SparseBERT demonstrates that high levels of sparsity do not preclude domain adaptation. While the initial process of pruning and distillation requires significant compute time, the resulting models offer substantial inference speedups without sacrificing accuracy. Future work will explore expanding SparseBERT to legal and financial domains and investigating structured pruning approaches.

Summary updated

BibTeX
@misc{campos2022sparse,
  author = {Daniel Campos and Alexandre Marques and Tuan Nguyen and Mark Kurtz and ChengXiang Zhai},
  title = {{Sparse*BERT: Sparse Models are Robust}},
  year = {2022},
  eprint = {2205.12452},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.12452},
}
Figure