Category-Level Contrastive Learning for Unsupervised Hashing in Cross-Modal Retrieval

Mengying Xu, Linyin Luo, Hanjiang Lai, Jian Yin

Introduction

Cross-modal retrieval—the ability to search for relevant text using an image query or vice versa—is a cornerstone of modern information systems. However, processing high-dimensional data across different modalities is computationally intensive. Hashing addresses this by mapping data into compact, low-dimensional binary codes, enabling efficient similarity searches in Hamming space.

While unsupervised hashing has gained popularity due to the high cost of manual labeling, current state-of-the-art methods face two significant hurdles: information incompleteness and false-negative sampling. Most models rely on batch-level contrastive learning, which restricts the model's view to a small subset of the data and often mistakenly treats semantically similar items as "negatives," degrading the quality of the resulting hash codes.

Proposed Methodology

To overcome these limitations, this paper introduces a Category-Level Contrastive Learning framework. The architecture moves beyond localized batch training by incorporating a global perspective of the dataset's semantic structure.

Overview of the proposed Category-Level Contrastive Learning framework, illustrating the image/text encoders, the selected memory module with K-means clustering, and the tripartite loss function.

Framework Components

  1. Dual Encoders: The system utilizes a VGG-19 network for image feature extraction and a Bag-of-Words (BoW) paired with a Multi-Layer Perceptron (MLP) for text processing.
  2. Selected Memory Module: This module maintains a global memory bank of multi-modal representations. By applying K-means clustering to these representations, the model generates "pseudo-labels" that capture the global data distribution.
  3. Category-Level Negative Sampling: Using pseudo-labels, the memory bank ensures that negative samples for contrastive learning are drawn only from different pseudo-categories. This prevents the model from penalizing similar items, a common flaw in random sampling.
  4. Hadamard Hash Centers: To maximize discriminative power, the authors initialize class centers using a Hadamard matrix. This mathematical approach ensures that different categories are represented by orthogonal vectors, maximizing the Hamming distance between them.

Tripartite Loss Function

The training process is guided by three distinct loss components:

  • Contrastive Loss: Synchronizes representations across image and text modalities.
  • Bank Loss: An InfoNCE-based loss that utilizes the memory bank to pull positive pairs together while pushing away verified category-level negatives.
  • Center Loss: Aligns individual data representations with their assigned, mathematically optimized category hash centers.

Experimental Results

The framework was evaluated on two benchmark datasets: MIRFLICKR-25K and NUS-WIDE.

On the MIRFLICKR-25K dataset, the model achieved a Mean Average Precision (mAP) of 0.750 for 16-bit Image-to-Text (I2T) retrieval, outperforming the previous state-of-the-art (UCCH) by approximately 1.64%. The performance gap widened on the larger NUS-WIDE dataset, where the model achieved an mAP of 0.683 for 16-bit I2T retrieval, a 2.79% improvement over UCCH.

Ablation Insights

Ablation studies highlighted the Bank Loss as the most critical component of the architecture. Removing the global memory bank functionality led to a performance drop of over 20% (e.g., from 0.750 to 0.606 on 16-bit I2T), confirming that global context and refined negative sampling are essential for high-quality unsupervised hashing.

Conclusion

By shifting from instance-level to category-level contrastive learning, this method successfully addresses the bottlenecks of localized training and noisy negative sampling. While the performance is currently tied to the quality of K-means clustering, the use of orthogonal Hadamard centers and a global memory bank sets a new standard for unsupervised cross-modal retrieval. Future work will focus on further refining the optimization of positive samples to complement the current advancements in negative sample selection.

Summary updated

BibTeX
@article{xu2024category,
  author = {Mengying Xu and Linyin Luo and Hanjiang Lai and Jian Yin},
  title = {{Category-Level Contrastive Learning for Unsupervised Hashing in Cross-Modal Retrieval}},
  journal = {Data Sci. Eng.},
  year = {2024},
  doi = {10.1007/s41019-024-00248-9},
}
Figure