Handling Nested and Overlapping Entities
You'll learn how to identify entities that contain other entities or share boundaries, a challenging scenario standard NER approaches struggle with.
The Problem with Simple NER
Traditional NER systems (like those using IOB tagging from earlier lessons) assume each token belongs to exactly one entity. But real text is messier:
- Nested entities: "The [Bank of [England]]" — "England" is a location inside the organization "Bank of England"
- Overlapping entities: "[New York] [University]" could be tagged as both a location (New York) and an organization (New York University)
Standard token-classification approaches can only assign one label per token, missing these complex patterns.
Solutions: Beyond Flat Sequences
Span-Based Approaches
Instead of labeling each token, these models consider all possible spans (subsequences) of text. For "Bank of England", you'd evaluate:
- "Bank" (not an entity)
- "Bank of" (not an entity)
- "Bank of England" (organization!)
- "of England" (not an entity)
- "England" (location!)
This allows both the outer organization and inner location to be recognized simultaneously.
Multi-Head Classification
Use multiple independent classification heads on your Transformer model — one might detect organizations while another detects locations. Each head can label tokens independently, capturing overlapping entities.
Why This Matters
Medical texts often nest entities ("left [ventricular [muscle]]"), and legal documents reference complex organizational structures. These domains need models that see multiple entity layers simultaneously rather than forcing a single flat interpretation.
Key Takeaway: Nested and overlapping entities require span-based models that evaluate all text subsequences or multi-head architectures that allow multiple simultaneous labels, moving beyond the one-label-per-token limitation of traditional sequence tagging.