Revisiting a kNN-Based Image Classification System with High-Capacity Storage

Kengo Nakata, Youyang Ng, Daisuke Miyashita, Asuka Maki, Yu-Chieh Lin, Jun DeguchiECCV 2022

Introduction

In standard deep learning, knowledge is typically embedded within millions of model parameters during training. While effective, this approach introduces several challenges:

  1. Catastrophic Forgetting: Learning new information often requires expensive retraining to avoid overwriting previous knowledge.
  2. The Black Box Problem: Understanding the specific reasoning behind a classification is difficult.
  3. Inflexibility: Correcting errors in the training data usually necessitates a full model retrain.

Researchers from Kioxia Corporation propose a paradigm shift: moving classification knowledge out of rigid neural network parameters and into high-capacity external storage. By combining a pretrained encoder with a k-Nearest Neighbor (kNN) retrieval system, they create a model that is easily "debuggable," avoids forgetting, and achieves high accuracy without fine-tuning.

Methodology

The proposed system decouples representation from classification through three phases:

  1. Pretraining: A high-quality image encoder (e.g., CLIP or ResNet) is pretrained on a large dataset and then "frozen."
  2. Knowledge Storing: A "support set" is passed through the frozen encoder. The resulting feature maps and their labels are stored in a database.
  3. Inference: For a query image, the system extracts its feature vector, calculates cosine similarity against the database, and retrieves the top-k most similar samples to determine the class via majority vote.
Overview of the kNN-based classification system using a frozen image encoder and external storage.

This approach leverages modern hardware, such as NVIDIA A100 GPUs, to perform million-scale retrieval in milliseconds.

Key Insights: Explainability and Scale

A major advantage of this system is Explainability by Example. Traditional models use methods like Grad-CAM to show where a model looked, but this system shows what it remembered. If a query is misclassified, a human can inspect the top-k neighbors to identify mislabeled or confusing images in the database.

Example of a misclassification where the system identifies similar but incorrectly labeled neighbors, allowing for human debugging.

Furthermore, the system allows for Instant Updates. New classes can be added by simply inserting feature maps into the database—no gradient descent required. The authors also found that as the database grows (from 12k to 1.28M samples), accuracy improves significantly, suggesting that increased memory can compensate for the lack of task-specific fine-tuning.

Key Results

The system was evaluated on benchmarks including ImageNet-1k, CIFAR-10/100, and STL-10.

  • Continual Learning: On the Split CIFAR-100 benchmark, the system achieved 90.8% accuracy, far outperforming traditional methods like iCaRL (80.9%) and EWC (42.2%).
  • Zero-Shot Performance: Using a ViT-L/14 encoder and 1.28M samples, the system reached 79.8% top-1 accuracy on ImageNet without any fine-tuning.
  • Efficiency: The search overhead for 1.28 million samples was only 3.6% (approx. 0.1 ms) on an A100 GPU.
  • Knowledge Correction: By removing incorrectly labeled samples identified via ImageNet-ReaL, the authors improved accuracy instantly without retraining.

Limitations and Future Work

The system's performance is fundamentally capped by the Encoder Dependency; if the frozen encoder cannot distinguish between fine-grained categories, the kNN search will fail. Additionally, while the current Storage Footprint (5.3 GB for 1.28M samples) is manageable, scaling to billions of images will require advanced Approximate Nearest Neighbor (ANN) search algorithms. Future work will focus on these scaling challenges and more robust pretraining methods.

Summary updated

BibTeX
@inproceedings{nakata2022revisiting,
  author = {Kengo Nakata and Youyang Ng and Daisuke Miyashita and Asuka Maki and Yu-Chieh Lin and Jun Deguchi},
  title = {{Revisiting a kNN-Based Image Classification System with High-Capacity Storage}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19836-6\_26},
}
Figure