[Paper Review] Learning to Screen for Fast Softmax Inference on Large Vocabulary Neural Networks
This paper proposes L2S (Learning to Screen), a method to accelerate softmax inference in large-vocabulary neural language models by training a lightweight screening model to predict a small subset of likely top-k words using clustering of context vectors. By applying the Gumbel softmax trick for end-to-end differentiable training, L2S achieves up to 20.4x speedup with near-identical accuracy (98.9% precision@1) compared to exact softmax, significantly outperforming prior methods like FGD and Zhang et al. (2018).
Neural language models have been widely used in various NLP tasks, including machine translation, next word prediction and conversational agents. However, it is challenging to deploy these models on mobile devices due to their slow prediction speed, where the bottleneck is to compute top candidates in the softmax layer. In this paper, we introduce a novel softmax layer approximation algorithm by exploiting the clustering structure of context vectors. Our algorithm uses a light-weight screening model to predict a much smaller set of candidate words based on the given context, and then conducts an exact softmax only within that subset. Training such a procedure end-to-end is challenging as traditional clustering methods are discrete and non-differentiable, and thus unable to be used with back-propagation in the training process. Using the Gumbel softmax, we are able to train the screening model end-to-end on the training set to exploit data distribution. The algorithm achieves an order of magnitude faster inference than the original softmax layer for predicting top-$k$ words in various tasks such as beam search in machine translation or next words prediction. For example, for machine translation task on German to English dataset with around 25K vocabulary, we can achieve 20.4 times speed up with 98.9\% precision@1 and 99.3\% precision@5 with the original softmax layer prediction, while state-of-the-art ~\citep{MSRprediction} only achieves 6.7x speedup with 98.7\% precision@1 and 98.1\% precision@5 for the same task.
Motivation & Objective
- To address the computational bottleneck of softmax inference in large-vocabulary neural language models, especially on mobile devices.
- To reduce inference time for top-k word prediction without sacrificing prediction accuracy.
- To exploit the clustering structure of context vectors and word embeddings to narrow down candidate search space.
- To develop an end-to-end trainable screening model that jointly optimizes cluster assignment and candidate set selection.
- To outperform existing MIPS-based and approximation-based methods in speed-accuracy tradeoff for NLP tasks like machine translation and next-word prediction.
Proposed method
- Propose a two-stage inference pipeline: first, a light-weight screening model predicts a small cluster of candidate words based on the context vector; second, exact softmax is computed only within that subset.
- Use a differentiable clustering mechanism via the Gumbel-Softmax trick to enable end-to-end backpropagation through discrete cluster assignments.
- Formulate a joint optimization objective that learns both the screening model and the candidate word sets per cluster simultaneously.
- Train the screening model on the full training distribution to exploit data-driven clustering patterns in context vectors.
- Integrate the screening model into beam search and next-word prediction pipelines, reducing softmax computation to only the candidate subset.
- Set a time budget constraint in the loss function to balance speed and accuracy, enabling tunable trade-offs in practice.
Experimental results
Research questions
- RQ1Can a learnable screening model that exploits clustering in context vectors significantly reduce softmax inference time in large-vocabulary language models?
- RQ2How can discrete clustering assignments be made differentiable for end-to-end training in a neural network?
- RQ3What is the trade-off between inference speedup and prediction accuracy when using learned screening over traditional MIPS algorithms?
- RQ4Can the proposed method maintain high precision@k (e.g., 98% or higher) while achieving an order-of-magnitude speedup in real NLP tasks?
- RQ5How robust is the method to variations in the number of clusters and time budget constraints?
Key findings
- L2S achieves 20.4x speedup on the German-to-English translation task with 98.9% precision@1 and 99.3% precision@5, outperforming Zhang et al. (2018) which achieved only 6.7x speedup with 98.7% precision@1.
- On the EN-VE translation task, L2S achieves 20x speedup with only 0.08 BLEU score drop when using beam size 5, while FGD achieves less than 6x speedup with similar accuracy.
- For the PTB-Small and PTB-Large language modeling tasks, L2S achieves over 5x speedup with less than 5% increase in perplexity compared to full softmax.
- The method is robust to the number of clusters: with 100–200 clusters, it maintains high precision (P@1 > 0.99) and low inference time (0.14–0.17ms).
- In beam search, L2S maintains near-identical BLEU scores (e.g., 30.19 vs. 30.33) while reducing inference time by up to 13.4x (beam size 5) on DE-EN.
- The joint optimization with Gumbel-Softmax enables effective end-to-end training, allowing the model to learn data-driven clustering patterns that improve both speed and accuracy.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.