Abstract
Traditional Named Entity Recognition (NER) models are typically designed for domain-specific datasets and limited to fixed predefined types, resulting in difficulty generalizing to new domains. Recently, prompt-based generative methods attempt to mitigate this constraint by training models jointly on diverse datasets and extract specified entities via prompt instructions. However, due to autoregressive structure, these methods cannot directly model entity span and suffer from slow sequential decoding. To address these issues, we propose a novel Span-based Unified NER framework via contrastive learning (SUNER), which aligns text span and entity type representations in a shared semantic space to extract entities in parallel. Specifically, we first extract mention spans without considering entity types to better generalize across datasets. Then, by leveraging the power of contrastive learning and well-designed entity marker structure, we map candidate spans and their textual type descriptions into the same vector representation space to differentiate entities across domains. Extensive experiments on both supervised and zero/few-shot settings demonstrate that proposed SUNER model achieves better performance and higher efficiency than previous state-of-the-art unified NER models.
Introduction
Named Entity Recognition (NER) is a fundamental task in information extraction, identifying and categorizing entities like people, places, or organizations. Traditionally, NER models have been "siloed," trained on specific datasets with fixed labels. This makes it difficult for a model trained on news text to identify specialized entities in medical or technical domains without extensive retraining.
Recently, generative models (like T5 or GPT) have been used to create "unified" NER systems that can handle multiple datasets at once using natural language prompts. However, these generative approaches face two significant hurdles: they are computationally slow due to sequential token generation, and they often struggle with precise entity boundary (span) detection.
The SUNER Framework
To overcome these challenges, we introduce SUNER (Span-based Unified NER). SUNER shifts the paradigm from slow sequence generation to efficient, parallel semantic matching. By using contrastive learning to align text spans with natural language type descriptions, SUNER achieves state-of-the-art performance while being nearly 6x faster than previous generative unified models.
Methodology
The SUNER framework consists of two primary stages designed for maximum generalizability and efficiency:
- Type-Agnostic Span Detection: Using a BERT-based biaffine encoder, the model first identifies all potential "mention spans" in a sentence. By ignoring entity types at this stage, the model learns to identify the structural characteristics of entities, which helps it generalize better across different domains.
- Contrastive Span Classification: This is the core innovation. Instead of using abstract numerical IDs for labels, SUNER uses natural language descriptions of entity types (e.g., "PER: a person, including fictional characters").
As shown in the architecture above, we utilize an Entity Mark Structure where special markers (e.g., [e1]...[/e1]) are inserted around candidate spans. Through contrastive alignment, the model maps these candidate spans and the textual type descriptions into a shared vector space. If a span's vector is semantically close to a specific description vector, it is classified accordingly.
Experimental Results
We evaluated SUNER on a unified corpus of seven diverse benchmarks, including news (CoNLL 2003), biomedicine (GENIA), and nested NER tasks (ACE 2004/2005). The unified corpus encompasses 47 distinct entity categories.
- Accuracy: SUNER outperformed the previous state-of-the-art unified model (PUnifiedNER) by an average of 1.90% F1 score, with particularly strong gains in complex nested datasets (+4.14% on GENIA).
- Zero-Shot Generalization: In zero-shot settings, SUNER achieved a 6.37% absolute increase in F1 score over generative baselines. By understanding the definitions of entity types, it can identify categories it has never seen during training.
- Efficiency: Because SUNER processes all candidate spans in parallel rather than sequentially, it is 5.96x faster than generative unified models, making it suitable for high-throughput real-world applications.
Conclusion
SUNER demonstrates that treating NER as a semantic matching task in a shared vector space is both more accurate and significantly more efficient than generative approaches. By leveraging natural language descriptions as labels, the framework achieves remarkable zero-shot capabilities. Future work will focus on closing the small performance gap between unified models and specialized, dataset-specific encoders.
Summary updated