Nested Named Entity Recognition (Nested NER) is an information extraction subtask that identifies entity mentions that are recursively contained within other entity mentions. Unlike flat NER, which assigns a single label to each token, Nested NER resolves structures where, for example, a [Facility] contains a [Location] that itself contains another [Location], requiring models to output overlapping or hierarchical span trees.
Glossary
Nested NER

What is Nested NER?
Nested NER is the task of identifying named entities that are hierarchically embedded within other entities, moving beyond flat sequence labeling to capture complex, overlapping structures in text.
This task is typically addressed using span-based architectures rather than token-level BIO tagging, as the latter cannot represent overlapping spans. Models like SpanBERT or Biaffine Classifiers enumerate all possible text spans and score them for entity type membership. The primary evaluation metric remains Mention-Level F1, but scoring must account for the correct identification of both the inner and outer entity boundaries and their types.
Key Characteristics of Nested NER
Nested Named Entity Recognition addresses the complexity of real-world text where entities are often embedded within one another, requiring models to move beyond flat, non-overlapping sequence labeling.
Hierarchical Span Overlap
Unlike flat NER, nested NER explicitly handles overlapping entity mentions where a shorter span is fully contained within a longer one. For example, in the phrase "[[University of [California]]] Berkeley", "California" is a Location nested inside the Organization "University of California Berkeley". This requires models to recognize multiple valid label paths for the same tokens.
Layered Decoding Architectures
Standard linear-chain CRF decoders cannot model nested structures. Nested NER architectures employ specialized decoding strategies:
- Layered-CRF: Stacks multiple flat NER layers, with each layer recognizing entities at a different nesting depth.
- Pyramid Models: Process text in a bottom-up fashion, connecting shorter spans into longer ones.
- Span-Based Classification: Enumerates all possible spans up to a maximum length and classifies each independently, naturally resolving overlaps.
Span Enumeration and Filtering
A dominant paradigm for nested NER is to generate all possible text spans (up to a length constraint n) and classify them. Because the number of spans is O(n²), efficient filtering is critical. Techniques include:
- Span Pruning: Using a fast, low-cost scorer (e.g., a simple bilinear layer) to filter out the vast majority of background spans before feeding candidates to a heavier classifier.
- Biaffine Attention: Directly scoring all start-end token pairs in a single matrix operation to identify high-probability entity boundaries.
Genia and ACE-2005 Benchmarks
The standard benchmarks for nested NER are GENIA (biomedical domain) and ACE-2005 (news and broadcast). These datasets contain rich, deeply nested annotations. For instance, a single ACE-2005 sentence can have a Person entity nested inside an Organization entity, which is itself part of a Geopolitical Entity. Performance is measured using mention-level F1, requiring exact boundary and type matches for every nested layer.
Reading Comprehension (MRC) Formulation
A modern approach reformulates nested NER as a Machine Reading Comprehension task. For each entity type, a question is generated (e.g., "Which locations are mentioned?"). The model extracts answer spans directly from the text. Because multiple answers can be extracted independently for each question, this method naturally handles nested structures without complex decoding constraints, leveraging the power of pre-trained question-answering models.
Boundary-Aware Loss Functions
Training nested NER models requires loss functions that account for the boundary sensitivity of overlapping spans. Standard cross-entropy on tokens is insufficient. Effective strategies include:
- Span-Level Cross-Entropy: Applied directly to the enumerated span representations.
- Dice Loss: Optimizes the overlap coefficient between predicted and ground-truth spans, directly targeting the mention-level F1 metric.
- Bipartite Matching Loss: Uses the Hungarian algorithm to find an optimal one-to-one assignment between predicted and gold entity spans before calculating the loss.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about recognizing hierarchically embedded named entities in unstructured text.
Nested Named Entity Recognition (Nested NER) is the information extraction task of identifying named entities that are hierarchically embedded within other named entities in a text. Unlike flat NER, which assigns a single, non-overlapping label to each token, Nested NER acknowledges that a single text span can simultaneously belong to multiple semantic categories at different levels of granularity. For example, in the phrase "the University of Cambridge Department of Engineering," a nested NER system would recognize "University of Cambridge" as an Organization, "Department of Engineering" as a Department (a sub-organization), and the entire phrase "University of Cambridge Department of Engineering" as a larger Organization mention. Architecturally, this is solved using layered decoding strategies, such as treating the problem as a sequence of flat NER layers applied at different granularities, using span-based models that score every possible text span independently, or employing constituency parsing techniques that naturally model the tree-like structure of nested mentions. The core challenge is resolving the overlapping span ambiguity that standard BIO tagging schemes cannot represent.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Mastering nested NER requires understanding the broader ecosystem of sequence labeling, span-based architectures, and evaluation techniques that handle overlapping and hierarchical entity structures.
Span Categorization
A NER paradigm that directly enumerates and classifies arbitrary text spans as entities, bypassing the need for token-level BIO tagging schemes. This approach is naturally suited for nested NER because it can independently score overlapping spans without the structural constraints of a linear-chain CRF. Architectures like Global Pointer and Biaffine Classifiers are common implementations.
BIO Tagging
A token-level annotation scheme where tokens are tagged as Beginning, Inside, or Outside of a named entity span. While foundational for flat NER, standard BIO tagging cannot represent nested entities because each token can only receive a single label. Extensions like BIOHD (with Head and Dependent tags) or multi-layered BIO schemes are required to encode hierarchical entity structures.
Fine-Grained Entity Typing (FET)
The task of assigning very specific semantic types from a large, hierarchically organized type ontology. FET and nested NER are deeply complementary: a nested NER system might identify 'San Francisco' as both a Location and a Settlement, while FET provides the deep type hierarchy (City → Municipality → PopulatedPlace) that defines the nesting structure.
Mention-Level F1
The primary evaluation metric for NER that computes the harmonic mean of precision and recall based on exact matches of entity span boundaries and their type classifications. For nested NER, evaluation is more complex—metrics must account for hierarchical matches where a span is correctly identified but its parent-child relationship is wrong. Variants like loose F1 (partial boundary overlap) and strict F1 (exact span and type match) are commonly reported.
Semi-Markov CRF
A segment-level sequence model that directly models the probability of entire entity spans rather than individual tokens. Unlike linear-chain CRFs, Semi-Markov CRFs can naturally handle segment-level features and are more amenable to nested structures by allowing overlapping segments with different labels. However, exact inference becomes computationally expensive for deep nesting hierarchies.
Global Pointer
A NER architecture that uses a multiplicative attention mechanism to directly identify entity spans by scoring all possible start-end token pairs without a CRF layer. For nested NER, Global Pointer is particularly effective because it can predict multiple entity types independently—each type head scores all spans, allowing the same token to participate in multiple overlapping entities of different types.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us