Definition
In the context of metric learning, negative mining involves selecting the most informative negative examples to train the model well. Instead of randomly sampling negative examples, we focus on hard negatives, those that are closest to the anchor in the embedding space but belong to a different class. For each anchor, compute distances to all or a subset of negative examples, and select the negative examples that are closest to the anchor.
Online Negative Mining
Online negative mining looks for negatives from the current batch, instead of using one initially assigned.
Semi-Hard Negative Mining

Semi-hard negative mining selects negative examples that are farther from the anchor than the positive example, but still within a certain margin.
If , then consider as a semi-hard negative