Adaptive Sparse Softmax: An Effective and Efficient Softmax Variant

Qi Lv, Lei Geng, Ziqiang Cao, Min Cao, Sujian Li, Wenjie Li, Guohong FuIEEE Transactions on Audio, Speech and Language Processing 2025 · DOI

Abstract

Softmax with the cross entropy loss is the standard configuration for current neural classification models. The gold score for a target class is supposed to be 1, but it is never reachable under the softmax schema. Such a problem makes the training process continue forever and leads to overfitting. Moreover, the "target-approach-1" training goal forces the model to continuously learn all samples, leading to a waste of time in handling some samples which have already been classified correctly with high confidence, while the test goal simply requires the target class of each sample to hold the maximum score. To solve the above weaknesses, we propose the Adaptive Sparse softmax (AS-Softmax) which designs a reasonable and test-matching transformation on top of softmax. For more purposeful learning, we discard the classes with far smaller scores compared with the actual class during training. Then the model could focus on learning to distinguish the target class from its strong opponents, which is also the great challenge in test. In addition, since the training losses of easy samples will gradually drop to 0 in AS-Softmax, we develop an adaptive gradient accumulation strategy based on the masked sample ratio to speed up training. We verify the proposed AS-Softmax on a variety of text multi-class, text multi-label, text token classification, image classification and audio classification tasks with class sizes ranging from 5 to 5000+. The results show that AS-Softmax consistently outperforms softmax and its variants, and the loss of AS-Softmax is remarkably correlated with classification performance in validation. Furthermore, adaptive gradient accumulation strategy can bring about 1.2x training speedup comparing with the standard softmax while maintaining classification effectiveness.

Introduction

In modern machine learning, the combination of Softmax and Cross-Entropy loss is the "gold standard" for classification. However, it has a fundamental flaw: the "target-approach-1" problem. Because a softmax probability of exactly 1.0 is mathematically unreachable, the model never stops trying to push the target class score higher, even after the sample is correctly classified with high confidence.

This leads to two major issues:

  1. Overfitting: The model wastes capacity trying to "perfect" easy samples, often at the expense of generalizing to new data.
  2. Objective Mismatch: In testing, we only care if the target class has the highest score. In training, softmax forces the model to care about the absolute distance between the target and every other class, even those that pose no threat to the correct prediction.

Methods: Bridging the Training-Testing Gap

The authors propose Adaptive Sparse Softmax (AS-Softmax) to bridge the gap between training and testing objectives.

The Margin Criterion

AS-Softmax introduces a hyperparameter $\delta$ (margin). During training, if the probability of the target class $p_t$ exceeds a non-target class $p_i$ by at least $\delta$, that non-target class is "masked" (ignored) for that specific sample. By discarding classes that are already significantly weaker than the target, the model focuses its gradients on distinguishing the target from its "strong opponents"—the classes most likely to cause a misclassification.

AS-Speed (Adaptive Gradient Accumulation)

As training progresses, more samples become "easy" and their loss drops to zero. To avoid wasting GPU resources on these masked samples, the authors developed a strategy that dynamically increases the number of gradient accumulation steps based on the ratio of masked samples. This ensures the "effective" batch size remains consistent while skipping unnecessary computations.

The proportion of masked samples increases as training progresses, enabling adaptive speedup.

Experimental Evaluation

The authors evaluated AS-Softmax across a massive range of tasks and modalities, including text multi-class (SST5), token classification (Conll2003), image classification (WikiArt), and audio classification (Chest_falsetto).

Key Results

  • Superior Accuracy: AS-Softmax consistently outperformed standard softmax and other variants (like Sparse-Softmax and AM-Softmax) across almost all datasets. For example, it gained ~2 points in F1 score on the SIGHAN2015 task.
  • Efficiency Gains: The AS-Speed algorithm achieved a 1.2x training speedup on average while maintaining or even slightly improving accuracy.
  • Cross-Modal Success: The benefits weren't limited to text; the researchers saw a 4.5% improvement in image classification and an 8.6% improvement in audio classification compared to standard softmax.
Comparison of Accuracy and Loss trajectories across softmax variants.

Analysis and Insights

One of the most striking findings is the Loss-Accuracy Correlation. Standard softmax loss often correlates poorly with validation accuracy (sometimes near zero). As shown in the training trajectories, while standard softmax loss may fluctuate or even increase as the model overfits, AS-Softmax loss shows a much stronger negative correlation with accuracy. This means the loss value in AS-Softmax is a more reliable indicator of actual model performance.

Furthermore, the "Strong Opponent" philosophy allows the model to ignore noise from thousands of irrelevant classes. This makes AS-Softmax more robust to imbalanced datasets, as it prevents majority classes from over-dominating gradient updates once they have reached a sufficient margin of confidence.

Conclusion

Adaptive Sparse Softmax provides a more purposeful learning objective by aligning training more closely with the requirements of testing. By focusing on strong opponents and adaptively accumulating gradients, it offers a rare combination of improved accuracy and increased training efficiency. Future work may explore adaptive margin selection to remove the need for manual hyperparameter tuning.

Summary updated

BibTeX
@article{lv2025adaptive,
  author = {Qi Lv and Lei Geng and Ziqiang Cao and Min Cao and Sujian Li and Wenjie Li and Guohong Fu},
  title = {{Adaptive Sparse Softmax: An Effective and Efficient Softmax Variant}},
  journal = {IEEE Transactions on Audio, Speech and Language Processing},
  year = {2025},
  doi = {10.1109/taslpro.2025.3587436},
}
Figure