A soft nearest-neighbor framework for continual semi-supervised learning

Zhiqi Kang, Enrico Fini, Moin Nabi, Elisa Ricci, Karteek Alahari · DOI

Introduction

Continual Semi-supervised Learning (CSSL) represents a realistic yet challenging scenario where data arrives in a stream and only a small fraction is labeled. Traditional models in this setting suffer from catastrophic forgetting—the loss of previously learned representations—and overfitting to the sparse labeled set. NNCSL (Nearest Neighbor for Continual Semi-supervised Learning) addresses these issues by moving away from parametric classifiers in favor of a non-parametric soft nearest-neighbor approach.

Methodology

The NNCSL framework consists of two primary components: a base learner (CSL) and a novel distillation loss (NND).

Continual Soft-Nearest Neighbor (CSL)

Instead of a standard linear classification head, NNCSL projects images into a feature space. Classification is performed by identifying the "nearest neighbors" among labeled samples in this space. This non-parametric approach provides greater flexibility when labels are scarce, as it doesn't rely on fixed weights that are prone to forgetting. Crucially, the model trains a linear classifier simultaneously with representation learning to avoid the performance drops typically associated with fine-tuning on small labeled sets.

Nearest-Neighbor Distillation (NND)

To maintain stability across tasks, the authors introduce Nearest-Neighbor Distillation (NND). This is the "secret sauce" for stability. Unlike standard distillation that matches class probabilities, NND preserves the local structure of the feature space. It ensures that if two samples were close in the previous model's feature space, they remain close in the current model's space, anchoring representations and preventing drift.

Figure 4: The Nearest-Neighbor Distillation (NND) loss preserves the local structure of the feature space between the old and new models.

Experimental Results

The framework was evaluated on CIFAR-10, CIFAR-100, and ImageNet-100 across varying levels of supervision (0.8%, 5%, and 25%).

Performance and Data Efficiency

NNCSL demonstrates remarkable data efficiency. On CIFAR-100, the model using only 0.8% labels (approximately 4 labels per class) matched or exceeded the performance of baseline methods using 25% labels. This represents a 30-fold improvement in label efficiency.

Figure 1: Performance comparison of NNCSL against baselines. Left: Accuracy vs. percentage of labeled data. Right: Accuracy across sequential tasks on CIFAR-100.

On the 20-task ImageNet-100 benchmark with 25% labels, NNCSL achieved 65.6% accuracy, significantly outperforming the next best method, CCIC, which reached only 25.9%. The method also showed significantly higher stability across different random seeds compared to baselines.

Conclusion

NNCSL provides a robust solution for learning from data streams with minimal supervision. By leveraging the stability of non-parametric nearest-neighbor classification and relationship-preserving distillation, it sets a new state-of-the-art for continual semi-supervised learning, particularly in low-label regimes. Future work may explore scaling this approach to Vision Transformers and reducing the dependency on a memory buffer for labeled samples.

Summary updated

BibTeX
@inproceedings{kang2022soft,
  author = {Zhiqi Kang and Enrico Fini and Moin Nabi and Elisa Ricci and Karteek Alahari},
  title = {{A soft nearest-neighbor framework for continual semi-supervised learning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2022},
  doi = {10.1109/iccv51070.2023.01090},
}
Figure