How Large a Vocabulary Does Text Classification Need? A Variational Approach to Vocabulary Selection

Wenhu Chen, Yu Su, Yilin Shen, Zhiyu Chen, Xifeng Yan, William Yang Wang

Introduction

In modern Natural Language Processing (NLP), deep learning models often allocate a disproportionate amount of memory to word embedding matrices. For many architectures, these embeddings account for nearly 97.6% of all trainable parameters. Traditionally, researchers manage this bloat using frequency-based cutoffs—keeping only the top $N$ most frequent words. However, this approach is task-agnostic; it assumes frequency equals importance. A common word like "the" may be irrelevant for sentiment analysis, while a rare technical term could be the primary indicator for a document category.

This paper introduces Variational Vocabulary Dropout (VVD), a task-aware method that uses Bayesian inference to prune unnecessary words. VVD can reduce model size by over 98% while maintaining or even improving classification accuracy by acting as a regularizer.

Methodology: Variational Vocabulary Dropout

VVD shifts the focus from simple frequency counts to a learned selection process. The core idea is to associate every word in the vocabulary with a learned dropout probability ($p_i$).

Variational Vocabulary Dropout (VVD) learns task-specific dropout probabilities ($p_i$) for each word, allowing the model to prune non-informative terms like 'What' or 'New' while retaining critical ones like 'Genre'.

The method employs several key techniques:

  1. Gaussian Relaxation: To optimize discrete "keep or drop" decisions, the authors use the reparameterization trick, allowing the model to learn word importance through standard backpropagation.
  2. Sparsity-Inducing Prior: An "improper log-uniform prior" is applied to push the model toward the smallest possible vocabulary.
  3. Selection: After training, words with dropout rates exceeding a specific threshold are discarded, leaving a highly compressed, task-specific vocabulary.

Task-Specific Vocabulary Requirements

The authors found that the "minimum viable vocabulary" varies significantly depending on the complexity of the NLP task:

  • Natural Language Understanding (NLU): Intent classification tasks (e.g., ATIS-flight) are relatively simple, often requiring as few as 100 words for high accuracy.
  • Document Classification (DC): These tasks generally require "hundred-level" vocabularies to distinguish between broad categories like news or sports.
  • Natural Language Inference (NLI): Reasoning tasks (e.g., SNLI) are the most demanding, requiring "thousand-level" vocabularies to capture complex sentence interactions.

Evaluation and Key Results

To measure efficiency, the authors introduced two metrics: AUC (Area Under the Accuracy-Vocab Curve) and Vocab@-X% (the minimum vocabulary size needed to stay within X% of peak accuracy).

Performance curves across Document Classification and NLU tasks, alongside the definition of evaluation metrics like AUC and Vocab@-5%.

VVD consistently outperformed baselines like TF-IDF and Group Lasso across eight datasets:

  • Massive Compression: On the DBPedia dataset, VVD achieved 98.5% accuracy using only 427 words, whereas standard frequency-based methods required 1,000 words to reach a lower accuracy level.
  • Efficiency: On the Snips dataset, VVD required only 36 words to stay within 5% of its top performance, compared to 61 words for the standard approach.
  • Regularization: By forcing the model to ignore "noisy" words, VVD often improved generalization, leading to higher peak accuracy than models using the full vocabulary.

Limitations

While effective, VVD introduces some training overhead due to the stochastic nature of the dropout rates. The authors suggest a hybrid approach—using an initial frequency cutoff followed by VVD—to mitigate this. Additionally, while VVD works well for classification, generative tasks remain a challenge as they require a broader productive vocabulary. Future work will explore extending VVD from static embeddings to dynamic, contextualized models like BERT.

Summary updated

BibTeX
@inproceedings{chen2019how,
  author = {Wenhu Chen and Yu Su and Yilin Shen and Zhiyu Chen and Xifeng Yan and William Yang Wang},
  title = {{How Large a Vocabulary Does Text Classification Need? A Variational Approach to Vocabulary Selection}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/n19-1352},
}
Figure