BaseTransformers: Attention over base data-points for One Shot Learning

Mayug Maniparambil, Kevin McGuinness, Noel O'ConnorarXiv 2022

TL;DR

BaseTransformers improves one-shot classification by refining the noisy feature representation of a single novel instance using a cross-attention mechanism over semantically similar examples from a large base dataset. By treating novel prototypes as a "part-based composition" of robust, well-supported base features, the model achieves state-of-the-art results on major benchmarks like mini-ImageNet and CUB.

What Problem Does This Paper Address?

In few-shot learning, the goal is to recognize new categories from just a handful of examples. The most extreme case is one-shot learning, where only a single image (the "support instance") is provided for a new class.

The authors identify a fundamental hurdle: feature encoders are typically pre-trained on a "base" dataset. When these encoders encounter a "novel" class from a different distribution, the resulting feature representation is often noisy and poor. Estimating a class "prototype" (the average representation of a category) from a single noisy sample is an ill-posed problem. While previous work tried to solve this by assuming class distributions are simple Gaussians, this paper argues that we can do better by explicitly "borrowing" high-quality feature parts from the well-supported base dataset.

Methods

The core of the proposal is the BaseTransformer, a module that uses a cross-attention mechanism to adapt novel support instances.

  1. Pre-training with InfoNCE: To prevent "supervision collapse" (where the encoder becomes too specialized to base classes), the authors train the encoder using a combination of standard cross-entropy and an auxiliary contrastive loss (InfoNCE).
  2. Semantic Querying: For a given novel support instance, the system identifies the $k$ most semantically similar classes in the base dataset. This is done using external knowledge like WordNet LCH-similarity, BERT embeddings of class labels, or category attributes.
  3. Cross-Attention Mechanism: The novel support instance acts as the Query ($Q$), while the features of the closest base instances act as the Keys ($K$) and Values ($V$).
  4. Part-based Composition: Unlike standard methods that use 1D global vectors, BaseTransformers use 2D feature maps. This allows the model to perform spatial, part-based comparisons. It learns to attend to relevant regions of base instances to "compose" a more robust prototype for the novel class.
The BaseTransformer architecture uses cross-attention to aggregate base features into a robust novel prototype.

Datasets

The authors evaluated their method on three standard few-shot learning benchmarks:

  • mini-ImageNet: A subset of ImageNet with 100 classes.
  • tiered-ImageNet: A larger, more challenging subset with 608 classes, split to ensure a larger distribution shift between base and novel categories.
  • CUB (Caltech-UCSD Birds 200): A fine-grained dataset of 200 bird species, where visual differences are subtle.

Key Insights and Ideas

  • The "Centaur" Analogy: The authors hypothesize that novel classes are often compositions of parts found in base classes. For example, a "centaur" prototype can be robustly constructed by attending to the torso of a human and the legs of a horse—both of which are well-represented in a base dataset.
Figure 1: BaseTransformers construct robust novel class prototypes by attending to and ag- gregating semantically similar regions of the well supported base data feature space instead of using the noisy novel prototype as in Prototypical Networks [28].
  • Well-Supported vs. Under-Supported: Base data features are "well-supported" because they are calculated from hundreds of examples per class, making them closer to the ground truth distribution. Novel one-shot features are "under-supported" and noisy. Borrowing from the former stabilizes the latter.
  • Semantic vs. Visual Similarity: The authors found that using semantic information (like class labels and WordNet) to find "donor" base classes works better than relying solely on visual similarity in the feature space, especially for deeper encoders.

Key Results

BaseTransformers achieved state-of-the-art (SOTA) results in the inductive one-shot setting across all three datasets:

  • mini-ImageNet: Reached 70.88% accuracy (ResNet-12), a significant jump over previous transformer-based methods like FEAT (66.78%).
  • tiered-ImageNet: Achieved 72.46% accuracy.
  • CUB: Reached 82.27% accuracy.

Interestingly, the performance gains were much more pronounced in the 1-shot setting than the 5-shot setting. The authors hypothesize that with 5 samples, the initial prototype is already a decent estimate of the true distribution, leaving less room for improvement via the BaseTransformer.

Table 1: 5-way 1-shot and 5-way 5-shot classification accuracy (%) on miniImageNet dataset using ResNet-12 and Conv4-64 backbones. 95% confidence intervals reported. The numbers in bold are the best performing methods for the corresponding setting.

Limitations and Future Work

  • Querying Bottleneck: The quality of the refined prototype is heavily dependent on the querying function. In "Oracle" experiments (where the model is told exactly which base classes are most similar), performance jumped even higher (e.g., to 76.55% on tiered-ImageNet). This suggests that the current semantic querying is a bottleneck.
  • Diminishing Returns: The method provides less benefit as the number of shots increases (e.g., 5-shot or more), as the internal class statistics become more reliable on their own.
  • Future Directions: The authors suggest that searching for an optimal, perhaps learnable, querying function is a promising path for future research.

Summary updated

BibTeX
@misc{maniparambil2022basetransformers,
  author = {Mayug Maniparambil and Kevin McGuinness and Noel O'Connor},
  title = {{BaseTransformers: Attention over base data-points for One Shot Learning}},
  year = {2022},
  eprint = {2210.02476},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.02476},
}
Figure