---
title: Query-Based Named Entity Recognition
url: https://www.emergentmind.com/topics/query-based-named-entity-recognition
type: topic
---

# Query-Based Named Entity Recognition

Query-Based Named Entity Recognition (Query-Based NER) denotes a family of NER formulations in which entity extraction is conditioned on an explicit query signal rather than only on a fixed token-label inventory. In the literature, that query signal has taken several forms: a natural-language question such as “which person is mentioned in the text?”, a descriptive type prompt, a weighted feature vector derived from a CRF-style model, a bank of learnable instance queries, or a token-centered latent query tied to a proposed start position [1908.09138] [1910.11476] [1806.04411] [2203.10545] [2204.11467]. Across these variants, the core idea is stable: the target entity notion is supplied or instantiated at query time, and the model extracts spans, entities, or structured entity hypotheses conditional on that query. This framing has been used to address nested and overlapping entities, long-tail entity classes, low-resource supervision, multimodal grounding, and large-label-space extraction.

## 1. Conceptual scope and historical development

An early precursor appears in “Named Entity Recognition with Extremely Limited Data” [1806.04411], which introduces **Named Entity Search (NES)**. NES reframes NER as search under extreme label scarcity: the **entity class is the query**, each token occurrence is treated as a **document**, token features are treated as **terms**, and ranking replaces conventional sequence labeling. The paper makes the formulation explicit through the linear scoring function
\[
p(Q \mid x) = \sum_{k=1}^{K} Q_k f_k(x) = \vec{Q}\cdot \vec{f}(x),
\]
where the target entity class is represented by a query vector and each token occurrence by a feature vector [1806.04411]. This was not a modern MRC-style method, but it established a retrieval-oriented view in which the entity type is supplied at query time rather than fixed in advance.

The canonical MRC-style turn appears in 2019. “Query-Based Named Entity Recognition” [1908.09138] and “A Unified MRC Framework for Named Entity Recognition” [1910.11476] both recast NER as answering a query for each entity type. A representative example is to formalize `PER` extraction as answering “which person is mentioned in the text?” [1910.11476]. These papers argue that sequence labeling struggles with overlapping or nested entities because one token can only receive one label at a time, whereas independent type-conditioned extraction allows the same token to participate in answers to multiple queries [1908.09138].

Subsequent work broadened what counts as a “query.” “Parallel Instance Query Network for Named Entity Recognition” [2203.10545] replaces manually written type-specific natural-language questions with **learnable instance queries**. “Local Hypergraph-based Nested Named Entity Recognition as Query-based Sequence Labeling” [2204.11467] uses a different notion again: the query is a **token-centered contextual representation** associated with a proposed start token. More recent multimodal systems use query-guided set prediction or text-guided learned queries rather than human-authored questions [2407.21033] [2603.17314].

A concise taxonomy emerging from these papers is as follows.

| Branch | Query representation | Representative papers |
|---|---|---|
| Retrieval-oriented NES | Weighted feature vector over token features | [1806.04411] |
| MRC-style Query-Based NER | Natural-language type question or description | [1908.09138], [1910.11476] |
| Multi-question MRC | Multiple type queries jointly encoded | [2205.05904] |
| Learned-query set prediction | Global learnable instance/entity queries | [2203.10545], [2407.21033], [2603.17314] |
| Query-based sequence labeling | Start-token-centered latent query | [2204.11467] |
| Generative prompt-based NER | Type-specific prompt instruction | [2304.10428] |

This diversity is important because “query-based NER” is not a single architecture class. A common misconception is to equate it only with MRC over natural-language questions. The literature here suggests a broader definition in which the query can be symbolic, descriptive, learned, retrieval-based, or latent, so long as extraction is explicitly conditioned on that query.

## 2. Canonical MRC-style formulation

In the MRC-style formulation, the input text is
\[
X=\{x_1,x_2,\ldots,x_n\},
\]
and for each entity type \(y \in Y\), a corresponding query \(q_y\) is constructed [1908.09138] [1910.11476]. The model is then given the query and the context jointly, typically in BERT format
\[
[\mathrm{CLS}], q_y, [\mathrm{SEP}], X, [\mathrm{SEP}],
\]
and must extract the answer span or spans in the context that satisfy the query [1908.09138].

The simplest version, in “Query-Based Named Entity Recognition” [1908.09138], uses BERT plus start/end prediction. For each token in the context, the model predicts whether it is a **start** or **end** position of the answer. The paper uses **Dice loss**
\[
L_{dice}=1-\frac{2\sum_{i=0}^{n} p_i g_i+\lambda}{\sum_{i=0}^{n} p_i^2+\sum_{i=0}^{n} g_i^2+\lambda}
\]
to address the severe class imbalance inherent in start/end prediction [1908.09138]. Its decoder is simple: if more than one start is predicted, it selects the one with the smallest index; if more than one end is predicted, it selects the one with the largest index; if either is missing, it returns `NULL` [1908.09138]. This design was sufficient to demonstrate large gains on nested benchmarks, but it also exposed a limitation of the early formulation: the described decoding procedure is closer to single-answer QA than to full multi-span extraction.

“A Unified MRC Framework for Named Entity Recognition” [1910.11476] addresses that limitation by decomposing prediction into three supervised subproblems: token-level start prediction, token-level end prediction, and **start-end span matching**. The core components are
\[
P_\text{start}=\text{softmax}_\text{each row}(E\cdot T_\text{start}), \qquad
P_\text{end}=\text{softmax}_\text{each row}(E\cdot T_\text{end}),
\]
followed by a pairwise matching classifier over candidate start/end embeddings [1910.11476]. The total loss is
\[
\mathcal{L}=\alpha\mathcal{L}_\text{start}+\beta\mathcal{L}_\text{end}+\gamma\mathcal{L}_\text{span}.
\]
This formulation supports multiple spans for a queried type and is explicitly presented as a **unified framework** for both flat and nested NER [1910.11476].

The significance of the MRC formulation lies in two repeated claims across the literature. First, it injects **label semantics** because the entity type is represented as language rather than as an opaque class index. Second, it handles overlap across different categories naturally because extraction for different types is performed by answering independent queries [1908.09138] [1910.11476]. This suggests that the conceptual gain is not merely architectural; it is a change in task formulation from token tagging to query-conditioned extraction.

## 3. Query design and semantic conditioning

Query design is a central variable in Query-Based NER. The literature compares natural-language questions, short descriptive prompts, keyword labels, pseudo queries, index queries, annotation-guideline queries, and type descriptions.

“Query-Based Named Entity Recognition” [1908.09138] compares three query types on Chinese OntoNotes: **index query**, **pseudo query**, and **natural language query**. Reported F1 scores are **81.14** for index queries, **81.82** for pseudo queries, and **82.11** for natural-language queries [1908.09138]. The paper interprets this as evidence that richer query wording carries informative prior knowledge about the target entity type.

“A Unified MRC Framework for Named Entity Recognition” [1910.11476] studies query construction even more systematically. On OntoNotes 5.0, it compares **position index of labels** (**88.29**), **keywords** (**89.74**), **Wikipedia** (**89.66**), **rule-based template filling** (**89.30**), **synonyms** (**89.92**), **keywords + synonyms** (**90.23**), and **annotation guideline notes** (**91.11**) [1910.11476]. The best-performing queries are the dataset’s own annotation guideline notes, such as “Find organizations in the text, including companies, agencies and institutions” [1910.11476]. This result is important because it shows that query quality is not reducible to mere presence of a label name; annotation-specific semantic content matters.

The same pattern appears in multimodal query-grounded MNER. “MNER-QG” [2211.14739] compares four query forms: a keyword only query, a rule-based template, a Wikipedia definition, and a **keyword + annotation** description such as “Organization: Include club, company, government party, school government, and news organization.” The paper reports that the fourth form performs best on both MNER and query grounding [2211.14739].

A broader survey perspective reinforces this interpretation. “Recent Advances in Named Entity Recognition: A Comprehensive Survey and Comparative Study” [2401.10825] does not define Query-Based NER as a standalone category, but it treats **prompt-based**, **template-based**, and **description-based** NER as closely related paradigms. Its synthesis is that these methods matter especially when entity types are represented through natural-language definitions, descriptions, prompts, or templates rather than fixed symbolic labels [2401.10825].

The cumulative implication is that query wording is not a superficial interface detail. It is part of the supervision signal. This also creates a practical tension: natural-language descriptions can improve generalization and disambiguation, but they introduce **query engineering** as a modeling variable.

## 4. Architectural diversification beyond single-query MRC

The single-query-per-type architecture is only one branch of Query-Based NER. Several later systems modify the unit of querying, the number of queries per pass, or the decoding regime.

“NER-MQMRC: Formulating Named Entity Recognition as Multi Question Machine Reading Comprehension” [2205.05904] proposes **multi-question MRC**. Instead of creating \(k\) separate examples per text for \(k\) entity types, it concatenates all questions in one BERT input:
\[
[\mathrm{CLS}] \; \text{text tokens} \; [\mathrm{SEP}] \; q_1 \; [\mathrm{ENT}] \; q_2 \; [\mathrm{ENT}] \; \cdots \; q_k \; [\mathrm{SEP}].
\]
The model extracts an embedding for each entity via its associated `[ENT]` marker, combines it with every token embedding through element-wise product, and predicts BIO labels for each token-entity pair with
\[
label_j = \argmax \left( \text{softmax}(W_{bio}(t_j \odot ent_i)) \right),
\]
optimized by
\[
L_{total} = \frac{1}{k \cdot n} \sum_{i=1}^{k} \sum_{j=1}^{n} L^{ce}_{i,j}.
\]
Empirically, it reports average **2.5 times faster training** and **2.3 times faster inference** than single-question MRC, while improving F1 by **+0.41**, **+0.32**, and **+0.27** on AE-Pub, Ecommerce5PT, and Twitter respectively [2205.05904].

“Parallel Instance Query Network for Named Entity Recognition” [2203.10545] moves further away from manually written type-specific queries. It introduces a fixed set of **learnable instance queries**
\[
I \in \mathbb{R}^{M \times h},
\]
encoded jointly with the sentence. Each query predicts one entity by jointly predicting left boundary, right boundary, and type. Training uses a **one-to-many Linear Assignment Problem** solved with the Hungarian algorithm, with assignment cost
\[
Cost_{ik} = -\left(P^t_{iY^t_k} + P^l_{iY^l_k} + P^r_{iY^r_k}\right).
\]
This model supports nested NER naturally because multiple queries can predict overlapping spans [2203.10545]. The paper reports new state of the art on nested benchmarks, including **88.14 F1** on ACE04, **87.42** on ACE05, **81.77** on GENIA, **84.50** on KBP17, and **94.04** on NNE, while also yielding **2.16×** speedup on ACE04 and **30.46×** speedup on NNE relative to type-specific MRC [2203.10545].

“Local Hypergraph-based Nested Named Entity Recognition as Query-based Sequence Labeling” [2204.11467] defines the query differently. It first proposes start-token candidates, then uses a **start-token-centered query representation** \(t_{i^*}^q\) to initialize an LSTM that generates a local hypergraph over the suffix beginning at that token:
\[
C_0 = h_0 = t_{i^*}^q.
\]
The local label space uses \(I\), \(O\), and \(E\)-[entity-type] nodes, with paths from a fixed \(B\)-node to an \(E\)-node representing extracted entities [2204.11467]. This avoids \(O(n^2)\) span proposal and removes an explicit maximum entity length. The reported F1 scores are **88.23** on ACE04, **87.40** on ACE05, **82.03** on GENIA, and **86.03** on KBP2017 [2204.11467].

Taken together, these architectures show that the “query” in Query-Based NER can operate at different granularities: one query per type, multiple type queries per text, one query per entity instance, or one query per proposed start token. This suggests that the central abstraction is conditional extraction, not any single interface form.

## 5. Generative and multimodal extensions

Generative large-language-model formulations reinterpret Query-Based NER as prompt-conditioned generation rather than extractive span prediction. “GPT-NER: Named Entity Recognition via Large Language Models” [2304.10428] decomposes NER into one prompt per entity type, with prompts of the form “The task is to label [Entity Type] entities in the given sentence.” Instead of predicting tags or spans directly, it asks the model to reproduce the sentence while surrounding target entities with `@@` and `##`; for example, `Columbus is a city` becomes `@@Columbus## is a city` for location extraction [2304.10428]. To counter hallucinated entities, GPT-NER adds a **self-verification** stage that asks the model whether an extracted span actually belongs to the queried type [2304.10428]. On full test sets, the best GPT-NER variant remains below supervised MRC baselines—for example, **90.91** vs **93.04** on CoNLL2003 and **82.20** vs **91.11** on OntoNotes5.0—but it is markedly stronger in very low-resource settings, reaching about **60 F1** with only **8 examples** on CoNLL2003 while the supervised comparison is around **0** [2304.10428].

Multimodal work extends the query to align textual extraction with visual evidence. “MNER-QG: An End-to-End MRC framework for Multimodal Named Entity Recognition with Query Grounding” [2211.14739] turns each sentence-image pair into a set of query-conditioned MRC instances, one per entity type. The same query conditions both textual span extraction and a query grounding module that predicts an image region relevant to the entity type [2211.14739]. The total loss is
\[
\mathcal L = \omega_f \mathcal L_{QG} + \lambda_1 \mathcal L_{ED} + \lambda_2 \mathcal L_{ESP},
\]
combining grounding, existence detection, and entity span prediction [2211.14739]. Reported MNER F1 reaches **74.70** on Twitter2015 and **86.94** on Twitter2017, with ablations showing that removing query grounding hurts performance on both datasets [2211.14739].

A second multimodal trajectory replaces manual type questions with learned entity queries and set prediction. “Multi-Grained Query-Guided Set Prediction Network for Grounded Multimodal Named Entity Recognition” [2407.21033] uses **type-grained queries** derived from prompts together with **learnable entity-grained queries**, then predicts an unordered set of entity quadruples under Hungarian matching [2407.21033]. “A Proposal-Free Query-Guided Network for Grounded Multimodal Named Entity Recognition” [2603.17314] uses a bank of randomly initialized learnable queries \(\mathbf{Q} \in \mathbb{R}^{N_q \times d}\), refines them by attending to text, and decodes entity span, class, and box jointly [2603.17314]. These models are not MRC in the classical sense, but they preserve the query-based principle: extraction is driven by query representations that are refined by and interact with the input.

These extensions indicate that Query-Based NER has become a bridge concept between extractive QA, generative prompting, multimodal grounding, and DETR-style set prediction. A plausible implication is that the field has expanded from “query as natural-language type description” to “query as a learned entity hypothesis.”

## 6. Empirical profile, strengths, limitations, and ongoing ambiguities

The empirical strengths of Query-Based NER recur across distinct formulations. On nested benchmarks, the gains over sequence labeling are especially large. “Query-Based Named Entity Recognition” reports **84.14 F1** on ACE 2004 and **86.88** on ACE 2005, improving over BERT Tagger by **+4.46** and **+6.47** respectively [1908.09138]. “A Unified MRC Framework for Named Entity Recognition” reports **85.98** on ACE04, **86.88** on ACE05, **83.75** on GENIA, and **80.97** on KBP2017, with particularly large improvements on GENIA (**+5.44**) and KBP2017 (**+6.37**) over prior state of the art [1910.11476]. In zero-shot transfer from CoNLL03 to OntoNotes 5.0, the same paper reports **72.34** for BERT-MRC versus **31.87** for BERT-Tagger, which strongly suggests that natural-language label descriptions help when the label vocabulary changes [1910.11476].

Low-resource and long-tail settings are another recurring motivation. NES was explicitly designed for “extremely limited data,” asking whether “NER-style labeling” is possible with “tens of labels,” and it showed that simplifying a CRF to a retrieval-style query causes only small degradation on CoNLL while supporting interactive search for long-tail classes such as *meteorites* or *mammals cloned* [1806.04411]. Its evaluation also introduced **unique average precision (uAP)** so that repeated mentions of the same entity do not dominate list-oriented retrieval [1806.04411]. GPT-NER likewise shows a sharp low-resource advantage, though under a very different generative setup [2304.10428].

At the same time, the limitations are equally consistent. The classical MRC formulation usually requires **one pass per entity type**, so inference cost scales with label set size [1908.09138] [2211.14739]. Query wording matters: natural-language questions, guideline notes, or annotations outperform weaker identifiers, and multimodal performance depends on informative type descriptions [1908.09138] [1910.11476] [2211.14739]. Learned-query systems reduce manual prompt engineering but introduce other costs, including latent-query interpretability, query-count hyperparameters, and matching-based training complexity [2203.10545] [2407.21033] [2603.17314]. Some models expose formulation-specific brittleness: NER-MQMRC is sensitive to entity ordering unless order is shuffled during training, with average F1 dropping by **12.33%** if order is fixed during training and shuffled at inference [2205.05904]; NES requires large token-level indexes, with NER features on AQUAINT occupying **158 GB** [1806.04411]; early BERT Query decoding is heuristic and effectively single-span in the paper’s short version [1908.09138].

The term itself also remains somewhat unstable. The 2024 survey notes that “Query-Based NER” is not explicitly defined there, and nearby paradigms are discussed mainly under **prompt-based LLM NER**, **template-based NER**, and **description-based zero-shot NER** rather than as a standalone category [2401.10825]. This suggests that the field contains at least two overlapping usages. In a narrow sense, Query-Based NER refers to MRC-style entity-type questions over text. In a broader sense, it includes any NER system in which extraction is governed by an explicit query representation—human-authored, retrieval-derived, prompt-based, or learned.

The literature therefore supports a broad but technically coherent understanding. Query-Based NER is not defined by a single decoder or a single encoder architecture. It is defined by the decision to make the target entity notion explicit as a query and to condition extraction on that query. Under that definition, retrieval-style NES [1806.04411], MRC-style span extraction [1908.09138] [1910.11476], multi-question MRC [2205.05904], learned instance-query systems [2203.10545], token-centered query-based sequence labeling [2204.11467], prompt-based generation [2304.10428], and query-guided multimodal grounding frameworks [2211.14739] [2407.21033] [2603.17314] all belong to the same intellectual lineage.

Source: https://www.emergentmind.com/topics/query-based-named-entity-recognition