Few-shot Metric Learning: Online Adaptation of Embedding for Retrieval

Deunsol Jung, Dahyun Kang, Suha Kwak, Minsu Cho · DOI

Abstract

Deep Metric Learning (DML) aims to map images into an embedding space where distance reflects semantic similarity. However, standard DML models often struggle to generalize when the target domain differs significantly from the training distribution. This paper introduces Few-shot Metric Learning (FSML), a paradigm that adapts embedding functions to new domains using only a few labeled examples. We present Channel-Rectifier Meta-Learning (CRML), a method that meta-learns to adjust intermediate feature channels. CRML avoids the overfitting common in small-sample adaptation while providing the flexibility needed for diverse retrieval tasks. Our results across multiple benchmarks demonstrate that CRML significantly outperforms existing DML and few-shot classification baselines, particularly in cross-domain scenarios.

Introduction

Deep Metric Learning (DML) is a cornerstone of modern computer vision, enabling tasks like face recognition and image retrieval by teaching networks to map similar objects close together in a vector space. While DML excels in "open-set" problems where new classes are seen at test time, its performance degrades sharply when those classes come from a different domain (e.g., a model trained on birds attempting to retrieve specific car models).

Existing few-shot learning research has largely focused on classification, where the goal is to draw decision boundaries between classes. However, classification is often insufficient for retrieval. A classifier may correctly identify a category, but it does not necessarily optimize the relative distance between items within that category. This paper addresses the gap by focusing on adapting the entire distance-relationship structure of the embedding space on the fly using a small support set.

Methodology

The Challenge of Adaptation

Adapting a massive pre-trained model (like a ResNet) to a new task with only a handful of images (e.g., 5 images per class) typically leads to two extremes:

  1. Overfitting: Fine-tuning all weights (Simple Fine-Tuning) quickly destroys the model's general feature extraction capabilities.
  2. Underfitting: Updating only the final linear layer is often too restrictive to capture the nuances of a new domain.

Channel-Rectifier Meta-Learning (CRML)

To find a "sweet spot" of plasticity, the authors propose CRML. Instead of updating the entire network, CRML meta-learns a set of channel scaling and shifting parameters ($\gamma$ and $\beta$) for intermediate layers.

During the "inner loop" of the meta-learning process, the model learns how to quickly adjust these channel rectifiers based on the available support samples. This allows the model to "re-weight" features that are relevant to the specific target domain—such as focusing on texture for clothing or shape for biological species—without altering the underlying robust feature extractors learned during pre-training.

Experimental Setup

The researchers evaluated CRML against several baselines, including Model-Agnostic Meta-Learning (MAML) and Meta-Transfer Learning (MTL), across four diverse datasets:

  • miniImageNet: A standard benchmark for few-shot learning.
  • CUB-200-2011: A dataset of fine-grained bird species used to test domain specialization.
  • MPII: A human pose dataset used to evaluate performance on continuous labels, where similarity is a sliding scale of joint distances rather than discrete categories.
  • miniDeepFashion: A new dataset introduced by the authors to simulate complex retrieval scenarios. In this dataset, "similarity" can be subjective, based on either category (e.g., both are coats) or specific attributes (e.g., both have belts), forcing the model to adapt its embedding space to the requested context.

Key Results and Discussion

Performance Gains

CRML consistently outperformed both standard DML and other few-shot adaptation baselines. On the miniImageNet (5-way 5-shot) task, CRML achieved a 69.2% mAP, a significant jump from the 46.9% achieved by standard DML and the 65.9% by the MAML baseline.

The Domain Gap Advantage

One of the most critical findings was that the benefit of CRML increases with the difficulty of the task. In cross-domain evaluations (training on ImageNet and testing on CUB birds), CRML improved the mAP from 36.2% to 56.4%. This suggests that meta-learned adaptation is most valuable when the target domain features differ substantially from the source data.

Selective Plasticity

By restricting updates to the channel rectifiers, the model maintains a balance between flexibility and stability. It can learn new domain-specific feature importance while retaining the general-purpose feature extraction capabilities of the backbone network. This proved effective even in the MPII pose dataset, demonstrating that the method generalizes beyond simple classification to continuous similarity metrics.

Conclusion

Few-shot Metric Learning represents a significant step forward for adaptive retrieval systems. By focusing on the relationship between embeddings rather than just classification boundaries, and by using channel-rectification to prevent overfitting, CRML provides a robust framework for real-world applications where the definition of "similarity" may change.

Future work remains to be done in scenarios where the context of similarity switches entirely, as seen in the more moderate gains on the multi-attribute miniDeepFashion dataset. Additionally, the computational cost of the meta-learning inner loop during inference is a practical consideration for deployment in real-time systems.

Summary updated

BibTeX
@inproceedings{jung2022few,
  author = {Deunsol Jung and Dahyun Kang and Suha Kwak and Minsu Cho},
  title = {{Few-shot Metric Learning: Online Adaptation of Embedding for Retrieval}},
  booktitle = {Asian Conference on Computer Vision (ACCV)},
  year = {2022},
  url = {https://openreview.net/forum?id=iZjahsAH4w},
}
Figure