Abstract
Most Named Entity Recognition (NER) models are limited to sentence-level context due to the input length constraints of models like BERT, causing them to miss crucial document-wide clues. This paper introduces the Span Graph Transformer (SGT), a novel architecture that captures long-range dependencies by linking identical and nested entity spans across an entire document. By leveraging both token-level and span-level contexts, SGT achieves state-of-the-art performance on both flat and nested NER tasks, proving especially powerful in low-resource settings.
Introduction
Named Entity Recognition (NER) is the foundational NLP task of locating and classifying entities (like "Person", "Location", or "Protein") within text. Currently, the state-of-the-art relies heavily on Transformer-based language models like BERT. However, because BERT has a quadratic self-attention complexity, it is typically capped at 512 sub-tokens.
As a result, most NER models process long documents sentence-by-sentence. This creates a massive blind spot: they cannot capture long-range contextual dependencies. For example, an acronym might be clearly defined as a protein in the first sentence of a paper, but appear in a highly ambiguous context later in the document. A sentence-level model is forced to guess, whereas a document-level model can use the earlier context to disambiguate it.
While some recent models try to append neighboring sentences to expand context, they still fail to explicitly model dependencies across an entire document.
Methodology
The authors propose the Span Graph Transformer (SGT), which tackles document-level context in two distinct stages:
1. Token-Level Dependency Extractor
Instead of just appending adjacent sentences, SGT dynamically retrieves the most relevant context sentences from the document for every target sentence. Relevance is scored based on span overlap and inter-sentence distance. The target sentence and its top context sentences are concatenated and fed into BERT to generate context-enriched token embeddings.
2. Span-Level Dependency Extractor
The token embeddings are passed through a biaffine encoder to generate initial span representations. To filter out the massive noise of all possible token combinations, the authors use a constituency parser to extract syntactically valid candidate spans.
3. Span Graph Construction & Graph Transformer
SGT builds a sparse, document-level graph where nodes are candidate spans. It creates edges between nested mentions (within the same sentence) and identical mentions (across different sentences). Finally, a Graph Transformer updates the span representations using a custom relative position encoding that accounts for sentence sharing, nesting depth, and document distance.
Key Insights
- Label Consistency as a Prior: Identical text spans within a single document almost always refer to the same entity type. By hardwiring "identical mention edges" into the graph, the model allows high-confidence mentions to directly pass representational features to ambiguous mentions of the same text elsewhere in the document.
- Sparse Graphs for Efficiency: A fully connected graph of all candidate spans in a document introduces too much noise and scales quadratically. Selectively connecting only nested and identical spans forces the model to focus on the most relevant dependencies, yielding better empirical results.
- Dual-Level Context: Ablation studies show that both token-level context (feeding relevant sentences together into BERT) and span-level context (the Graph Transformer) are necessary. Removing the span-level graph caused a significant 2.87% F1 drop on the complex Genia dataset.
Results
SGT achieved new state-of-the-art results across a robust mix of standard benchmarks:
- Nested NER: Achieved 88.98% F1 (+0.59%) on ACE 2004, 89.15% F1 (+0.95%) on ACE 2005, and a massive 83.36% F1 (+1.83%) on Genia.
- Flat NER: Outperformed previous SOTA with 94.04% F1 (+0.54%) on CoNLL 2003 and 91.91% F1 (+0.57%) on OntoNotes 5.
- Low-Resource Performance: On the distantly supervised BC5CDR dataset, SGT outperformed existing SOTA by 2.31% F1. Notably, it improved recall by 6.57%, demonstrating that document-level features help infer missing entities that distant-supervision dictionaries fail to catch.
Conclusion
The Span Graph Transformer addresses a critical limitation in current NER models by explicitly modeling document-wide span dependencies. By combining dynamic context retrieval with a sparse span graph, SGT effectively leverages global information without the computational burden of dense graphs. Future work may involve integrating the span selection process directly into the model to remove the dependency on external parsers.
Summary updated