NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Bayesian Compression for Natural Language Processing

Nadezhda Chirkova, Ekaterina Lobacheva, Dmitry P. Vetrov

Abstract

Recurrent Neural Networks (RNNs) are essential for natural language processing but often suffer from excessive parameter counts, particularly in the embedding layer. This paper introduces a principled Bayesian approach to sparsify RNNs by adapting Sparse Variational Dropout (SparseVD) and introducing a novel vocabulary sparsification layer. The proposed method achieves extreme compression—up to 12,985x on sentiment analysis tasks—while maintaining competitive performance and enhancing model interpretability.

Introduction

Recurrent Neural Networks (RNNs) are the workhorses of NLP, but they are notoriously "heavy." A significant portion of their parameters resides in the embedding layer, which scales linearly with vocabulary size. For instance, a model with a 20,000-word vocabulary and 300-dimensional embeddings requires 6 million parameters before accounting for recurrent logic. Existing pruning methods often rely on manual heuristics and tedious trial-and-error. This research seeks an automated, principled way to sparsify both internal weights and the vocabulary itself, enabling deployment on resource-constrained portable devices.

Methodology

The authors build upon Sparse Variational Dropout (SparseVD), a Bayesian technique where weights are treated as random variables. During training, the model learns which weights are "noisy" and can be safely zeroed out.

Adapting SparseVD for RNNs

In standard feed-forward networks, the "Local Reparameterization Trick" (LRT) is used to accelerate training. However, RNNs reuse weights across timesteps. The authors demonstrate that LRT is theoretically incompatible with weight-sharing in hidden-to-hidden layers. To address this, they propose sampling noise once per mini-batch, ensuring stability and trainability.

Vocabulary Sparsification

The paper introduces multiplicative weights ($z$) for every word in the vocabulary. If the Bayesian training determines a word's weight $z$ is zero, that word is effectively removed. This allows the network to automatically filter the vocabulary, retaining only the most informative tokens for a specific task.

Experimental Setup

The approach was evaluated on two primary NLP tasks:

  • Text Classification: Using the IMDb (sentiment analysis) and AGNews (topic classification) datasets.
  • Language Modeling: Using the Penn Treebank (PTB) dataset at both character and word levels.

Results and Discussion

The Bayesian approach demonstrated remarkable efficiency across tasks, often acting as a regularizer that improved performance over uncompressed baselines.

Extreme Compression in Classification

On the IMDb dataset, the SparseVD-Voc model achieved a staggering 12,985x compression rate. It reduced the vocabulary from 20,000 words to just 292, and recurrent neurons from 128 to 8, with only a marginal 0.5% drop in accuracy compared to the SparseVD baseline.

Table 1: Performance and compression results for text classification tasks on IMDb and AGNews datasets.

Interpretability and Task Sensitivity

The words retained by the model were highly relevant to the task. In sentiment analysis, the "surviving" words were those with strong emotional valences (e.g., "beautifully," "greatest," "worst," "pathetic").

Figure 1: Visualization of learned embeddings and sentiment scores, showing how the model retains words with high emotional impact.

However, vocabulary sparsification proved to be a "double-edged sword." While effective for classification, it struggled with language modeling on the word-level PTB dataset. In generative tasks, even rare words provide essential context, making them harder to prune without significant quality loss.

Conclusion

This work demonstrates that Bayesian sparsification can drastically reduce the footprint of RNNs. By automatically filtering noise and redundant vocabulary, the method enables high-performance NLP on low-power devices. Future research will explore group sparsity techniques to further refine pruning for complex generative tasks where sequence context is paramount.

Summary updated

BibTeX
@inproceedings{chirkova2018bayesian,
  author = {Nadezhda Chirkova and Ekaterina Lobacheva and Dmitry P. Vetrov},
  title = {{Bayesian Compression for Natural Language Processing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2018},
  doi = {10.18653/v1/d18-1319},
}
Figure