Differentiable Top-k with Optimal Transport
Yujia Xie, Hanjun Dai, Minshuo Chen, Bo Dai, Tuo Zhao, Hongyuan Zha, Wei Wei, Tomas Pfister
Abstract
The top-k operation, i.e., finding the k largest or smallest elements from a collection of scores, is an important model component, which is widely used in information retrieval, machine learning, and data mining. However, if the top-k operation is implemented in an algorithmic way, e.g., using bubble algorithm, the resulting model cannot be trained in an end-to-end way using prevalent gradient descent algorithms. This is because these implementations typically involve swapping indices, whose gradient cannot be computed. Moreover, the corresponding mapping from the input scores to the indicator vector of whether this element belongs to the top-k set is essentially discontinuous. To address the issue, we propose a smoothed approximation, namely the SOFT (Scalable Optimal transport-based diFferenTiable) top-k operator. Specifically, our SOFT top-k operator approximates the output of the top-k operation as the solution of an Entropic Optimal Transport (EOT) problem. The gradient of the SOFT operator can then be efficiently approximated based on the optimality conditions of EOT problem. We apply the proposed operator to the k-nearest neighbors and beam search algorithms, and demonstrate improved performance.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers36
- DSelect-k: Differentiable Selection in the Mixture of Experts with Applications to Multi-Task LearningHussein Hazimeh, Zhe Zhao, Aakanksha Chowdhery, Maheswaran Sathiamoorthy et al.NeurIPS 2021 · 216 citations
- Decision-Focused Learning without Decision-Making: Learning Locally Optimized Decision LossesSanket Shah, Kai Wang, Bryan Wilder, Andrew Perrault et al.NeurIPS 2022 · 79 citations
- Differentiable Top-k Classification LearningFelix Petersen, Hilde Kuehne, Christian Borgelt, Oliver DeussenICML 2022 · 48 citations
- Differentiable Sorting Networks for Scalable Sorting and Ranking SupervisionFelix Petersen, Christian Borgelt, Hilde Kuehne, Oliver DeussenICML 2021 · 39 citations
- Fast, Differentiable and Sparse Top-k: a Convex Analysis PerspectiveMichael Eli Sander, Joan Puigcerver, Josip Djolonga, Gabriel Peyré et al.ICML 2023 · 35 citations
Related papers
- ST: A Scalable Module for Solving Top-k ProblemsHanchen Xia, Weidong Liu, Xiaojun MaoNeurIPS 2024 · 1 citation
- LapSum - One Method to Differentiate Them All: Ranking, Sorting and Top-k SelectionLukasz Struski, Michal B. Bednarczyk, Igor T. Podolak, Jacek TaborICML 2025
- Listwise Learning to Rank Based on Approximate Rank IndicatorsThibaut Thonet, Yagmur Gizem Cinar, Éric Gaussier, Minghan Li et al.AAAI 2022 · 12 citations
- Entropic Neural Optimal Transport via Diffusion ProcessesNikita Gushchin, Alexander Kolesov, Alexander Korotin, Dmitry P. Vetrov et al.NeurIPS 2023 · 59 citations
- Progressive Entropic Optimal Transport SolversParnian Kassraie, Aram-Alexandre Pooladian, Michal Klein, James Thornton et al.NeurIPS 2024 · 14 citations
