Efficient Contextualized Representation: Language Model Pruning for Sequence Labeling

Liyuan Liu, Xiang Ren, Jingbo Shang, Xiaotao Gu, Jian Peng, Jiawei Han

Abstract

Pre-trained language models (LMs) have significantly advanced natural language processing by providing rich contextualized representations. However, their large computational footprint poses challenges for real-time inference. This paper introduces LD-Net, a novel framework designed to compress bulky pre-trained LMs for specific sequence labeling tasks without the need for resource-intensive retraining. LD-Net utilizes dense connectivity to allow for flexible layer removal and a specialized "layer selection" regularization ($R_3$) to induce binary sparsity. Experimental results on benchmarks like CoNLL03 and CoNLL00 demonstrate that LD-Net can prune over 90% of a language model's computation while maintaining state-of-the-art performance, achieving up to a 5x wall-clock speedup.

Introduction

The advent of contextualized word representations from large-scale pre-trained language models has revolutionized NLP. Despite their success, models like ELMo are often composed of deep stacks of LSTMs with thousands of hidden states, leading to substantial computational overhead. Traditional model compression techniques often require retraining the entire architecture, which is prohibitively expensive for RNN-based LMs due to the memory requirements of backpropagation through time (BPTT). Furthermore, the sequential nature of stacked RNNs prevents the simple removal of intermediate layers without disrupting information flow. LD-Net addresses these issues by providing a "plug-and-play" compression method tailored for downstream tasks such as Named Entity Recognition (NER).

The LD-Net Framework

The LD-Net framework is built upon three core innovations designed to facilitate efficient pruning:

1. Dense Connectivity

Unlike traditional stacked architectures where each layer only receives input from the immediately preceding one, LD-Net adopts a "DenseNet-style" connectivity. Each layer receives the concatenated outputs of all previous layers. This structural change ensures that any layer can be detached without breaking the overall network connectivity, transforming pruning into a selection problem.

The transition from vanilla stacked RNNs to densely-connected and eventually pruned architectures.

2. Task-Guided Layer Selection

To identify redundant layers for a specific task, LD-Net introduces a binary mask $z_i$ for each layer. The model is optimized using a novel sparsity-inducing regularization term, $R_3$. While standard $L_1$ regularization often results in many small non-zero weights that introduce noise, $R_3$ is specifically designed to push mask values toward discrete 0 (pruned) or 1 (kept) states. This binary selection preserves the integrity of the retained layers and is more suitable for hardware acceleration.

Visualization of regularization terms $R_1, R_2,$ and $R_3$, showing how $R_3$ effectively pushes values toward binary extremes.

3. Layer-wise Dropout

During the initial pre-training phase, entire layers are randomly dropped. This technique forces the model to distribute information robustly across the architecture, ensuring that the LM remains functional even after significant pruning during the task-specific adaptation phase.

Experimental Evaluation

The authors evaluated LD-Net on the CoNLL03 (NER) and CoNLL00 (chunking) benchmarks. On the CoNLL03 task, LD-Net successfully pruned over 90% of the language model's calculations. Remarkably, the $F_1$ score only saw a marginal decrease from 92.03% to 91.84%, remaining significantly higher than the 90.78% baseline achieved without a language model. In terms of hardware performance, the pruned model delivered a 5x wall-clock speedup on an Nvidia GTX 1080 GPU and reduced peak RAM consumption by 50%.

Conclusion

LD-Net demonstrates that not all layers in a deep language model are necessary for every downstream task. By combining dense connectivity with task-guided pruning, it is possible to achieve massive efficiency gains with minimal impact on accuracy. While this work focuses on RNN architectures, the underlying principles of structural flexibility and binary layer selection offer a promising path for compressing other large-scale models, including Transformers, in the future.

Summary updated

BibTeX
@inproceedings{liu2018efficient,
  author = {Liyuan Liu and Xiang Ren and Jingbo Shang and Xiaotao Gu and Jian Peng and Jiawei Han},
  title = {{Efficient Contextualized Representation: Language Model Pruning for Sequence Labeling}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2018},
  doi = {10.18653/v1/d18-1153},
}
Figure