Template-Based Named Entity Recognition Using BART

Leyang Cui, Yu Wu, Jian Liu, Sen Yang, Yue Zhang

Abstract

Traditional Named Entity Recognition (NER) systems rely on sequence labeling, which often fails in low-resource or cross-domain scenarios due to fixed label sets. This paper proposes a template-based method that treats NER as a language model ranking problem. By leveraging a pre-trained BART model to score natural language templates, the approach achieves significant improvements in few-shot performance, outperforming standard BERT fine-tuning by over 10% F1 score on several low-resource datasets.

What Problem Does This Paper Address?

Traditional NER systems are typically designed as sequence labeling tasks where models assign tags like B-PER or I-LOC to individual tokens. This paradigm faces two significant challenges:

  1. Label Mismatch: Models trained on one domain (e.g., News with Person/Location/Org) cannot easily adapt to another (e.g., Movie reviews with Actor/Plot/Character) because their output layers are hard-coded to specific label indices.
  2. Data Scarcity: In "few-shot" settings with limited training data, traditional models struggle to transfer knowledge because they treat labels as abstract integers rather than semantically meaningful concepts.
Examples of NER across different domains highlighting the diversity of entity types.

The authors aim to overcome these limitations by framing NER in a way that is flexible enough to handle any entity type without architectural changes.

Methods: NER as Template Ranking

The researchers introduce a Template-Based Method utilizing BART, a sequence-to-sequence (seq2seq) model.

The Core Idea

Instead of tagging tokens, the model evaluates candidate text spans against natural language templates. For a candidate span like "Bangkok," the model constructs templates such as:

  • "Bangkok is a location entity."
  • "Bangkok is a person entity."
  • "Bangkok is not an entity."

Inference as Ranking

During inference, the system enumerates all possible text spans in a sentence (up to a maximum length). For each span, it calculates the log-likelihood score of various entity type templates. The template with the highest score determines the span's classification.

Comparison between traditional sequence labeling and the proposed template-based inference using BART.

Transfer Learning through Semantics

By using natural language words (e.g., "location", "dish") in templates, the model leverages BART's pre-trained knowledge of these concepts. This allows the model to "understand" that a "character" in a movie is semantically related to a "person" in news, facilitating better cross-domain generalization.

Datasets and Evaluation

The approach was evaluated on several benchmarks:

  • CoNLL03: A standard high-resource news dataset.
  • MIT Movie & MIT Restaurant: Domain-specific datasets for testing cross-domain transfer.
  • ATIS: A flight reservation dataset for low-resource testing.

Key Insights

  • Natural Language as a Universal Interface: Mapping abstract labels (like LOC) to natural language words ("location") transforms NER into a semantic task.
  • Continual Learning: New entity types can be added simply by defining new string templates, avoiding the "softmax bottleneck" of fixed output layers.
  • Generative Power: BART's decoder is uniquely suited for this ranking approach as it can directly calculate the probability of specific output sequences.

Key Results

  • Few-Shot Dominance: In low-resource settings, the template-based method significantly outperformed BERT fine-tuning, with F1 score gains of 10.88% on MIT Movie, 15.34% on MIT Restaurant, and 11.73% on ATIS.
  • Competitive Performance: On the high-resource CoNLL03 dataset, the model achieved a 92.55% F1 score, matching the performance of traditional sequence labeling methods.
  • Robustness: Embedding visualizations indicated that the template-based approach produces more domain-independent representations compared to BERT.

Limitations and Future Work

The primary drawback is computational efficiency. Enumerating and scoring every possible span results in $O(n^2)$ complexity relative to sentence length. While the authors mitigated this by limiting span length to 8 tokens, the method remains slower than token-level tagging. Future work may involve automating template discovery and exploring performance on specialized nested NER tasks.

Summary updated

BibTeX
@inproceedings{cui2021template,
  author = {Leyang Cui and Yu Wu and Jian Liu and Sen Yang and Yue Zhang},
  title = {{Template-Based Named Entity Recognition Using BART}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.findings-acl.161},
}
Figure