Span-based Unified Named Entity Recognition Framework via Contrastive Learning

Hongli Mao, Xian-Ling Mao, Hanlin Tang, Yu-Ming Shang, Xiaoyan Gao

Abstract

Named Entity Recognition (NER) has traditionally relied on dataset-specific models or slow, autoregressive generative frameworks. We introduce SUNER (Span-based Unified NER), a novel framework that treats NER as a semantic matching task between text spans and natural language type descriptions. By employing a parallel contrastive learning approach, SUNER overcomes the efficiency bottlenecks of generative models while improving boundary detection and handling nested entities. SUNER achieves state-of-the-art performance across seven diverse datasets, offering a nearly 6x speedup over previous unified models and significant gains in zero-shot scenarios.

Introduction

Traditional NER models are usually "specialists"—trained on specific datasets with a fixed set of entity types. They struggle to generalize to new domains without expensive retraining. To solve this, recent "Unified NER" models use a generative (seq2seq) approach. However, these models are inefficient due to sequential decoding and often struggle with precise span boundaries and complex relationships like nested entities.

Comparison of NER paradigms: (a) Dataset-specific, (b) Prompt-based Generative, and (c) SUNER (ours).

Methodology

The authors propose SUNER (Span-based Unified NER), which breaks the task into two parallelizable modules:

Span Detection and Classification

Instead of looking for specific types immediately, the model first identifies all potential "mention spans" using a BERT-based biaffine encoder. Subsequently, inspired by contrastive learning paradigms like CLIP, the model maps candidate spans and textual descriptions of entity types into the same vector space, using an InfoNCE loss to align them.

Entity Mark Structure

To handle nested entities, special markers [e] and [/e] are inserted around candidate spans. The positional embeddings of these markers are tied to the original tokens, and a constrained attention mask is used so that markers can "see" the text and each other without disturbing the original text embeddings.

The SUNER architecture, illustrating the raw input processing, entity mark structure, and the contrastive matching between marked span representations and entity type descriptions.

Key Results

SUNER was evaluated on 7 datasets encompassing 47 entity categories. Key findings include:

  • Superior Performance: SUNER outperformed the previous state-of-the-art unified model, PUnifiedNER, by an average of 1.90% F1 score across all supervised datasets.
  • Zero-Shot & Few-Shot Dominance: In zero-shot settings, SUNER showed a 6.37% absolute F1 increase over generative baselines.
  • Inference Speedup: SUNER achieved a 5.96x speedup in inference compared to seq2seq models, making it viable for high-throughput applications.
  • Ablation Success: Removing the "Entity Mark Structure" led to a significant performance drop, proving that modeling inter-span dependencies is critical for complex, nested datasets.

Conclusion

SUNER demonstrates that parallel contrastive learning is a superior paradigm for unified NER, offering both higher accuracy and significantly better efficiency than generative alternatives. Future work will focus on domain-specific pre-training and automated threshold tuning to further enhance cross-domain performance.

Summary updated

BibTeX
@inproceedings{mao2024span,
  author = {Hongli Mao and Xian-Ling Mao and Hanlin Tang and Yu-Ming Shang and Xiaoyan Gao},
  title = {{Span-based Unified Named Entity Recognition Framework via Contrastive Learning}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=GewRC1YPtA},
}
Figure