Inferensys

Glossary

Nested NER

Nested Named Entity Recognition (NER) is the task of identifying named entities that are hierarchically embedded within other entities, such as a street name inside a facility mention.
Product manager reviewing autonomous task execution dashboard on laptop, completed tasks visible, casual work session.
HIERARCHICAL ENTITY RECOGNITION

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.

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.

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.

HIERARCHICAL ENTITY STRUCTURES

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.

01

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.

02

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.
03

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.
04

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.

05

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.

06

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.
NESTED NER

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.

Prasad Kumkar

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.