hard negative mining
**Hard Negative Mining** is a **training strategy in contrastive and metric learning where the most difficult negative examples are specifically selected** — focusing the model's learning on the challenging cases that are most likely to be confused with positives, rather than wasting capacity on easy negatives.
**What Is Hard Negative Mining?**
- **Easy Negatives**: Samples obviously different from the anchor (e.g., airplane vs. cat). Gradient is near zero.
- **Hard Negatives**: Samples similar to the anchor but from a different class (e.g., leopard vs. cheetah). Large, informative gradient.
- **Mining Strategies**: Top-k hardest negatives, semi-hard negatives (harder than positive but not the hardest), curriculum from easy to hard.
**Why It Matters**
- **Training Efficiency**: Most negatives in a large batch contribute negligible gradients. Hard negatives drive faster learning.
- **Representation Quality**: Models trained with hard negatives develop finer-grained representations.
- **Stability**: Too-hard negatives can cause training collapse. Semi-hard mining balances difficulty and stability.
**Hard Negative Mining** is **selective training on the tricky cases** — focusing learning where it matters most to build representations that can distinguish the most confusable examples.