Skip to main content
QUICK REVIEW

[Paper Review] SoftSort: A Continuous Relaxation for the argsort Operator

Sebastian Prillo, Julian Martin Eisenschlos|arXiv (Cornell University)|Jun 29, 2020
Domain Adaptation and Few-Shot LearningComputer Science13 references6 citations
TL;DR

This paper introduces SoftSort, a simple and efficient continuous relaxation for the argsort operator that enables differentiable sorting in deep learning. By computing the softmax of negative L1 distances to each ranked element, SoftSort achieves state-of-the-art performance, is faster than prior methods like NeuralSort, and simplifies mathematical analysis while maintaining strong optimization properties.

ABSTRACT

While sorting is an important procedure in computer science, the argsort operator - which takes as input a vector and returns its sorting permutation - has a discrete image and thus zero gradients almost everywhere. This prohibits end-to-end, gradient-based learning of models that rely on the argsort operator. A natural way to overcome this problem is to replace the argsort operator with a continuous relaxation. Recent work has shown a number of ways to do this, but the relaxations proposed so far are computationally complex. In this work we propose a simple continuous relaxation for the argsort operator which has the following qualities: it can be implemented in three lines of code, achieves state-of-the-art performance, is easy to reason about mathematically - substantially simplifying proofs - and is faster than competing approaches. We open source the code to reproduce all of the experiments and results.

Motivation & Objective

  • To address the challenge of zero gradients in the argsort operator, which hinders end-to-end training in differentiable models.
  • To develop a continuous relaxation for argsort that is computationally efficient and easy to implement.
  • To simplify mathematical reasoning about differentiable sorting compared to prior approaches like NeuralSort.
  • To achieve performance comparable or superior to existing methods while reducing computational overhead.

Proposed method

  • SoftSort computes the soft sorting permutation as a row-wise softmax over negative L1 distances between each element and the r-th largest value in the input vector.
  • The method uses a temperature hyperparameter τ to control the sharpness of the relaxation, with convergence to the true argsort in the limit as τ → 0.
  • The core operation is defined as SoftSort^d_τ(s) = softmax( -d(sort(s)1^T, 1s^T) / τ ), where d is a semi-metric (e.g., |x−y|).
  • The approach leverages standard automatic differentiation frameworks like PyTorch and TensorFlow, enabling seamless integration into deep learning pipelines.
  • SoftSort is row-stochastic and can be projected to a valid permutation matrix via row-wise argmax, preserving interpretability.
  • The method is modular and extensible, allowing for different distance functions d while maintaining theoretical guarantees.

Experimental results

Research questions

  • RQ1Can a continuous relaxation for argsort be designed that is both simple and efficient while maintaining high performance?
  • RQ2Does SoftSort outperform existing differentiable sorting methods like NeuralSort in terms of speed and optimization efficiency?
  • RQ3Can the mathematical analysis of differentiable sorting be significantly simplified with a new relaxation approach?
  • RQ4How does SoftSort perform across diverse benchmarks involving reordering and ranking tasks?
  • RQ5What is the impact of different distance functions d on the convergence and performance of SoftSort?

Key findings

  • SoftSort achieves state-of-the-art performance on multiple benchmarks involving reordering, matching or slightly outperforming NeuralSort.
  • On both CPU and GPU, SoftSort is approximately 6 times faster than the NeuralSort implementation for input sizes up to n=4000.
  • SoftSort is 80% faster on CPU and 40% faster on GPU than the optimized version of NeuralSort, even after optimization.
  • The learning curves of SoftSort with d=|·| and NeuralSort are nearly identical, indicating comparable optimization dynamics.
  • SoftSort with d=|·| converges more slowly than d=|·|² on a synthetic sorting task, suggesting sensitivity to distance function choice.
  • No significant slowdowns were observed in worst-case input orders, and shuffling inputs can further mitigate any potential performance issues.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.