Learning to Screen for Fast Softmax Inference on Large Vocabulary Neural Networks

Patrick H. Chen, Si Si, Sanjiv Kumar, Yang Li, Cho-Jui Hsieh

TL;DR

Researchers from UCLA and Google Research have developed "Learning to Screen" (L2S), a novel algorithm that speeds up neural network inference by up to 45x. By using a differentiable screening model to predict a tiny subset of likely candidate words before performing a full softmax, L2S removes the computational bottleneck of large vocabularies without sacrificing accuracy.

What Problem Does This Paper Address?

In modern Natural Language Processing (NLP), models like LSTMs or Transformers often end with a softmax layer. This layer’s job is to take a "context vector" (the model's internal summary of the sentence so far) and calculate the probability of every single word in the dictionary being the next word.

The problem is scale. If your vocabulary has 50,000 words, the model must perform 50,000 vector multiplications for every single token it generates. This is a massive computational bottleneck, especially for mobile devices or real-time translation apps. While techniques like "Maximum Inner Product Search" (MIPS) exist to find the top candidates faster, they often struggle to maintain high precision (above 98%) while providing significant speedups.

Methods

The authors introduce L2S (Learning to Screen). Instead of looking at all words, the model first "screens" the vocabulary to find a small, relevant subset.

L2S Architecture
  1. Context Clustering: The algorithm exploits the fact that certain contexts naturally limit the possible next words. It partitions context vectors into $r$ clusters.
  2. The Screening Model: A light-weight model predicts which cluster the current context belongs to. Each cluster is associated with a pre-learned "candidate set" of words.
  3. End-to-End Training: This is the "secret sauce." Normally, assigning a context to a discrete cluster is a non-differentiable operation, meaning you can't use standard back-propagation to train it. The authors use the Gumbel-softmax trick to create a continuous, differentiable approximation of this discrete choice, allowing the screening model and the candidate sets to be optimized simultaneously.
  4. Optimization: They treat the selection of candidate sets as a version of the "Knapsack Problem," using a greedy approach to maximize prediction accuracy within a fixed "time budget" (the maximum number of words allowed in a subset).

Datasets

The authors evaluated L2S across several standard NLP benchmarks:

  • Language Modeling: Penn Treebank (PTB-Small and PTB-Large) and the massive WikiText-103 (80k vocabulary).
  • Neural Machine Translation (NMT): IWSLT 2014 German-to-English (DE-EN) and IWSLT 2015 English-Vietnamese (EN-VE).

Key Insights and Ideas

  • Context is King: Previous methods mostly focused on organizing the word embeddings (the database). L2S focuses on the context vectors (the queries). By learning the structure of how we speak/write, the model realizes that if the context is about "finance," it doesn't even need to consider words about "marine biology."
  • Differentiability Matters: By making the screening process differentiable via the Gumbel-softmax trick, the model doesn't just cluster contexts based on geometric similarity; it clusters them based on what leads to the most accurate final predictions.
  • The "Knapsack" Efficiency: By framing subset selection as a constrained optimization problem, they can strictly control the trade-off between inference speed (subset size) and precision.

Key Results

L2S achieves an order-of-magnitude improvement over both the original softmax and existing state-of-the-art acceleration methods:

Performance Comparison Table
  • Massive Speedups: On the PTB-Large dataset, L2S achieved a 45.3x speedup while maintaining 99.6% precision.
  • Superior Translation: For German-to-English translation, L2S was 20.4x faster than the original softmax. For comparison, the previous state-of-the-art graph-based method (FGD) only achieved a 6.7x speedup for the same task.
  • Minimal Quality Loss: In translation tasks, the BLEU score (a measure of translation quality) dropped by less than 0.1 points, a negligible difference for a 13-20x speed increase.
  • Scalability: On the 80k-word WikiText-103 dataset, the model maintained high precision even when speeding up inference by over 15x.

Limitations and Future Work

While L2S is highly effective, the paper notes a few areas for further exploration:

  • Hyperparameter Tuning: Users must still manually tune the "time budget" ($B$) and the number of clusters ($r$) to find the sweet spot for their specific hardware and accuracy requirements.
  • Static vs. Dynamic: The candidate sets for each cluster are learned during training and remain static during inference. Future work could explore more dynamic subset generation.
  • Architecture Breadth: The paper focuses heavily on LSTM-based models. While the logic should apply to Transformers (which also use a large-vocabulary softmax), explicit testing on modern large-scale Transformer architectures would be a logical next step.

Summary updated

BibTeX
@inproceedings{chen2019learning,
  author = {Patrick H. Chen and Si Si and Sanjiv Kumar and Yang Li and Cho-Jui Hsieh},
  title = {{Learning to Screen for Fast Softmax Inference on Large Vocabulary Neural Networks}},
  booktitle = {International Conference on Learning Representations},
  year = {2019},
  url = {https://openreview.net/forum?id=py8Ft4_7-m},
}
Figure