In contrastive learning, "pulling" and "pushing" refer to adjusting the representations (the sequence of numbers I mentioned earlier) produced by the neural network, so that similar samples are close to each other and dissimilar samples are far apart in the representation space.
This is achieved using a loss function, which compares the representations of each pair of samples and calculates a score that measures how close or far apart they are. The goal is to minimize this score for similar pairs and maximize it for dissimilar pairs.
The mathematical details can vary, but a common approach is to use the contrastive loss, which is calculated as:

Loss = (1 - y) * d^2 + y * max(margin - d, 0)^2

where:

    - d is the Euclidean distance between the representations of the two samples
    - y is a binary label indicating whether the two samples are similar (y = 1) or dissimilar (y = 0)
    - margin is a hyperparameter that sets the minimum acceptable distance between representations of dissimilar pairs

This loss function encourages the representations of similar pairs to be close together (i.e., d is small), while penalizing representations of dissimilar pairs that are too close (i.e., d is large but less than margin).
To optimize this loss, we can use any gradient-based optimization method, such as stochastic gradient descent, to update the parameters of the neural network. The idea is that over time, the representations produced by the network will become increasingly good at separating similar and dissimilar samples, which will improve the model's ability to discriminate between different classes.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence