Abstract
Softmax is the de facto standard in modern neural networks for language processing when it comes to normalizing logits. However, by producing a dense probability distribution each token in the vocabulary has a nonzero chance of being selected at each generation step, leading to a variety of reported problems in text generation. $\alpha$-entmax of Peters et al. (2019, arXiv:1905.05702) solves this problem, but is considerably slower than softmax. In this paper, we propose an alternative to $\alpha$-entmax, which keeps its virtuous characteristics, but is as fast as optimized softmax and achieves on par or better performance in machine translation task.
1. Introduction: The Density Problem
In Natural Language Processing (NLP), the softmax function is the standard choice for output layers. It transforms raw logits into a probability distribution. However, softmax suffers from a "density" problem: it assigns a non-zero probability to every token in the vocabulary, including nonsensical ones. This often leads to issues during inference, such as the model producing empty translations or getting stuck in repetitive loops.
While sparse alternatives like $\alpha$-entmax exist to mitigate these issues by naturally producing zeros for unlikely tokens, they introduce a significant computational bottleneck. $\alpha$-entmax requires sorting the entire vocabulary at every step to find a threshold $\tau$, an $O(V \log V)$ operation that is considerably slower than the $O(V)$ softmax.
2. The $\alpha$-ReLU Transformation
To address the speed degradation of entmax, we introduce $\alpha$-ReLU. This method offers the benefits of sparsity while maintaining the computational efficiency of softmax. Instead of enforcing a strict probability distribution where elements must sum exactly to 1, $\alpha$-ReLU "loosens" this constraint using a shifted ReLU function:
$$\alpha\text{-ReLU}_i(\mathbf{z}) := [(\alpha - 1)z_i - \tau]_+^{\frac{1}{\alpha-1}}$$
Unlike entmax, where $\tau$ is a complex function of all logits, in $\alpha$-ReLU, $\tau$ is a simple constant or hyperparameter. This reduces the complexity to $O(V)$. To ensure the model remains effective, we pair this transformation with a custom loss function based on Tsallis $\alpha$-entropy. This encourages the model to "self-normalize," learning to produce sums close to 1 without architectural enforcement.
3. Experimental Evaluation
We evaluated $\alpha$-ReLU on three standard Neural Machine Translation (NMT) benchmarks:
- IWSLT’14 De$→$En: 172K training examples (small scale).
- WMT’13 En$→$Ru: 1.3M training examples (medium scale).
- WMT’14 En$→$De: 4.5M training examples (large scale).
4. Key Results and Discussion
Our experiments demonstrate that $\alpha$-ReLU matches or exceeds the performance of both softmax and $\alpha$-entmax while being significantly faster.
- Translation Quality: On IWSLT De$→$En, $\alpha$-ReLU achieved 37.3 BLEU, outperforming softmax (35.3) and 1.5-entmax (36.6).
- Efficiency: $\alpha$-ReLU is approximately 2x faster than $\alpha$-entmax during inference and matches the speed of highly optimized softmax CUDA kernels.
- Generation Robustness: Similar to entmax, $\alpha$-ReLU effectively solves the "empty string" problem, assigning much lower probabilities to null translations than standard softmax.
Interestingly, $\alpha$-ReLU is less sparse than $\alpha$-entmax, yet it performs better. This suggests that while some sparsity is essential to avoid generation errors, extreme sparsity is not a requirement for high-quality translation.
5. Conclusion
$\alpha$-ReLU provides a practical, fast, and sparse alternative to softmax for the output layers of neural networks. By replacing expensive sorting with a self-normalizing ReLU-based approach, we achieve state-of-the-art results without the computational tax of previous sparse methods. Future work will explore the application of $\alpha$-ReLU in attention layers, where its sparsity could offer further architectural benefits.
Summary updated