SpanProto: A Two-stage Span-based Prototypical Network for Few-shot Named Entity Recognition

Jianing Wang, Chengyu Wang, Chuanqi Tan, Minghui Qiu, Songfang Huang, Jun Huang, Ming Gao

Introduction

Named Entity Recognition (NER) is a fundamental task in natural language processing that involves identifying and categorizing entities such as names, locations, and organizations within text. While deep learning has significantly advanced NER, traditional models require vast amounts of labeled data to perform well. Few-shot NER addresses this limitation by attempting to recognize new entity types using only a handful of examples (e.g., 1 to 5 examples per category).

Existing few-shot NER approaches typically treat the problem as a sequence labeling task using the "BIO" (Begin, Inside, Outside) scheme. However, these methods face two primary challenges:

  1. The "O" Class Overload: In most sentences, the majority of tokens do not belong to any entity category (labeled as "O"). This creates a severe class imbalance that can overwhelm the signal from rare entity types.
  2. Label Dependency: Token-wise models often struggle to maintain structural consistency when data is scarce, leading to fragmented or logically inconsistent entity boundaries.

The SpanProto Framework

To overcome these hurdles, the authors introduce SpanProto, a novel two-stage framework that decouples entity boundary detection from classification. By separating "finding the span" from "naming the type," the model avoids the noise associated with non-entity tokens and improves boundary accuracy.

The two-stage architecture of SpanProto, featuring Span Extraction and Mention Classification.

Methods

1. Span Extraction (Finding the "What")

In the first stage, SpanProto uses a Span Extractor to identify potential entity boundaries. Instead of labeling tokens individually, it generates a Global Boundary Matrix. This matrix calculates a score for every possible start-and-end position pair in a sentence. This approach allows the model to focus purely on boundary information, effectively bypassing the rigid rules of token-wise sequence labeling and the imbalance of the "O" class.

Visualization of the Global Boundary Matrix for identifying entity spans.

2. Mention Classification (Naming the "Type")

Once spans are extracted, the Mention Classifier assigns them to a category using Prototypical Learning. The model calculates a "prototype" (a mean representation) for each entity type based on the support set examples.

A key innovation in this stage is Margin-based Learning. In few-shot scenarios, the span extractor often identifies valid entities that do not belong to the current target types (e.g., finding a "Date" when the task only requires "Person" and "Location"). SpanProto introduces a margin-based loss that pushes these "false positive" spans away from all target prototypes in the semantic space, preventing them from being misclassified into the wrong category.

Datasets and Evaluation

SpanProto was evaluated on two major benchmarks:

  • Few-NERD: A large-scale dataset with 66 fine-grained entity types, tested in both "Intra" (within-domain) and "Inter" (cross-domain) settings.
  • CrossNER: A benchmark designed to test cross-domain adaptation across diverse fields like News, Wiki, and Social Media.

Key Results and Insights

SpanProto consistently outperformed strong baselines, including ProtoBERT and DecomMeta, across all tested scenarios:

  • State-of-the-Art Performance: On the Few-NERD (Inter) benchmark, SpanProto achieved an average F1 score of 75.25%, a significant improvement over the previous best of 67.99%.
  • Domain Adaptation: In the CrossNER tasks, the model showed superior flexibility, outperforming baselines by 3-5% F1 on average.
  • Error Reduction: Qualitative analysis confirmed that SpanProto significantly reduces both boundary errors (wrongly identified spans) and category errors (wrongly assigned types) compared to traditional token-wise models.

Conclusion

By decoupling span extraction from mention classification and implementing a margin-based prototypical loss, SpanProto effectively addresses the core challenges of few-shot NER. The framework's ability to handle the "O" class imbalance and filter out irrelevant entities makes it a robust solution for low-resource entity recognition tasks. Future work will focus on improving the memory efficiency of the global boundary matrix and extending the framework to other structured prediction tasks.

Summary updated

BibTeX
@inproceedings{wang2022spanproto,
  author = {Jianing Wang and Chengyu Wang and Chuanqi Tan and Minghui Qiu and Songfang Huang and Jun Huang and Ming Gao},
  title = {{SpanProto: A Two-stage Span-based Prototypical Network for Few-shot Named Entity Recognition}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.227},
}
Figure