Inferensys

Glossary

Semi-Markov CRF

A segment-level sequence model that directly models the probability of entire entity spans rather than individual tokens, naturally handling segment-level features and non-contiguous structures.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
SEGMENT-LEVEL SEQUENCE MODELING

What is Semi-Markov CRF?

A Semi-Markov Conditional Random Field is a discriminative probabilistic model that directly assigns labels to entire text segments rather than individual tokens, enabling the explicit modeling of segment-level features and duration.

A Semi-Markov CRF is a graphical model for sequence labeling that operates at the segment level. Unlike a linear-chain CRF, which predicts a label for each token, a Semi-Markov CRF predicts a single label for a contiguous span of tokens. This allows the model to naturally incorporate features that depend on the entire multi-word segment, such as the phrase's internal syntactic structure or its total length, making it highly effective for Named Entity Recognition where entity boundaries are critical.

The model defines a conditional probability distribution over segmentations of the input sequence. By scoring entire spans directly, it avoids the label bias problem and the fragmentation of entity features that can occur in token-level models. Inference is typically performed using a generalized Viterbi decoding algorithm adapted for semi-Markov structures, finding the optimal sequence of non-overlapping segments that maximizes the overall sequence probability.

ARCHITECTURAL ADVANTAGES

Key Features of Semi-Markov CRFs

Semi-Markov Conditional Random Fields extend standard linear-chain CRFs by modeling entire entity segments as single units, enabling direct scoring of span-level features and duration modeling.

01

Segment-Level Modeling

Unlike token-level linear-chain CRFs that predict labels for each word, Semi-Markov CRFs operate directly on variable-length text segments. The model scores entire spans—such as 'Bank of America' or 'acute myeloid leukemia'—as atomic units rather than independently labeling each token. This eliminates the need for BIO tagging schemes and naturally captures multi-word entity boundaries without post-processing heuristics.

02

Explicit Duration Modeling

Semi-Markov CRFs incorporate segment duration distributions that explicitly model how long an entity span is likely to be. This prevents the model from predicting implausibly short or long entities:

  • Organization names typically span 1-5 tokens
  • Person names rarely exceed 4 tokens
  • Medical terms can extend to 8+ tokens

The duration prior acts as a regularizer, penalizing segment lengths that deviate from expected distributions.

03

Segment-Level Feature Engineering

The architecture enables rich feature extraction across entire spans rather than individual tokens. Segment features can capture:

  • Internal capitalization patterns ('New York Times')
  • Gazetteer matches against knowledge bases
  • Syntactic constituency of the full phrase
  • Character-level morphology across the span
  • Embedding aggregations (mean, max, attention-pooled)

These holistic features are impossible to compute in token-level CRF architectures.

04

Non-Markovian State Transitions

Standard CRFs enforce the Markov property—the next state depends only on the current state. Semi-Markov CRFs relax this constraint by conditioning transitions on the entire segment history, including:

  • The entity type of the previous segment
  • The length of the previous segment
  • The textual content of adjacent segments

This enables modeling of long-range dependencies between entities, such as consistent labeling of co-referring mentions across a document.

05

Viterbi Decoding Over Segments

Inference uses a segment-level Viterbi algorithm that efficiently searches over all possible segmentations. The dynamic programming approach computes:

code
score(s, i, j) = segment_score(i, j) + transition(s_prev, s) + max_path(prev_state, i)

where segment_score(i, j) evaluates the span from position i to j with label s. This guarantees finding the globally optimal segmentation without greedy decoding or beam search approximations.

06

Handling Nested and Discontinuous Entities

Extensions of Semi-Markov CRFs can model non-contiguous and nested entity structures that linear-chain models cannot represent:

  • Nested entities: '[[University of [California]] [San Francisco]]'
  • Discontinuous mentions: 'insulin-dependent and non-insulin-dependent diabetes'
  • Overlapping spans in biomedical text

This is achieved through higher-order factors or by relaxing the non-overlapping segment constraint, making the model suitable for complex information extraction tasks.

SEQUENCE MODELING ARCHITECTURE COMPARISON

Semi-Markov CRF vs. Linear-Chain CRF

Structural and functional differences between segment-level Semi-Markov CRFs and token-level Linear-Chain CRFs for named entity recognition and structured prediction.

FeatureSemi-Markov CRFLinear-Chain CRF

Modeling granularity

Segment-level (entire entity spans)

Token-level (individual tokens)

State duration modeling

Handles nested entities

Segment-level feature extraction

Markov property scope

Semi-Markov (relaxed memory)

First-order Markov (strict)

Inference complexity

O(n^2) or higher

O(n) with Viterbi decoding

Training speed

Slower (segment enumeration)

Faster (token-level dynamic programming)

BIO tag dependency

TECHNICAL DEEP DIVE

Frequently Asked Questions

Explore the mechanics and advantages of Semi-Markov Conditional Random Fields for segment-level sequence modeling in Named Entity Recognition.

A Semi-Markov Conditional Random Field (Semi-CRF) is a discriminative probabilistic graphical model designed for segment-level sequence labeling. Unlike a standard linear-chain CRF, which models dependencies between individual tokens, a Semi-CRF directly models the probability of entire contiguous segments (spans) of text. In a linear-chain CRF, the state duration follows an implicit geometric distribution, which poorly reflects natural language where entity lengths vary arbitrarily. The Semi-CRF overcomes this by assigning a single label to an entire multi-token segment and scoring it using segment-level features (e.g., the internal composition of the phrase). This architecture naturally handles the Markov property at the segment level, where the transition probability depends on the previous segment's label and boundaries, not just the previous token. This makes it inherently superior for tasks like Named Entity Recognition (NER) where the internal consistency of a phrase like 'Bank of America' is critical, and token-level independence assumptions fail.

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.