Example-Based Named Entity Recognition

Morteza Ziyadi, Yuting Sun, Abhishek Goswami, Jade Huang, Weizhu ChenarXiv 2020

Abstract

Traditional Named Entity Recognition (NER) models are often constrained by fixed entity schemas and require extensive retraining for new domains. This paper presents an "example-based NER" framework that treats NER as an entity-agnostic span extraction task. By leveraging a small set of support examples (10-20), the model can identify novel entity types in unseen domains without parameter updates. Our approach achieves significant performance gains in low-data regimes, outperforming existing few-shot methods by over 30% in F1-score.

Introduction

Standard NER models are heavily tied to the specific entity categories present in their training data, such as "Person" or "Location." Adapting these models to custom entities—for instance, specific "Error Codes" or "Game Titles" in a technical support context—typically necessitates large-scale data collection and computationally expensive fine-tuning. This barrier makes NER impractical for many niche applications and non-expert users.

While "few-shot" NER has been proposed as a solution, many existing methods still rely on rigid hierarchical relationships or require substantial target-domain data for adaptation. This research addresses the challenge of true train-free, few-shot NER: enabling a model to recognize entirely novel entity types in an unseen domain using as few as 10 to 20 examples, without any parameter updates or retraining.

Methodology

The proposed framework reframes NER as an entity-agnostic span extraction problem, drawing inspiration from extractive Question Answering (QA). Instead of classifying tokens into predefined categories, the model learns to match spans in a query sentence to labeled examples in a "support" set.

Similarity-Based Span Detection

The architecture utilizes a shared BERT encoder for both the "query" sentence and a set of "support" sentences. Support entities are explicitly marked with boundary tags (<e> and </e>). The model calculates the dot-product similarity between query tokens and the boundary tokens of the support entities to identify potential spans.

Model architecture for example-based NER using shared BERT encoders and similarity matching.

To handle multiple support examples, the authors introduce a soft sentence-level attention mechanism during training to weigh the most relevant support sentences. During inference, a "hard attention" strategy is employed: the model selects the top-$K$ most similar support examples for a given entity type and aggregates their scores. This approach effectively filters noise and allows the model to generalize to new domains out-of-the-box.

Inference and Interpretability

One of the primary advantages of this method is its inherent interpretability. Predictions are derived directly from the similarity to specific support examples provided by the user. This allows for rapid debugging; if the model misidentifies an entity, a user can simply update the support set with better examples rather than retraining the model.

Example-based inference process showing how support examples guide the extraction of novel entities like 'Game' and 'Error Code'.

The final prediction resolves overlapping spans by prioritizing the highest-scoring candidates across all target entity types.

Experimental Evaluation

The model was trained on generic datasets (OntoNotes 5.0 and CoNLL-2003) to learn universal matching capabilities. It was then evaluated on several unseen target domains, including ATIS, MIT Movie/Restaurant Reviews, SNIPS, and a proprietary Microsoft dataset.

Key Results

  • Massive Gains in Low-Data Regimes: With only 10 support examples per entity type, the method achieved a >30% absolute gain in F1-score on target domains compared to state-of-the-art baselines like Neighbor Tagging.
  • Domain Transfer: On the SNIPS GetWeather domain, the F1-score improved from a 30% baseline to 78% using just 10 examples.
  • Data Efficiency: The model's performance with 10-20 examples often exceeds what baseline methods achieve with hundreds of examples. For instance, on MIT Movie Review, the model reached ~40.1 F1 with 10 examples, while the baseline required 500 examples to reach only 8.6 F1.

Discussion and Limitations

The authors explored several alternative strategies that yielded "negative results," providing insight into the model's design. Simple heuristic voting (equal weight for all support examples) resulted in poor precision. Additionally, pre-training BERT by masking entities did not improve performance for unseen types, and word-level prediction was found to be inferior to token-level prediction. These findings underscore the importance of the proposed attention-based scoring and the extractive QA framing.

Conclusion

Example-based NER offers a robust, train-free alternative to traditional NER for few-shot scenarios. By decoupling the model from fixed schemas and focusing on context-based similarity, it enables rapid deployment in new domains. While future work may further refine scoring algorithms and attention mechanisms, the current framework provides a production-friendly, interpretable solution for custom entity extraction.

Summary updated

BibTeX
@misc{ziyadi2020example,
  author = {Morteza Ziyadi and Yuting Sun and Abhishek Goswami and Jade Huang and Weizhu Chen},
  title = {{Example-Based Named Entity Recognition}},
  year = {2020},
  eprint = {2008.10570},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2008.10570},
}
Figure