Inferensys

Glossary

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.
Engineer reviewing vector database search results on laptop, embeddings visualization on screen, home office coding session.
NEURAL ARCHITECTURE

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.

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.

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.

ARCHITECTURAL FOUNDATIONS

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.

01

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.

02

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.
03

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.
04

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.
05

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.
06

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.
SPAN REPRESENTATION

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.

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.