Abstract
DS-Softmax (Doubly Sparse Softmax) is a learning-based method that slashes the computational cost of softmax inference by up to 23x in language modeling and 15x in translation without sacrificing accuracy. It achieves this through a two-level hierarchy: a sparse mixture that selects a single "expert" for a given input, and sparse experts that only search through a small, relevant subset of the total output classes.
The Softmax Bottleneck
In deep learning, the softmax function is the standard way to turn model outputs into a probability distribution over classes. However, softmax has a major scaling problem: its computational complexity is linear ($O(N)$) with respect to the number of output classes.
For tasks like language modeling or machine translation, where vocabularies can exceed 100,000 words, the softmax layer often accounts for over 95% of the total computation. This creates a massive bottleneck, especially when deploying models to resource-constrained environments like mobile devices. While existing "post-approximation" methods (like Locality Sensitive Hashing or SVD-Softmax) try to speed up a fixed pre-trained model, they often face a steep trade-off between speed and accuracy because the original model wasn't structured for efficient searching.
Methodology: Doubly Sparse Softmax
The authors introduce DS-Softmax, which moves away from approximating a fixed model and instead learns a structured, efficient softmax during training. The architecture relies on two layers of sparsity:
- Sparse Mixture (Level 1): A gating network looks at the input vector and selects exactly one "expert" out of $K$ possible experts. This is a "top-1" selection, meaning the model doesn't waste time averaging multiple experts.
- Sparse Experts (Level 2): Unlike standard Mixture of Experts (MoE) where every expert covers the entire vocabulary, DS-Softmax experts are pruned. Using Group Lasso regularization during training, each expert is forced to become "sparse," meaning it only contains a small subset of the total classes.
Mitosis Training
To make this work, the authors also introduced two critical training techniques. Training a 64-expert model from scratch is memory-intensive. "Mitosis" starts with just 2 experts and progressively "splits" them into more (4, 8, 16...) as training progresses. This keeps the memory footprint manageable while allowing experts to specialize over time.
Additionally, a Loading Balance Loss regularization term ensures no single expert gets "overloaded" while others sit idle, maximizing the efficiency of the hierarchy.
Evaluation and Results
The researchers evaluated DS-Softmax across a variety of domains, including synthetic data, Penn Treebank (PTB), WikiText-2, IWSLT English-to-Vietnamese translation, and CASIA Chinese handwriting recognition. The results demonstrate that DS-Softmax significantly outperforms existing baselines like D-Softmax and SVD-Softmax in terms of the speed-to-accuracy ratio:
- Language Modeling (WikiText-2): Achieved a 23.86x FLOPs speedup with a slight improvement in accuracy over the full softmax baseline. When combined with SVD-Softmax, the speedup reached 32.77x.
- Translation (En-Ve): Achieved a 15.08x speedup with virtually no loss in BLEU score.
- Handwriting Recognition (CASIA): Even on a task with a more uniform class distribution (where hierarchical methods usually struggle), it achieved a 6.91x speedup.
- Real-world Latency: On a standard CPU, the method reduced latency on the Wiki-2 task from 3.07ms to just 0.15ms per inference.
Key Insights and Discussion
- Learning vs. Approximating: The core innovation is teaching a model to be efficient during training rather than trying to "fix" a dense model post-hoc. By adapting weights to a hierarchical structure, the model finds a superior efficiency-accuracy frontier.
- Overlapping Hierarchies: Unlike rigid tree structures where a word belongs to exactly one cluster, DS-Softmax allows classes to belong to multiple experts. This naturally handles homonyms (e.g., "bank" as a financial institution vs. a river bank), as the gating network can route the input based on context.
- Orthogonality: DS-Softmax can be combined with other speedup methods (like SVD-Softmax) applied to the individual experts for even greater gains.
While the paper presents a robust solution for inference, training complexity remains higher than standard softmax due to the multi-stage pipeline (pre-training, mitosis, pruning). Future work may explore deeper multi-level structures for vocabularies in the millions and further hardware-specific optimizations for GPUs and TPUs.
Summary updated