Abstract
Named Entity Recognition (NER) is a fundamental NLP task typically framed as sequence labeling, which necessitates extensive domain-specific labeled data. We present QaNER, a novel framework that re-imagines NER as an extractive question-answering (QA) task. By prompting pre-trained QA models with natural language queries (e.g., "Who is the person?"), QaNER leverages the broad knowledge captured during QA pre-training. Our approach achieves state-of-the-art performance in zero-shot and few-shot scenarios while maintaining linear computational complexity relative to the number of entity types. Experimental results across three benchmarks demonstrate that QaNER is significantly faster, more robust, and more data-efficient than existing prompt-based NER methods.
Introduction
Traditional NER systems rely on sequence labeling, which requires large-scale annotated datasets for every new domain. While few-shot learning via prompt-based methods has shown promise, existing techniques often suffer from high computational complexity—frequently scaling with the square of the input length—and sensitivity to handcrafted templates. Furthermore, these methods often struggle with zero-shot generalization to unseen entity types.
QaNER addresses these challenges by reformulating NER as extractive QA. Instead of predicting tags for every token, the model identifies entity spans in response to natural language prompts. This shift allows the model to utilize the semantic understanding inherent in models trained on datasets like SQuAD.
Methodology
The core of QaNER is the transformation of the NER task into a span extraction problem. For a given sentence (context) and a target entity type, a prompt is generated.
NER-to-QA Formulation
For each entity type $E$, the system constructs a question such as "What is the [E]?". The model then extracts the corresponding span from the input text $x$. Unlike previous prompt-based methods that can be computationally expensive, QaNER's complexity scales linearly with the number of entity types ($O(m)$), making it much faster for processing long documents.
Key Innovations
- Negative Sampling: To mitigate false positives, QaNER incorporates "unanswerable" questions. If an entity type is absent, the model is trained to point to a null token (e.g.,
[CLS]), a technique inspired by SQuAD 2.0. This significantly reduces the model's tendency to hallucinate entities. - Automated Prompt Generation: To reduce reliance on manual engineering, Masked Language Models (MLM) are employed to generate natural-sounding questions automatically.
- N-Best Decoding: To handle multiple occurrences of the same entity type within a single sentence, an n-best decoding strategy is used to retrieve all valid spans in one pass.
Experimental Results
QaNER was evaluated on three diverse benchmarks: CoNLL03 (news), MIT Movie, and MIT Restaurant. Models were initialized with weights from BERT pre-trained on SQuAD 1.1 and 2.0.
Performance in Few-Shot and Zero-Shot Scenarios
QaNER consistently outperformed baselines like TemplateNER and LightNER, particularly in zero-shot settings where the model has seen no examples of the target domain. With as few as 10 to 50 examples per entity type, QaNER reached performance levels that traditional sequence labeling models only achieve with hundreds of samples.
Efficiency and Robustness
Beyond accuracy, QaNER demonstrated superior inference speed due to its linear scaling. It also showed remarkable robustness; performance remained stable even when prompt wording was slightly altered, indicating that the model relies on the underlying semantics of the question rather than rigid pattern matching.
Conclusion
QaNER provides a robust and efficient framework for few-shot NER by leveraging the strengths of extractive QA models. By treating entity types as natural language questions, the model achieves high data efficiency and generalization. Future work will explore extending this prompting logic to more complex tasks such as nested NER and extractive summarization.
Summary updated