基于倒排多索引的自适应采样Softmax:方法、理论与应用
Adaptive Sampled Softmax with Inverted Multi-Index: Methods, Theory and Applications
AI总结:
针对softmax在超大类别场景下计算成本过高的问题,提出基于倒排多索引的MIDX采样器,通过分解softmax概率降低复杂度,经理论验证与多任务实验,在效果和效率上均优于现有方法。
摘要:
Softmax函数是多分类任务的基石,广泛应用于从大规模检索与排序模型到先进大语言模型的各类机器学习场景中。但其计算成本随类别数量线性增长,在类别数达百万甚至十亿级的场景下,计算开销会高到难以承受。依赖自归一化重要性采样的采样softmax已成为一种高效替代方案,可显著降低计算复杂度,但其估计量仅在采样分布与真实softmax分布匹配时才保持无偏。\n为同时提升近似精度与采样效率,我们提出MIDX Sampler(MIDX采样器)——一种基于倒排多索引方法的新型自适应采样策略。具体而言,我们将softmax概率分解为多个多项分布概率,每个多项分布对应一组特定的码字,最后一个多项分布对应查询的残差得分,从而将时间复杂度降低至与码字数量相关,而非与类别数量相关。为进一步提升效率,我们用简单的均匀分布替换了与查询相关的残差概率,在简化计算的同时保持了高性能。\n我们的方法得到了严谨的理论分析支撑,解决了采样偏差、梯度偏差、收敛速率以及泛化误差界等关键问题。理论结果表明,与理想softmax分布的散度越小,收敛速度越快,泛化性能越好。在大语言模型、序列推荐器以及极端多分类任务上开展的大量实验证实,与现有方法相比,MIDX-Sampler具备更优的效果与效率。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。