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.
Glossary
Semi-Markov CRF

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.
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.
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.
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.
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.
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.
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.
Viterbi Decoding Over Segments
Inference uses a segment-level Viterbi algorithm that efficiently searches over all possible segmentations. The dynamic programming approach computes:
codescore(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.
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.
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.
| Feature | Semi-Markov CRF | Linear-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 |
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.
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
Understanding Semi-Markov CRFs requires familiarity with the sequence modeling and span-based architectures they build upon. These related concepts form the technical foundation for segment-level sequence labeling.

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