SpanBERT modifies the standard BERT pre-training objective by masking random contiguous spans of tokens rather than individual subword tokens. The model is trained to predict the entire masked span using only the representations of the tokens at the span's boundaries—the start and end tokens—combined with a relative position embedding. This span boundary objective forces the model to learn compositional span representations without relying on the individual tokens within the span itself.
Glossary
SpanBERT

What is SpanBERT?
SpanBERT is a pre-training method for BERT that masks contiguous spans of tokens and predicts them using span boundary representations, optimizing the model for span-level tasks like coreference resolution.
This architecture is particularly effective for coreference resolution and other tasks requiring reasoning over entity mentions. By learning to represent spans based on their surrounding context, SpanBERT captures the semantic properties of multi-word expressions. The model also retains the next-sentence prediction objective from BERT but applies it to contiguous text segments, further reinforcing discourse-level understanding essential for linking mentions across sentences.
Key Features of SpanBERT
SpanBERT introduces critical modifications to the standard BERT pre-training objective, specifically engineered to produce superior representations for span-level tasks like coreference resolution.
Contiguous Span Masking
Unlike standard BERT which masks random individual tokens, SpanBERT masks contiguous random spans of text. This forces the model to rely on the structural context of the entire span rather than memorizing local collocations. By masking full noun phrases or entity mentions, the model learns to predict the semantic content of a whole segment based on its boundaries, directly mimicking the requirements of mention detection and coreference linking.
Span Boundary Objective (SBO)
The core innovation of SpanBERT is the Span Boundary Objective. Rather than predicting each masked token independently using its own position's output vector, SBO predicts each token in the masked span using only the output representations of the tokens immediately outside the span (the start and end boundaries). This explicitly teaches the model to encode the meaning of a phrase into its boundary tokens, which is precisely the information needed to build high-quality span representations for coreference scoring.
Single-Sequence Training
SpanBERT abandons the Next Sentence Prediction (NSP) objective used in original BERT. Instead, it pre-trains on single contiguous text segments of up to 512 tokens, sampled to respect sentence boundaries. This design choice was driven by the finding that NSP is detrimental to span-level tasks. By removing the artificial sentence-pair format, the model learns long-range discourse dependencies within a single document, which is critical for resolving coreference chains that cross sentence boundaries.
Performance on Coreference Resolution
SpanBERT established a new state-of-the-art on the CoNLL-2012 shared task for coreference resolution upon its release. The combination of span masking and the SBO objective proved uniquely effective. Key results include:
- Significant F1 gains over standard BERT on the OntoNotes 5.0 benchmark.
- Strong performance without task-specific architectural modifications, demonstrating that the pre-training objective alone was responsible for the improvement.
- The learned representations proved to be robust, general-purpose features for any task requiring entity-level understanding.
SpanBERT vs. Standard BERT
Architectural and training objective differences between SpanBERT and standard BERT, highlighting optimizations for span-level tasks like coreference resolution.
| Feature | SpanBERT | Standard BERT |
|---|---|---|
Masking Strategy | Contiguous random spans | Random individual tokens |
Masking Granularity | Multi-token spans | Single subword tokens |
Span Boundary Objective | ||
Single-Sequence Training | ||
Next Sentence Prediction | ||
Geometric Span Length Distribution | Sampled from Geometric(0.2) | |
Average Masked Span Length | 3.8 tokens | 1 token |
Coreference Resolution F1 (CoNLL-2012) | 79.6% | 73.8% |
Frequently Asked Questions
Clear, technically precise answers to the most common questions about SpanBERT's architecture, training methodology, and its impact on span-level NLP tasks.
SpanBERT is a pre-training method for BERT that is specifically optimized for span-level tasks such as coreference resolution and question answering. Unlike standard BERT, which masks individual tokens randomly, SpanBERT masks contiguous spans of tokens and predicts them using a novel span boundary objective (SBO). The key architectural difference is that SpanBERT does not use the Next Sentence Prediction (NSP) objective, which the authors found detrimental to span-level performance. Instead, it relies solely on two objectives: Masked Language Modeling (MLM) on spans and the SBO, which forces the model to predict masked tokens using only the representations of the tokens at the span's boundaries. This boundary-focused prediction encourages the model to learn span-level representations that encode the internal structure of phrases and entities without attending to the masked tokens themselves.
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
Explore the core concepts, training objectives, and architectural components that define SpanBERT and its role in modern NLP pipelines.
Span Masking
The core pre-training innovation of SpanBERT. Instead of masking random individual tokens like standard BERT, contiguous spans of tokens are masked. The model must predict the entire masked span using only the representations of the boundary tokens (the tokens immediately before and after the span). This forces the model to learn span-level semantics rather than relying on local token co-occurrence statistics.
- Example: In 'The quick brown fox jumps', masking 'quick brown' forces the model to predict the phrase from 'The' and 'fox'.
- Benefit: Directly optimizes for span representation quality, crucial for tasks like coreference resolution.
Span Boundary Objective (SBO)
A novel auxiliary training loss used alongside the standard Masked Language Model (MLM) loss. For each masked span, the SBO uses the output representations of the boundary tokens (the tokens immediately outside the masked span) to predict each token inside the span. This explicitly teaches the model to encode span content into its boundary representations.
- Mechanism: A position embedding marks the relative offset of the target token from the left boundary.
- Impact: Eliminates the need for the model to attend to individual masked tokens, relying purely on the structural boundary.
Coreference Resolution
The primary downstream task where SpanBERT achieves state-of-the-art performance. This NLP task involves identifying all mentions (spans of text) that refer to the same real-world entity and clustering them into coreference chains. SpanBERT excels here because its span boundary representations naturally capture the semantic content of a phrase.
- Example: In 'Alice went to the store. She bought milk.', SpanBERT links 'She' to 'Alice'.
- Benchmark: Achieved significant F1 score gains on the CoNLL-2012 shared task.
Single-Sequence Training
Unlike standard BERT, which often uses two concatenated segments with a Next Sentence Prediction (NSP) objective, SpanBERT is trained on single, long contiguous sequences of up to 512 tokens. This design choice is deliberate: NSP is not beneficial for span-level tasks, and single sequences prevent the model from creating spurious correlations between unrelated text segments.
- Advantage: Maximizes the length of coherent context available for predicting long spans.
- Efficiency: Simplifies the data preprocessing pipeline by removing the need for sentence segmentation.
Span Representation
A fixed-length vector encoding the meaning of a contiguous token sequence. In SpanBERT, a span's representation is typically computed by concatenating the hidden states of its start and end tokens along with a learned attention-based soft head vector. This representation is then fed into a feedforward network for scoring.
- Formula:
g_i = [x_{START(i)}; x_{END(i)}; \hat{x}_i] - Usage: These vectors are scored in a mention-ranking model to determine antecedent links.
Mention-Ranking Model
The neural architecture typically paired with SpanBERT for coreference tasks. Instead of making independent pairwise decisions, this model generates candidate spans, computes their span representations using SpanBERT, and then scores each candidate antecedent for a given mention. The highest-scoring antecedent is selected, or a dummy 'NA' antecedent is chosen if no link exists.
- Process: Mention Detection → Span Pruning → Antecedent Scoring.
- Integration: SpanBERT provides the high-quality span embeddings that make this architecture highly effective.

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