Conditional random field

Conditional random fields (CRFs) are a class of statistical modelling method often applied in pattern recognition and machine learning, where they are used for structured prediction. Whereas an ordinary classifier predicts a label for a single sample without regard to "neighboring" samples, a CRF can take context into account; e.g., the linear chain CRF popular in natural language processing predicts sequences of labels for sequences of input samples.

CRFs are a type of discriminative undirected probabilistic graphical model. It is used to encode known relationships between observations and construct consistent interpretations. It is often used for labeling or parsing of sequential data, such as natural language text or biological sequences[1] and in computer vision.[2] Specifically, CRFs find applications in shallow parsing,[3] named entity recognition[4] and gene finding, among other tasks, being an alternative to the related hidden Markov models (HMMs). In computer vision, CRFs are often used for object recognition and image segmentation.

Description

Lafferty, McCallum and Pereira[1] define a CRF on observations ${\displaystyle {\boldsymbol {X}}}$ and random variables ${\displaystyle {\boldsymbol {Y}}}$ as follows:

Let ${\displaystyle G=(V,E)}$ be a graph such that

What this means is that a CRF is an undirected graphical model whose nodes can be divided into exactly two disjoint sets ${\displaystyle {\boldsymbol {X}}}$ and ${\displaystyle {\boldsymbol {Y}}}$, the observed and output variables, respectively; the conditional distribution ${\displaystyle p({\boldsymbol {Y}}|{\boldsymbol {X}})}$ is then modeled.

Inference

For general graphs, the problem of exact inference in CRFs is intractable. The inference problem for a CRF is basically the same as for an MRF and the same arguments hold.[5] However there exist special cases for which exact inference is feasible:

• If the graph is a chain or a tree, message passing algorithms yield exact solutions. The algorithms used in these cases are analogous to the forward-backward and Viterbi algorithm for the case of HMMs.
• If the CRF only contains pair-wise potentials and the energy is submodular, combinatorial min cut/max flow algorithms yield exact solutions.

If exact inference is impossible, several algorithms can be used to obtain approximate solutions. These include:

• Loopy belief propagation
• Alpha expansion
• Mean field inference
• Linear programming relaxations

Parameter Learning

Learning the parameters ${\displaystyle \theta }$ is usually done by maximum likelihood learning for ${\displaystyle p(Y_{i}|X_{i};\theta )}$. If all nodes have exponential family distributions and all nodes are observed during training, this optimization is convex.[5] It can be solved for example using gradient descent algorithms, or Quasi-Newton methods such as the L-BFGS algorithm. On the other hand, if some variables are unobserved, the inference problem has to be solved for these variables. Exact inference is intractable in general graphs, so approximations have to be used.

Examples

In sequence modeling, the graph of interest is usually a chain graph. An input sequence of observed variables ${\displaystyle X}$ represents a sequence of observations and ${\displaystyle Y}$ represents a hidden (or unknown) state variable that needs to be inferred given the observations. The ${\displaystyle Y_{i}}$ are structured to form a chain, with an edge between each ${\displaystyle Y_{i-1}}$ and ${\displaystyle Y_{i}}$. As well as having a simple interpretation of the ${\displaystyle Y_{i}}$ as "labels" for each element in the input sequence, this layout admits efficient algorithms for:

The conditional dependency of each ${\displaystyle Y_{i}}$ on ${\displaystyle X}$ is defined through a fixed set of feature functions of the form ${\displaystyle f(i,Y_{i-1},Y_{i},X)}$, which can informally be thought of as measurements on the input sequence that partially determine the likelihood of each possible value for ${\displaystyle Y_{i}}$. The model assigns each feature a numerical weight and combines them to determine the probability of a certain value for ${\displaystyle Y_{i}}$.

Linear-chain CRFs have many of the same applications as conceptually simpler hidden Markov models (HMMs), but relax certain assumptions about the input and output sequence distributions. An HMM can loosely be understood as a CRF with very specific feature functions that use constant probabilities to model state transitions and emissions. Conversely, a CRF can loosely be understood as a generalization of an HMM that makes the constant transition probabilities into arbitrary functions that vary across the positions in the sequence of hidden states, depending on the input sequence.

Notably in contrast to HMMs, CRFs can contain any number of feature functions, the feature functions can inspect the entire input sequence ${\displaystyle X}$ at any point during inference, and the range of the feature functions need not have a probabilistic interpretation.

Variants

Higher-order CRFs and semi-Markov CRFs

CRFs can be extended into higher order models by making each ${\displaystyle Y_{i}}$ dependent on a fixed number ${\displaystyle o}$ of previous variables ${\displaystyle Y_{i-o},...,Y_{i-1}}$. Training and inference are only practical for small values of ${\displaystyle o}$ (such as o ≤ 5),{{ safesubst:#invoke:Unsubst||date=__DATE__ |\$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }} since their computational cost increases exponentially with ${\displaystyle o}$. Large-margin models for structured prediction, such as the structured Support Vector Machine can be seen as an alternative training procedure to CRFs.

There exists another generalization of CRFs, the semi-Markov conditional random field (semi-CRF), which models variable-length segmentations of the label sequence ${\displaystyle Y}$.[6] This provides much of the power of higher-order CRFs to model long-range dependencies of the ${\displaystyle Y_{i}}$, at a reasonable computational cost.

Latent-dynamic conditional random field

Latent-dynamic conditional random fields (LDCRF) or discriminative probabilistic latent variable models (DPLVM) are a type of CRFs for sequence tagging tasks. They are latent variable models that are trained discriminatively.

In an LDCRF, like in any sequence tagging task, given a sequence of observations x = Template:Mvar₁, … Template:Mvar, the main problem the model must solve is how to assign a sequence of labels y = Template:Mvar₁, … Template:Mvar from one finite set of labels Template:Mvar. Instead of directly modeling Template:Mvar(y|x) as an ordinary linear-chain CRF would do, instead a set of latent variables h is "inserted" between x and y using the chain rule of probability:[7]

${\displaystyle P(\mathbf {y} |\mathbf {x} )=\sum _{\mathbf {h} }P(\mathbf {y} |\mathbf {h} ,\mathbf {x} )P(\mathbf {h} |\mathbf {x} )}$

This allows the capturing of latent structure between the observations and labels.[8] While LDCRFs can be trained using quasi-Newton methods, a specialized version of the perceptron algorithm called the latent-variable perceptron has been developed for them as well, based on Collins' structured perceptron algorithm.[7] These models find applications in computer vision, specifically gesture recognition from video streams,[8] and shallow parsing.[7]

Software

This is a partial list of software that implement generic CRF tools.

This is a partial list of software that implement CRF related tools.

References

1. {{#invoke:citation/CS1|citation |CitationClass=conference }}
2. Template:Cite news
3. {{#invoke:citation/CS1|citation |CitationClass=conference }}
4. {{#invoke:citation/CS1|citation |CitationClass=conference }}
5. Template:Cite arXiv
6. {{#invoke:citation/CS1|citation |CitationClass=conference }}
7. {{#invoke:citation/CS1|citation |CitationClass=conference }}
8. Template:Cite doi
9. T. Lavergne, O. Cappé and F. Yvon (2010). Practical very large scale CRFs. Proc. 48th Annual Meeting of the ACL, pp. 504-513.