A span representation is a dense, fixed-length vector that encodes the semantic content of a contiguous multi-token text segment. Unlike individual token embeddings, it captures the compositional meaning of a phrase by aggregating the contextualized hidden states from a transformer encoder across the span's boundaries.
Glossary
Span Representation

What is Span Representation?
A fixed-length vector encoding a contiguous sequence of tokens, typically computed by concatenating or attending over the hidden states of the span's start and end tokens.
The canonical method computes the representation by concatenating the hidden states of the span's start and end tokens, often with an attention-weighted sum over all tokens in between. This vector serves as the primary input feature for span-level tasks like coreference resolution and named entity recognition, where models must compare and score arbitrary text segments.
Key Characteristics of Span Representations
Span representations encode contiguous token sequences into fixed-length vectors, serving as the fundamental building blocks for modern coreference resolution and information extraction systems.
Boundary-Anchored Encoding
Span representations are typically computed by concatenating or attending over the hidden states of the span's start token and end token. This boundary-focused approach captures the syntactic and semantic boundaries of a phrase without requiring explicit segmentation. Models like SpanBERT optimize this by masking entire contiguous spans during pre-training, forcing the model to predict the masked content using only the boundary tokens. This produces representations inherently sensitive to phrase-level constituency, making them ideal for tasks like mention detection where identifying precise entity boundaries is critical.
Attention-Based Pooling
Beyond simple concatenation of endpoints, sophisticated span representations use soft head-finding attention to compute a weighted sum over all token hidden states within the span. This mechanism learns to focus on the syntactic head word of the phrase without requiring explicit dependency parse features. The attention weights are computed as:
- Token-level scoring: Each token receives a learned score based on its hidden state
- Normalized weighting: Scores are softmax-normalized across the span
- Weighted aggregation: The final representation is a weighted sum of all token vectors This approach is more robust than rigid head-finding heuristics and adapts to the linguistic properties of different mention types.
Span Width Features
Effective span representations often incorporate explicit span width embeddings to encode the length of the token sequence. These learned embeddings capture important priors:
- Short spans (1-3 tokens) typically correspond to named entities and pronouns
- Medium spans (4-7 tokens) often represent common noun phrases
- Long spans (8+ tokens) may indicate nested or complex syntactic constituents By concatenating a width embedding with the boundary-derived representation, models learn to distinguish between spans of different lengths that might otherwise have similar semantic content, improving mention detection precision.
Higher-Order Refinement
Static span representations are insufficient for coreference because an entity's representation should incorporate information from its coreference chain. Higher-order inference iteratively refines span representations by attending over the representations of predicted antecedents:
- First pass: Compute initial span representations and antecedent scores
- Refinement step: Update each span's representation by attending over its top-k predicted antecedents
- Iteration: Repeat the refinement process, allowing transitive information to propagate through the chain This enables the model to learn that 'the company' and 'it' should have similar representations if they corefer, improving resolution accuracy for long-distance dependencies.
Biaffine Scoring Compatibility
Span representations are designed to be compatible with biaffine attention scoring for efficient pairwise comparison. Given a span representation g_i for mention i and g_j for candidate antecedent j, the coreference score is computed as:
- Bilinear transformation: s(i,j) = g_i^T W g_j + U^T [g_i; g_j] + b
- The matrix W captures interaction patterns between mention and antecedent features
- The concatenated term provides a direct compatibility score This scoring function is more expressive than simple dot-product or cosine similarity, allowing the model to learn complex coreference patterns such as appositive relationships and predicate-nominative constructions.
Pruning for Computational Efficiency
Enumerating all possible spans in a document is computationally prohibitive, as the number grows quadratically with document length. Span representation systems employ aggressive pruning strategies:
- Span pruning: Score all possible spans up to a maximum width, then retain only the top-k spans by mention likelihood score for downstream coreference scoring
- Antecedent pruning: For each retained mention, consider only the k nearest preceding mentions as candidate antecedents, plus a dummy NA antecedent
- Distance-based filtering: Apply hard constraints on maximum antecedent distance These optimizations reduce the candidate space from O(n^2) to O(nk), making end-to-end coreference feasible on long documents while maintaining high recall.
Frequently Asked Questions
Clear, technical answers to the most common questions about encoding contiguous token sequences into fixed-length vectors for NLP tasks like coreference resolution.
A span representation is a fixed-length vector that encodes the semantic and syntactic information of a contiguous sequence of tokens within a text. Unlike token-level embeddings that represent individual words, a span representation captures the meaning of a multi-word phrase. The most common method computes the representation by concatenating the hidden states of the span's start and end tokens from a pretrained encoder like BERT, often combined with a learned attention-weighted sum over all tokens within the span. This vector is then used as input to downstream tasks such as coreference resolution, named entity recognition, and semantic role labeling, where the model must reason about phrases rather than single tokens.
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 and architectural components that rely on or enable span representations in modern NLP systems.

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