Few-shot Classification with Hypersphere Modeling of Prototypes

Ning Ding, Yulin Chen, Ganqu Cui, Xiaobin Wang, Hai-Tao Zheng, Zhiyuan Liu, Pengjun Xie · DOI

Abstract

Traditional metric-based few-shot learning (FSL) often represents classes as single-point prototypes, which fails to capture class-level variance and sparsity. We present HyperProto, a novel framework that models class prototypes as hyperspheres. By learning a center and a dynamic radius for each category, HyperProto provides a more expressive geometric representation that adapts to class density. Our approach demonstrates significant performance improvements across diverse benchmarks in Natural Language Processing (NLP) and Computer Vision (CV), offering a robust alternative to point-based or complex statistical distribution models.

Introduction

Few-shot learning (FSL) aims to recognize novel categories from a limited number of labeled examples. Metric-based meta-learning has emerged as a dominant paradigm, typically mapping data into an embedding space where each class is represented by a "prototype"—usually the mean vector of support examples.

However, point-based prototypes are inherently limited. They cannot represent the "spread" or "compactness" of a class. While modeling classes as statistical distributions (e.g., using covariance matrices) can address this, such methods often introduce computational complexity and optimization challenges. HyperProto bridges this gap by using hyperspheres: a representation more expressive than a point but simpler and more stable than a full statistical distribution.

Methodology: Hypersphere Modeling

HyperProto defines each class in the embedding space as a hypersphere characterized by two parameters: a center ($z$) and a radius ($\epsilon$).

The Distance Metric

Instead of measuring the distance to a central point, HyperProto calculates the distance from a query point $f_\phi(x)$ to the surface of the hypersphere: $$M(x, B) = ||f_\phi(x) - z||_2 - \epsilon$$ This metric allows the model to naturally handle points within the sphere (negative distance) via the softmax function, creating a more flexible and "forgiving" decision boundary.

Illustration of the HyperProto framework, showing the transition from initialization to the learned hypersphere representation with center z and radius epsilon.

Dynamic Optimization

Unlike standard prototypes that are statically re-estimated for each episode, HyperProto initializes the center and radius from the support set and then optimizes them through gradient descent. This allows the radius to act as a learnable "area of influence," expanding for sparse classes and contracting for compact ones.

Experiments and Results

The model was evaluated on a wide range of benchmarks to demonstrate its cross-domain efficacy:

  • NLP: FEW-NERD (Named Entity Recognition) and FewRel (Relation Extraction).
  • Computer Vision: miniImageNet and cross-domain transfer to CUB.

Performance Gains

HyperProto consistently outperformed vanilla Prototypical Networks (ProtoNet) and numerous competitive baselines. In NLP tasks, it achieved an 8.33% absolute F1 increase on FEW-NERD (INTRA) and a 21.63% increase on FewRel 2.0 domain adaptation. In computer vision, it improved miniImageNet accuracy by 3.45% over the baseline.

Performance comparison between the baseline ProtoNet and HyperProto across various NLP and Computer Vision benchmarks.

Discussion and Insights

The success of HyperProto stems from its geometric approach to class sparsity. By measuring distance to a surface rather than a point, the model explicitly accounts for the "territory" a class occupies. This learnable sparsity forces the feature encoder to produce representations that reside within the learned "safe zone" of the hypersphere.

Limitations

The primary challenge remains the 1-shot scenario, where estimating an initial radius is difficult due to the lack of multiple points. Additionally, the radius parameter is sensitive to learning rates, often requiring a higher rate than the rest of the network to converge effectively.

Conclusion

HyperProto offers a computationally efficient and geometrically intuitive advancement for few-shot classification. By adding only a single scalar parameter (the radius) per class, it achieves state-of-the-art results in high-shot settings and provides a scalable foundation for future research in non-Euclidean or robust representation learning.

Summary updated

BibTeX
@inproceedings{ding2023few,
  author = {Ning Ding and Yulin Chen and Ganqu Cui and Xiaobin Wang and Hai-Tao Zheng and Zhiyuan Liu and Pengjun Xie},
  title = {{Few-shot Classification with Hypersphere Modeling of Prototypes}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.findings-acl.57},
}
Figure