Contrastive learning is a machine learning approach which effectively compares a pair of positive/negative samples, then computes the loss in the embedding space.

Compare this to an autoencoder. We effectively pass everything forward: from the input, we pass it through an encoder to compress all details, then reconstruct it in the output space.

A contrastive approach uses the input, passes it through an encoder; then the output and passes it through a decoder. It then computes the loss in the embedding space by comparing the two input/output values. It does require many negative examples.