AttentionNCE: Contrastive Learning with Instance Attention

Bin Liu, Xiaohong Liu, Ziqiao Shang, Lin Ma, Zhaoyu Li, Fei Teng, Tianrui LiOpenReview 2025 · Submission to ICLR 2025 · Rejected · OpenReview

Abstract

Contrastive learning has found extensive applications in computer vision, natural language processing, and information retrieval, significantly advancing the frontier of self-supervised learning. However, the limited availability of labels poses challenges in contrastive learning, as the positive and negative samples can be noisy, adversely affecting model training. To address this, we introduce instance-wise attention into the variational lower bound of contrastive loss, and proposing the AttentionNCE loss accordingly. AttentioNCE incorporates two key components that enhance contrastive learning performance: First, it replaces instance-level contrast with attention-based sample prototype contrast, helping to mitigate noise disturbances. Second, it introduces a flexible hard sample mining mechanism, guiding the model to focus on high-quality, informative samples. Theoretically, we demonstrate that optimizing AttentionNCE is equivalent to optimizing the variational lower bound of contrastive loss, offering a worst-case guarantee for maximum likelihood estimation under noisy conditions. Empirically, we apply AttentionNCE to popular contrastive learning frameworks and validate its effectiveness. The code is released at: \url{https://anonymous.4open.science/r/AttentioNCE-55EB}
BibTeX
@misc{liu2025attentionnce,
  author = {Bin Liu and Xiaohong Liu and Ziqiao Shang and Lin Ma and Zhaoyu Li and Fei Teng and Tianrui Li},
  title = {{AttentionNCE: Contrastive Learning with Instance Attention}},
  year = {2025},
  url = {https://openreview.net/forum?id=FfHGAAoSVJ},
  howpublished = {OpenReview},
  note = {Submitted to ICLR 2025},
}
Figure