Prototypical Contrastive Predictive Coding

Kyungmin LeeICLR 2022

Abstract

ProtoCPC (Prototypical Contrastive Predictive Coding) is a novel distillation framework that combines the simplicity of traditional Knowledge Distillation (KD) with the powerful representation-capturing abilities of Contrastive Learning. By using "prototypes" to model the contrastive objective, it achieves state-of-the-art performance in model compression and self-supervised learning without the massive memory buffers or large batch sizes typically required by contrastive methods.

Background and Motivation

In deep learning, transferring knowledge from a large, complex "teacher" model to a smaller, efficient "student" model—a process called Knowledge Distillation (KD)—is highly desirable. Standard KD works by making the student's output probabilities match the teacher's. While simple, it often fails to capture the rich, high-order structural information hidden in the teacher's internal representations.

Contrastive Learning (like CRD) addresses this by teaching the student to distinguish "positive" pairs (the same data point) from "negative" pairs (different data points). However, contrastive learning usually requires a massive number of negative samples to work well, necessitating huge memory buffers or massive batch sizes. ProtoCPC aims to provide the benefits of contrastive learning while eliminating this heavy infrastructure.

Methods: The ProtoCPC Framework

The core innovation of ProtoCPC is redefining the "critic" function in the contrastive objective.

  1. Prototypical Projection: Instead of comparing raw feature vectors using cosine similarity, ProtoCPC projects features into a probability space using prototypes—learnable linear layers acting as "anchor points" in the feature space.
  2. The Probabilistic Critic: The discrepancy between the teacher and student is modeled using the negative exponential of the cross-entropy between their probabilistic outputs.
  3. Prior Momentum: To avoid needing thousands of explicit negative samples, the model maintains an Exponential Moving Average (EMA) of the teacher's probability distribution (the "prior"). This prior acts as a statistical summary of the "negatives," allowing the model to enforce contrastive constraints using only the current batch.
  4. Sinkhorn-Knopp (SK) Operator: To prevent "representation collapse" (where the model lazily maps all inputs to a single prototype), the Sinkhorn-Knopp algorithm ensures the teacher's probability assignments are distributed reasonably across all available prototypes.
ProtoCPC applied to three distillation tasks

As illustrated above, the paper applies this method to three distinct tasks:

  • Supervised Model Compression: Distilling a labeled classifier.
  • Self-Supervised Model Compression: Distilling a model trained without labels (e.g., MoCo or DINO).
  • Self-Distillation: Using the objective to improve self-supervised learning itself.

Key Insights

  • Implicit Uniformity: The authors provide a theoretical link between ProtoCPC and von-Mises Fisher kernel density estimation, showing that their loss naturally encourages "uniformity"—forcing features to spread out evenly across the hypersphere.
  • Priors over Buffers: The "prior momentum" trick effectively replaces a massive memory bank with a single moving-average vector, accurately estimating the distribution of negative samples.
  • Leveraging Existing Structure: In supervised tasks, ProtoCPC uses the model's existing classification layer as the prototypes, meaning contrastive learning happens "for free."

Experimental Results

The authors validated ProtoCPC on CIFAR-100 and ImageNet across various architectures (ResNet, WideResNet, MobileNetV2, ShuffleNet, DeiT).

Top-1 accuracy (%) on CIFAR-100 for similar architectures
  • Supervised Distillation: On CIFAR-100, ProtoCPC consistently outperformed standard KD and CRD. For instance, distilling a WRN-40-2 into a WRN-16-2, ProtoCPC achieved 75.79% accuracy, compared to KD's 74.92% and CRD's 75.48%.
  • ImageNet Performance: Distilling a ResNet-34 into a ResNet-18, ProtoCPC achieved a Top-1 error of 28.54%, outperforming CRD (28.83%) and Online KD (29.45%).
  • Self-Supervised SOTA: When distilling a MoCo-v2 ResNet-50 into a ResNet-18, ProtoCPC reached 61.1% linear accuracy, a massive leap over standard self-supervised learning (52.5%).
  • Self-Distillation Boost: Enhancing the DINO framework with ProtoCPC improved ResNet-50 performance from 70.9% to 71.8%.

Limitations and Future Work

While ProtoCPC removes the memory buffer, it introduces new hyperparameters like temperatures ($\tau_s, \tau_t$) and the prior momentum rate ($m_p$) that require careful tuning. Additionally, for self-supervised tasks, the method relies on a very large number of prototypes ($K = 65536$). Exploring how the method scales with fewer prototypes or in different domains (like NLP) remains an open question. Finally, the Sinkhorn-Knopp operator adds a small amount of iterative computation, though this is generally negligible compared to the memory savings.

Summary updated

BibTeX
@inproceedings{lee2022prototypical,
  author = {Kyungmin Lee},
  title = {{Prototypical Contrastive Predictive Coding}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=QRIBK1ReKAv},
}
Figure