Introduction
In the lifecycle of deep learning applications, models are rarely static. We frequently transition knowledge between architectures, whether compressing a high-capacity "teacher" into a lightweight "student" (Knowledge Distillation) or migrating from a legacy system to a state-of-the-art successor (Model Upgrading).
Traditional methods for these transitions often focus on point-wise mimicry, forcing the target model to replicate the exact logits or feature vectors of the source. However, this rigid approach can be counterproductive; it forces the target to inherit the source's specific errors and ignores the inherent geometric differences between architectures. This paper proposes Contrastive Neighborhood Alignment (CNA), a method that shifts the focus from absolute coordinates to the underlying topology of the feature space.
The CNA Framework
The fundamental premise of CNA is that the "knowledge" of a model is encoded in the relative relationships between data points. If two samples are neighbors in the source model's representation, they should remain neighbors in the target model's representation, regardless of the specific feature values.
The Three-Step Workflow
- Neighborhood Identification: For each sample in a training batch, the algorithm identifies its nearest neighbors within the source model’s feature space. This captures the local "shape" of the data as perceived by the original model.
- Contrastive Alignment: The target model is trained using a contrastive loss function (modeled after InfoNCE). This loss function acts as a geometric regularizer: it "pulls" a sample toward its source-identified neighbors in the target space while simultaneously "pushing" it away from all other samples in the batch.
- Inductive Generalization: Unlike classic manifold learning techniques like LLE or Isomap, which are transductive and require the entire dataset to be re-processed for new samples, CNA trains a neural network. This allows the learned structural preservation to generalize instantly to unseen data.
Because the CNA loss uses a softmax-based formulation, it integrates seamlessly with standard cross-entropy losses, allowing for joint optimization without the "loss competition" often seen in complex distillation pipelines.
Experimental Evaluation
Manifold Learning and Visualization
To test the ability of CNA to capture complex data structures, the researchers applied it to synthetic 3D manifolds like the S-curve and Swiss Roll. While traditional methods often struggle to generalize or produce distorted embeddings, CNA successfully "unfolds" these shapes into coherent 2D representations.
On benchmark datasets like MNIST and CIFAR-10, CNA outperformed traditional manifold learning methods in 5-Nearest Neighbor generalization accuracy. This confirms that the inductive nature of CNA effectively captures the underlying semantic structure of the data.
Knowledge Distillation and Model Upgrading
In practical image classification tasks, CNA demonstrates significant utility:
- State-of-the-Art Distillation: On CIFAR-100, CNA achieved an accuracy of 71.96% when distilling a ResNet56 to a ResNet20, surpassing standard Knowledge Distillation (71.82%).
- Reducing Model Regression: A common issue in industry is "model regression," where a newer, more accurate model fails on specific samples that the old model handled correctly. CNA addresses this by maintaining a consistent "worldview" between versions. It reduced the Negative Flip Rate (NFR) by 29.9% on CIFAR-100 and 14.1% on ImageNet compared to baseline upgrades.
Conclusion and Future Directions
Contrastive Neighborhood Alignment provides a flexible, unsupervised, and label-agnostic framework for model transition. By prioritizing topology over raw values, it offers a more robust way to preserve data structure across different architectures.
While highly effective, the authors note that performance is currently sensitive to batch sizes on large-scale datasets like ImageNet, as small batches may not contain a sample's true nearest neighbors. Future research may explore adaptive neighbor selection ($K$) and methods to mitigate the potential transfer of biases from the source model's embeddings. Nonetheless, CNA represents a significant step toward more stable and geometrically-aware model evolution.
Summary updated