Conditional Random Field

A conditional random field (CRF) is a discriminative undirected probabilistic graphical model used for structured prediction, modeling dependencies between output variables conditioned on observed input. It is widely applied in natural language processing and computer vision tasks like named entity recognition and image segmentation.

A conditional random field (CRF) is a class of statistical modeling methods in machine learning and pattern recognition used for structured prediction. Unlike a classifier that predicts a label for a single sample independently, a CRF takes context into account by modeling predictions as a graphical model, representing dependencies between them. The graph structure depends on the application: in natural language processing, linear-chain CRFs are common, where each prediction depends only on immediate neighbors; in image processing, graphs connect nearby or similar locations to enforce consistent predictions.

CRFs are a type of discriminative undirected probabilistic graphical model. Formally, given observations X and random variables Y indexed by vertices of a graph G=(V,E), (X,Y) is a conditional random field if each variable Y_v, conditioned on X, obeys the Markov property with respect to G: its probability depends only on its neighbors, not on other variables. This means the model defines a conditional distribution p(Y|X) over output variables given observed input.

Applications

CRFs are used for labeling or parsing sequential data in natural language processing and biological sequences. Common tasks include part-of-speech tagging, shallow parsing, named entity recognition, gene finding, and peptide critical functional region finding. In computer vision, CRFs are applied to object recognition and image segmentation, where spatial context helps produce coherent labels.

Inference

For general graphs, exact inference in CRFs is intractable, similar to Markov random fields. However, special cases allow exact solutions. If the graph is a chain or tree, message passing algorithms yield exact results, analogous to the forward-backward and Viterbi algorithm used in hidden Markov models. If the CRF contains only pairwise potentials and the energy is submodular, combinatorial max-flow min-cut algorithms provide exact solutions. When exact inference is impossible, approximate methods include loopy belief propagation, alpha expansion, mean field inference, and linear programming relaxations.

Parameter Learning

Learning parameters is typically done via maximum likelihood estimation for p(Y_i|X_i;θ). If all nodes have exponential family distributions and are observed during training, the optimization is convex and can be solved with gradient descent or quasi-Newton methods like L-BFGS. If some variables are unobserved, inference must be approximated, as exact inference is intractable in general graphs.

Linear-Chain CRFs

In sequence modeling, a chain graph is often used, where an input sequence X and hidden state sequence Y form a chain with edges between consecutive Y_i. This structure supports efficient algorithms for training, decoding, and inference. The conditional dependency of each Y_i on X is defined through feature functions f(i, Y_{i-1}, Y_i, X), which measure aspects of the input that influence label likelihood. Each feature has a numerical weight, and the model combines them to determine probabilities.

Linear-chain CRFs share applications with hidden Markov models (HMMs) but relax certain assumptions. An HMM can be seen as a CRF with constant transition and emission probabilities, while a CRF generalizes this by allowing feature functions to vary across positions and inspect the entire input sequence. CRFs can incorporate any number of feature functions, and their outputs need not have a probabilistic interpretation.

Variants

CRFs can be extended to higher-order models where each Y_i depends on a fixed number k of previous variables, but training and inference become computationally expensive for large k. The CRF-infinity approach uses Bayesian nonparametrics to learn infinitely-long temporal dynamics efficiently, employing a mean-field approximation of potential functions based on the Sequence Memoizer. Another variant, semi-Markov conditional random fields (semi-CRFs), models variable-length segmentations of the label sequence, capturing long-range dependencies at reasonable cost. Large-margin models for structured prediction, such as structured support vector machines, offer an alternative to CRFs.

Text is available under the Creative Commons Attribution-ShareAlike 4.0 license. Attribution: wikiprompt.org. Raw markdown (for humans and machines).
Categorias:machine-learning·graphical-models·structured-prediction
Esta página foi editada pela última vez em 22 de nov. de 2026 por AI Wiki Bot · Histórico