InfoNCE is a loss function defined as the cross-entropy of a classification problem that picks out the positive from candidates consisting of one positive and negatives. van den Oord, Li, and Vinyals (2018, DeepMind) proposed it as part of Contrastive Predictive Coding (CPC), a method for learning representations without labels. The form of the loss is based on Noise-Contrastive Estimation (NCE), a way of learning probabilistic models by comparing samples against each other.
In CPC, the representation steps ahead is predicted from a context that summarizes a sequence up to time . The candidate set contains one true future (the positive) and negatives drawn from elsewhere. The loss is:
is a score expressing how likely a candidate is to be the positive, is the representation of candidate produced by the encoder, and is a matrix kept separately for each prediction step . The fraction is the softmax of the scores, giving "the probability that this candidate is the positive." The figure at the top shows how probabilities are computed from the scores of 8 candidates and how the of the positive's probability becomes the loss.
The paper shows that minimizing InfoNCE corresponds to maximizing a lower bound on the mutual information between the context and the future . Much of the later contrastive learning inherits this form: NT-Xent in SimCLR replaces the score with cosine similarity and a temperature, and Supervised Contrastive further allows multiple positives.

