Adaptive Sampled Softmax with Inverted Multi-Index: Methods, Theory and Applications

Jin Chen, Jin Zhang, Xu huang, Yi Yang, Defu Lian +1 more
1/15/2025
cs.LG

No official code found. Best implementation: XuHwang/MIDX_Journal (1 star, MIT, last commit 2024-09-02).

Abstract

The softmax function is a cornerstone of multi-class classification, integral to a wide range of machine learning applications, from large-scale retrieval and ranking models to advanced large language models. However, its computational cost grows linearly with the number of classes, which becomes prohibitively expensive in scenarios with millions or even billions of classes. The sampled softmax, which relies on self-normalized importance sampling, has emerged as a powerful alternative, significantly reducing computational complexity. Yet, its estimator remains unbiased only when the sampling distribution matches the true softmax distribution. To improve both approximation accuracy and sampling efficiency, we propose the MIDX Sampler, a novel adaptive sampling strategy based on an inverted multi-index approach. Concretely, we decompose the softmax probability into several multinomial probabilities, each associated with a specific set of codewords and the last associated with the residual score of queries, thus reducing time complexity to the number of codewords instead of the number of classes. To further boost efficiency, we replace the query-specific residual probability with a simple uniform distribution, simplifying the computation while retaining high performance. Our method is backed by rigorous theoretical analysis, addressing key concerns such as sampling bias, gradient bias, convergence rates, and generalization error bounds. The results demonstrate that a smaller divergence from the ideal softmax distribution leads to faster convergence and improved generalization. Extensive experiments on large-scale language models, sequential recommenders, and extreme multi-class classification tasks confirm that the MIDX-Sampler delivers superior effectiveness and efficiency compared to existing approaches.

View on arXivView PDF

Code Implementations(1)

MIT

This is a repo for MIDX sampler applied in other domains like NLP, Knowledge Graph, Sequential Recommendation and Extreme Classification.

11PythonSep 13, 20222 years agoMIT

Similar Papers

Cite this paper

@article{chen2025adaptive,
  title  = {Adaptive Sampled Softmax with Inverted Multi-Index: Methods, Theory and Applications},
  author = {Jin Chen and Jin Zhang and Xu huang and Yi Yang and Defu Lian and Enhong Chen},
  year   = {2025},
  eprint = {2501.08563},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2501.08563v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2501.08563.svg)](https://codeofpaper.com/paper/2501.08563)

Discussion