Inferensys

Glossary

SpanBERT

A pre-training method for BERT that masks contiguous spans of tokens and predicts them using span boundary representations, optimized for span-level tasks like coreference resolution.
Product manager reviewing autonomous task execution dashboard on laptop, completed tasks visible, casual work session.
SPAN-LEVEL PRE-TRAINING

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.

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.

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.

ARCHITECTURE INNOVATIONS

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.

01

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.

Geometric Distribution
Span Length Sampling
02

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.

Boundary Tokens
Input to SBO
03

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.

04

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.
CoNLL-2012
Benchmark Dataset
PRE-TRAINING OBJECTIVE COMPARISON

SpanBERT vs. Standard BERT

Architectural and training objective differences between SpanBERT and standard BERT, highlighting optimizations for span-level tasks like coreference resolution.

FeatureSpanBERTStandard 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%

SPANBERT EXPLAINED

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.

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.