One-Class SVM-guided Negative Sampling for Enhanced Contrastive Learning

Dhruv Jain, Tsiry Mayet, Romain Hérault, Romain ModzelewskiNLDL 2025

TL;DR

This paper introduces "Mixing OCSVM negatives (MiOC)," a novel method for generating synthetic negative samples in contrastive learning. By using One-Class SVM (OCSVM) to identify "inlier" negatives, MiOC creates more diverse and meaningful embeddings, leading to improved classification performance across several benchmark datasets.

What Problem Does This Paper Address?

Unsupervised contrastive learning has become a powerful technique for learning rich feature representations from unlabeled data. A critical component of this learning process is the careful selection and mixing of "negative" samples – data points that should be distinguished from the "anchor" or "query" sample. While much research has focused on identifying "hard" negatives (those that are difficult to distinguish), this paper argues that an over-reliance on only hard negatives can limit the diversity of the learned representations. The challenge is to find a more robust and diverse set of negative samples that can lead to better overall performance.

Methods

The core innovation of this paper is the Mixing OCSVM negatives (MiOC) approach. It builds upon existing contrastive learning frameworks (like MoCo) by introducing a new strategy for generating synthetic negative samples. Here's how it works:

  1. OCSVM for Inlier Identification: For each batch of embeddings, an One-Class SVM (OCSVM) is trained. OCSVM is typically used for anomaly detection and aims to find a minimal hypersphere that encloses the "normal" data points. In this context, it's used to identify embeddings that are "inliers" within the hypersphere defined by the query and key embeddings of the current batch. These "inlier" negatives are considered to be within the typical distribution of the data.
  2. Synthetic Negative Generation: Two types of synthetic negatives are generated:
  3. Sn: These are created by interpolating a randomly chosen negative sample from the memory buffer (queue) with a randomly chosen query embedding.
  4. So: These are generated by interpolating a randomly chosen "inlier" negative (identified by OCSVM) with a randomly chosen query embedding. This step is crucial for expanding the sampling space beyond just hard negatives.
  5. Mixing: The newly generated synthetic negatives (Sn and So) are then mixed with the existing memory buffer of negatives. This augmented set of negatives is used in the contrastive loss calculation.

The paper also discusses modifications to existing methods like MoCHI to better integrate with their proposed approach.

Datasets

The following publicly available datasets were used for training and evaluation:

  • Imagenet100: Used for pre-training and linear evaluation.
  • Cifar10: Used for linear evaluation.
  • Cifar100: Used for linear evaluation.
  • Cinic10: A newer dataset used for linear evaluation, positioned as an intermediate between Cifar10 and Imagenet.
  • STL10: Used for linear evaluation.

Key Insights and Ideas

  • Beyond Hard Negatives: The paper strongly advocates for moving beyond solely focusing on "hard" negatives. By incorporating "inlier" negatives identified by OCSVM, MiOC introduces diversity that leads to more meaningful embeddings.
  • OCSVM as a Smart Sampler: OCSVM proves to be an effective tool for identifying a subset of negatives that are representative of the data's typical distribution, which can then be leveraged for generating synthetic negatives.
  • Synthetic Negatives Enhance Robustness: The interpolation strategy for creating synthetic negatives (both Sn and So) effectively expands the negative sampling space, leading to improved generalization and classification performance.
  • Computational Trade-off: While MiOC introduces additional computation for OCSVM fitting, the paper demonstrates that it remains efficient and scales well, especially for smaller to medium batch sizes.

Key Results

  • Improved Classification Performance: MiOC consistently outperformed state-of-the-art methods like MoCov2, MOCHI, and SCE on the Imagenet100 dataset in terms of Top1% Accuracy and k-NN scores. For instance, on Imagenet100 with 200 epochs, MiOC achieved a Top1% Accuracy of 78.07% compared to MoCov2's 77.17%.
  • Strong Generalization: On smaller datasets (Cifar10, Cifar100, Cinic10, STL10), MiOC also showed superior linear evaluation performance, indicating its ability to learn generalizable features.
  • Effective with Limited Data: MiOC demonstrated robust performance even when trained with very few samples per class, outperforming other methods in these challenging scenarios.
  • Visualization: t-SNE visualizations of embeddings showed that MiOC produced more distinct clusters compared to MoCov2.

Limitations and Future Work

  • Computational Overhead: The OCSVM fitting step adds computational cost, although the paper argues it's manageable and scales well.
  • Future Directions: The authors suggest exploring other anomaly detection methods for generating synthetic negatives, comparing different ranking strategies for hard negatives, and investigating the application of MiOC to models that don't explicitly use negatives (like DINO). They also propose further research into identifying and comparing hard negatives based on their similarity to the query.

Summary updated

BibTeX
@inproceedings{jain2025one,
  author = {Dhruv Jain and Tsiry Mayet and Romain HÉRAULT and Romain MODZELEWSKI},
  title = {{One-Class SVM-guided Negative Sampling for Enhanced Contrastive Learning}},
  booktitle = {NLDL},
  year = {2025},
  url = {https://openreview.net/forum?id=XCUzATsVdU},
}
Figure