Efficient Optimization for Rank-Based Loss Functions

Pritish Mohapatra, Michal Rolínek, C. V. Jawahar, Vladimir Kolmogorov, M. Pawan Kumar

Abstract

The accuracy of information retrieval systems is often measured using complex loss functions such as the average precision (AP) or the normalized discounted cumulative gain (NDCG). Given a set of positive and negative samples, the parameters of a retrieval system can be estimated by minimizing these loss functions. However, the non-differentiability and non-decomposability of these loss functions does not allow for simple gradient based optimization algorithms. This issue is generally circumvented by either optimizing a structured hinge-loss upper bound to the loss function or by using asymptotic methods like the direct-loss minimization framework. Yet, the high computational complexity of loss-augmented inference, which is necessary for both the frameworks, prohibits its use in large training data sets. To alleviate this deficiency, we present a novel quicksort flavored algorithm for a large class of non-decomposable loss functions. We provide a complete characterization of the loss functions that are amenable to our algorithm, and show that it includes both AP and NDCG based loss functions. Furthermore, we prove that no comparison based algorithm can improve upon the computational complexity of our approach asymptotically. We demonstrate the effectiveness of our approach in the context of optimizing the structured hinge loss upper bound of AP and NDCG loss for learning models for a variety of vision tasks. We show that our approach provides significantly better results than simpler decomposable loss functions, while requiring a comparable training time.

Introduction

In fields like information retrieval and computer vision, the performance of a system is often defined by the order of its results. Metrics such as Average Precision (AP) and Normalized Discounted Cumulative Gain (NDCG) are standard because they reward systems that rank relevant items at the top. However, these metrics are "non-decomposable," meaning the loss for a single sample depends on its relative rank among all other samples.

Optimizing these metrics directly is challenging. Techniques like Structured SVMs or Deep Networks often rely on loss-augmented inference, which requires finding a ranking that maximizes the sum of model scores and task loss. For a dataset with $P$ positive and $N$ negative samples, traditional algorithms for AP and NDCG have a complexity of $O(PN + N \log N)$. In large-scale scenarios like object detection, where $N$ can reach millions, this computational burden forces a retreat to simpler, less effective surrogate losses like the 0-1 loss.

Methodology: The OptRanks Algorithm

This paper introduces a class of QS-suitable (Quicksort-suitable) loss functions characterized by two properties:

  1. Negative-decomposability: The total loss is the sum of losses over individual negative samples.
  2. Interleaving-dependence: The loss for a negative sample depends only on its "interleaving rank"—the number of positive samples ranked above it.

The proposed OptRanks algorithm uses a divide-and-conquer strategy inspired by Quicksort to perform loss-augmented inference. Instead of a full sort, it employs linear-time selection to find the median score among negative samples and determines its optimal interleaving rank. By exploiting a monotonicity property—where lower-scoring negative samples must have an equal or lower rank than higher-scoring ones—the algorithm recursively prunes the search space. This reduces the complexity to $O(N \log P)$, making it nearly linear in the number of negative samples.

Experimental Results

The authors evaluated the approach across several vision tasks, including action classification (PASCAL VOC 2011), large-scale object detection (PASCAL VOC 2007), and image classification (CIFAR-10).

Computational Efficiency

The primary advantage of the QS-flavored algorithm is its scalability. In action classification, the proposed AP_QS method was over 10x faster per inference call than previous state-of-the-art AP optimization.

Computation time for AP vs. number of negative samples. AP_QS (green) significantly outperforms the standard AP optimization (red) and approaches the speed of 0-1 loss (blue).

Similar gains were observed for NDCG. On the VOC 2007 object detection task involving 10 million samples, loss-augmented inference took only 0.52 seconds with the new algorithm, compared to over 7.6 seconds using standard methods.

Computation time for NDCG vs. number of negative samples. NDCG_QS (green) maintains near-constant time compared to the standard NDCG (red).

Accuracy and Performance

Directly optimizing for AP yielded significant performance boosts. On VOC 2011, the method achieved a mean AP of 51.2, compared to 47.9 when using a standard 0-1 loss surrogate. In deep learning contexts, layer-wise training on CIFAR-10 saw total training time drop from 2 hours to 1.6 hours while simultaneously improving accuracy.

Conclusion

By reducing the complexity of loss-augmented inference to $O(N \log P)$, this work makes direct optimization of complex ranking metrics feasible for massive datasets. The authors proved that this approach is asymptotically optimal for comparison-based algorithms. Future work includes extending this framework to other non-decomposable metrics such as the F-measure or Mean Reciprocal Rank (MRR).

Summary updated

BibTeX
@inproceedings{mohapatra2018efficient,
  author = {Pritish Mohapatra and Michal Rolínek and C. V. Jawahar and Vladimir Kolmogorov and M. Pawan Kumar},
  title = {{Efficient Optimization for Rank-Based Loss Functions}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2018},
  url = {https://openreview.net/forum?id=ryNWOaWuZr},
}
Figure