Abstract
Image-Text Retrieval (ITR) is essentially a ranking problem. Given a query caption, the goal is to rank candidate images by relevance, from large to small. The current ITR datasets are constructed in a pairwise manner. Image-text pairs are annotated as positive or negative. Correspondingly, ITR models mainly use pairwise losses, such as triplet loss, to learn to rank. Pairwise-based ITR increases positive pair similarity while decreasing negative pair similarity indiscriminately. However, the relevance between dissimilar negative pairs is different. Pairwise annotations cannot reflect this difference in relevance. In the current datasets, pairwise annotations miss many correlations. There are many potential positive pairs among the pairs labeled as negative. Pairwise-based ITR can only rank positive samples before negative samples, but cannot rank negative samples by relevance. In this paper, we integrate listwise ranking into conventional pairwise-based ITR. Listwise ranking optimizes the entire ranking list based on relevance scores. Specifically, we first propose a Relevance Score Calculation (RSC) module to calculate the relevance score of the entire ranked list. Then we choose the ranking metric, Normalized Discounted Cumulative Gain (NDCG), as the optimization objective. We transform the non-differentiable NDCG into a differentiable listwise loss, named Smooth-NDCG (S-NDCG). Our listwise ranking approach can be plug-and-play integrated into current pairwise-based ITR models. Experiments on ITR benchmarks show that integrating listwise ranking can improve the performance of current ITR models and provide more user-friendly retrieval results.
Introduction
Image-Text Retrieval (ITR) is a fundamental task in cross-modal understanding, where the objective is to retrieve the most relevant images for a given text query or vice versa. Traditionally, this has been framed as a pairwise ranking problem. Models are trained using losses like triplet loss, which aim to ensure that a "positive" pair (a matching image and caption) has a higher similarity score than a "negative" pair by at least a predefined margin.
However, this approach has a significant limitation: it treats all negative samples as equally irrelevant. In real-world scenarios, some negative samples are semantically closer to the query than others. For instance, if the query is "a man playing musical instruments," an image of a man playing a guitar is a "near-miss" compared to an image of a dog in a park. Pairwise models fail to distinguish between these, potentially ranking a completely irrelevant image higher than a semantically related one simply because both were labeled as negatives.
Methodology
To address the limitations of pairwise ranking, we propose a framework that integrates listwise ranking into existing ITR models. This framework consists of two core innovations: the Relevance Score Calculation (RSC) module and the Smooth-NDCG (S-NDCG) loss.
Relevance Score Calculation (RSC)
Since standard ITR datasets only provide binary positive/negative labels, we need a mechanism to estimate fine-grained relevance for negative pairs. The RSC module utilizes text similarity as a proxy for image-text relevance. For a query caption $T_i$ and a candidate image $V_j$, we calculate the similarity between $T_i$ and the ground-truth caption of $V_j$ using a pre-trained Sentence-Transformer. This provides a continuous relevance score $r(V_j, T_i)$ that reflects semantic proximity even for samples labeled as negative.
Smooth-NDCG (S-NDCG) Loss
Normalized Discounted Cumulative Gain (NDCG) is a standard metric for evaluating ranked lists, but its dependence on discrete ranks makes it non-differentiable and unsuitable for direct optimization via gradient descent. We overcome this by replacing the discrete ranking indicator (the Heaviside step function) with a differentiable sigmoid function $\sigma(x; \tau)$. This "smoothing" allows us to define a differentiable listwise loss, S-NDCG, which can be optimized alongside traditional pairwise losses.
The final training objective is a combination of the standard triplet loss and our S-NDCG loss: $\mathcal{L} = \mathcal{L}_{Triplet} + \mathcal{L}_{S-NDCG}$. This joint approach leverages the stability of pairwise learning while benefiting from the fine-grained sorting capabilities of listwise ranking.
Experiments and Results
We evaluated our approach on three major benchmarks: Flickr30K, MS-COCO, and the ECCV Caption dataset. Our listwise ranking module was integrated into several state-of-the-art baseline models, including VSE++, VSE∞, and SGRAF.
- Performance Improvements: On the Flickr30K dataset, adding listwise ranking to the SGRAF model increased the RSUM (the sum of Recall@1, 5, and 10 for both image and text retrieval) from 499.6 to 509.1. Similar gains were observed across other models and datasets.
- State-of-the-Art Results: The combination of VSE∞ and our listwise ranking achieved new state-of-the-art performance on MS-COCO and Flickr30K.
- Qualitative Superiority: Retrieval results demonstrate that when the exact match is not found, the top-ranked "incorrect" results are semantically much closer to the query than those produced by baseline pairwise models.
- Efficiency: The RSC and S-NDCG modules are only utilized during the training phase. Consequently, there is zero additional computational overhead during inference, making this a highly practical enhancement for real-time retrieval systems.
Conclusion
By integrating listwise ranking into the pairwise-based ITR paradigm, we enable models to learn from the nuanced relevance of negative samples. Our proposed RSC module and S-NDCG loss provide a robust, differentiable way to optimize the entire ranking list. Experimental results confirm that this approach not only improves standard retrieval metrics but also produces more semantically coherent and user-friendly results.
Summary updated