A Conditional Random Field (CRF) is a discriminative probabilistic graphical model used for structured prediction tasks such as sequence labelling, where the model directly estimates the conditional probability P(y|x) of an output label sequence y given an observed input sequence x. CRFs overcome the label bias problem of maximum-entropy Markov models by considering the entire output sequence jointly, making them effective for named entity recognition, part-of-speech tagging, and image segmentation.
A Conditional Random Field (CRF) is a discriminative probabilistic graphical model used for structured prediction tasks such as sequence labelling, where the model directly estimates the conditional probability P(y|x) of an output label sequence y given an observed input sequence x. CRFs overcome the label bias problem of maximum-entropy Markov models by considering the entire output sequence jointly, making them effective for named entity recognition, part-of-speech tagging, and image segmentation.
Semantic Classification
Content
Conditional Random Field
A Conditional Random Field (CRF) is a class of statistical modelling method introduced by Lafferty, McCallum, and Pereira (2001) as a discriminative alternative to generative probabilistic sequence models such as Hidden Markov Models (HMMs). Where an HMM models the joint probability P(x,y) of observations and labels, a CRF directly models the conditional P(y|x), allowing arbitrary overlapping features of the entire input sequence to inform each labelling decision without making strong independence assumptions about the observations.
Mathematical Formulation and Inference
A linear-chain CRF defines the conditional probability as a normalised product of potential functions over adjacent label pairs and observation-label combinations. Feature functions f_k(y_t, y_{t-1}, x, t) capture local context; their weighted sum forms the log-linear model. The partition function Z(x) normalises the distribution and is computed efficiently via the forward-backward algorithm. Viterbi decoding finds the most probable label sequence in O(T·K²) time for T tokens and K label classes.
Applications in NLP and Beyond
CRFs became the state-of-the-art for named entity recognition (NER), part-of-speech (POS) tagging, and shallow parsing through the 2000s and early 2010s. Systems like Stanford NER and CoNLL shared task winners frequently used CRFs as their core inference engine. In computer vision, 2D CRFs over image pixels modelled spatial label dependencies for semantic segmentation. With the advent of deep neural networks, BiLSTM-CRF architectures combine recurrent feature extraction with CRF decoding, retaining global sequence consistency while leveraging distributed representations, and remaining competitive with pure transformer architectures for NER in low-resource settings.