Contrastive learning is a supervised method for driving the latent representations of data points towards or away from each other by adding custom losses.
Implementations
- The triplet margin loss used by Yu et al. (1): : Enzyme embedding : Positive case : Negative case, selected to have EC numbers close in Euclidean space to the positive case : Margin; set to 1
- The supercon hard loss used by Yu et al. (1): : temperature, set to 0.1 in the paper
- Noise contrastive estimation (variant 1): : Input text : Another example (either positive or negative) : Scoring function, usually cosine similarity, dot product, or logit “produced by input-sample matcher sub-network” (from Rethmeier and Augenstein 2021) : Scaling function, usually sigmoid
- Noise contrastive estimation (variant 2, ranks a single positive pair over negative pairs): Variant 2 ranks a single positive pair over negative pairs
1.
Yu T, Cui H, Li JC, Luo Y, Jiang G, Zhao H. Enzyme function prediction using contrastive learning. Science. 2023;379(6639):1358–63. Available from: https://doi.org/10.1126/science.adf2465