Optimizing Rank-based Metrics with Blackbox Differentiation
Michal Rolínek, Vít Musil, Anselm Paulus, Marin Vlastelica, Claudio Michaelis, Georg Martius
TL;DR
This paper tackles the challenge of directly optimizing non-differentiable rank-based metrics like AP and Recall in vision tasks. It introduces RaMBO, a blackbox differentiation framework that treats ranking as a combinatorial solver and backpropagates through a differentiable interpolation with controlled fidelity via a parameter $\lambda$. The authors design sound loss functions (recall-based and AP-based) and address practical issues such as mini-batch bias, ties, and sparse supervision through margin shifts, score memory, and refined recall signals. Empirical results on image retrieval and object detection show competitive retrieval performance and consistent improvements on near-state-of-the-art detectors, while maintaining computational efficiency suitable for long sequences. The work provides a principled, implementable path for integrating rank-based optimization into standard CV pipelines, with public code to foster adoption and extension.
Abstract
Rank-based metrics are some of the most widely used criteria for performance evaluation of computer vision models. Despite years of effort, direct optimization for these metrics remains a challenge due to their non-differentiable and non-decomposable nature. We present an efficient, theoretically sound, and general method for differentiating rank-based metrics with mini-batch gradient descent. In addition, we address optimization instability and sparsity of the supervision signal that both arise from using rank-based metrics as optimization targets. Resulting losses based on recall and Average Precision are applied to image retrieval and object detection tasks. We obtain performance that is competitive with state-of-the-art on standard image retrieval datasets and consistently improve performance of near state-of-the-art object detectors. The code is available at https://github.com/martius-lab/blackbox-backprop
