Multi-Task Transformer with Relation-Attention and Type-Attention for Named Entity Recognition

Ying Mo, Hongyin Tang, Jiahao Liu, Qifan Wang, Zenglin Xu, Jingang Wang, Wei Wu, Zhoujun Li

Abstract

Named Entity Recognition (NER) is a fundamental task in natural language processing, traditionally categorized into flat, nested, and discontinuous types. While generative sequence-to-sequence models have recently been employed to unify these tasks, they often struggle with precise boundary detection and accurate entity typing. This paper presents a Multi-task Transformer based on the BART architecture that introduces two novel mechanisms: Relation-Attention and Type-Attention. By explicitly modeling token relationships and leveraging external knowledge from Wikipedia, the proposed model achieves state-of-the-art performance across eight benchmark datasets, demonstrating the efficacy of structural and semantic priors in generative NER frameworks.

Introduction

Named Entity Recognition (NER) involves identifying and categorizing spans of text into predefined categories such as persons, locations, or organizations. Historically, NER research has been fragmented into three distinct sub-problems:

  1. Flat NER: Entities are non-overlapping (e.g., "New York").
  2. Nested NER: Entities are contained within one another (e.g., "[Bank of [China]]").
  3. Discontinuous NER: Entities are separated by intervening words (e.g., "aching in the shoulders").

While traditional sequence labeling and span-based methods have been tailored to specific sub-problems, recent trends have shifted toward generative (seq2seq) models to provide a unified framework. However, these models face significant hurdles. Because they generate output token-by-token, they often lose the structural dependencies required for precise boundary detection and struggle to map spans to correct entity types without explicit guidance. This research addresses these limitations by re-introducing structural awareness and external semantic knowledge into the generative process.

Methodology

The proposed architecture is built upon the BART-Large Transformer model, enhanced with a multi-task learning objective and two specialized attention mechanisms.

Relation-Attention

To improve boundary detection, the model performs a secondary task of predicting relationships between token pairs. For any two tokens, the model predicts a relation such as "Begin-End," "Inside," or "None." These predictions are facilitated by Conditional Layer Normalization (CLN), which models the complex interactions between token pairs. The resulting relation features are processed through a Convolutional Neural Network (CNN) and injected into the decoder's cross-attention layers. This mechanism forces the generative decoder to remain cognizant of the structural boundaries of entities during the generation process.

Type-Attention

To refine entity classification, the researchers integrated external knowledge from Wikipedia. By calculating prior distributions for entity types based on Wikipedia data, the model builds weighted representations of what a "prototype" entity for a given category (e.g., "Location") looks like. This external knowledge is fused into both the encoder and decoder via self-attention, providing a semantic anchor that helps the model correctly map spans to types, even in ambiguous contexts.

Multi-Task Objective

The model is trained with a joint loss function that combines the standard generation loss with the relation prediction loss. Experimental results indicated that the optimal performance is achieved when the generation task is prioritized, specifically using a weight of $w=0.3$ for the auxiliary relation task, suggesting that the relation prediction serves as a vital structural guide rather than a primary output.

Experiments and Results

The model was evaluated on eight benchmark datasets covering all three NER types: CoNLL-2003 and OntoNotes 5.0 (Flat); GENIA, ACE 2004, and ACE 2005 (Nested); and CADEC, ShARe13, and ShARe14 (Discontinuous).

Performance Highlights

  • Nested NER: On the GENIA dataset, the model outperformed previous sequence labeling and span-based methods by 5.07% and 4.67% in F1 score, respectively. This demonstrates the model's superior ability to handle overlapping structures.
  • Flat NER: The model achieved an F1 score of 93.44 on CoNLL-2003, surpassing previous state-of-the-art generative models.
  • Discontinuous NER: While the gains were more marginal compared to specialized multi-stage models, the framework showed consistent improvements, proving its versatility across complex entity structures.

Discussion

The success of this Multi-task Transformer highlights a critical insight: while generative models offer flexibility, they benefit significantly from "classification-like" structural constraints. By re-introducing boundary awareness through Relation-Attention, the model regains the structural precision of traditional sequence labeling without losing the benefits of a unified generative framework. Furthermore, the use of Wikipedia as a semantic prior demonstrates that external knowledge can effectively compensate for limited training data in complex typing tasks.

Conclusion

This research presents a robust unified framework for NER that bridges the gap between generative flexibility and structural precision. By integrating Relation-Attention and Type-Attention, the Multi-task Transformer sets new benchmarks for flat and nested NER. Future work will focus on improving performance for discontinuous entities, exploring few-shot learning capabilities, and scaling the architecture with larger pre-trained language models.

Summary updated

Abstract

Named entity recognition (NER) is an important research problem in natural language processing. There are three types of NER tasks, including flat, nested and discontinuous entity recognition. Most previous sequential labeling models are task-specific, while recent years have witnessed the rising of generative models due to the advantage of unifying all NER tasks into the seq2seq model framework. Although achieving promising performance, our pilot studies demonstrate that existing generative models are ineffective at detecting entity boundaries and estimating entity types. This paper proposes a multi-task Transformer, which incorporates an entity boundary detection task into the named entity recognition task. More concretely, we achieve entity boundary detection by classifying the relations between tokens within the sentence. To improve the accuracy of entity-type mapping during decoding, we adopt an external knowledge base to calculate the prior entity-type distributions and then incorporate the information into the model via the self and cross-attention mechanisms. We perform experiments on an extensive set of NER benchmarks, including two flat, three nested, and three discontinuous NER datasets. Experimental results show that our approach considerably improves the generative NER model’s performance.
BibTeX
@inproceedings{mo2023multi,
  author = {Ying Mo and Hongyin Tang and Jiahao Liu and Qifan Wang and Zenglin Xu and Jingang Wang and Wei Wu and Zhoujun Li},
  title = {{Multi-Task Transformer with Relation-Attention and Type-Attention for Named Entity Recognition}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=7zYchi1aZ0},
}
Figure