Conditional random field

From HandWiki
Short description: Class of statistical modeling methods

Conditional random fields (CRFs) are a class of statistical modeling methods often applied in pattern recognition and machine learning and used for structured prediction. Whereas a classifier predicts a label for a single sample without considering "neighbouring" samples, a CRF can take context into account. To do so, the predictions are modelled as a graphical model, which represents the presence of dependencies between the predictions. What kind of graph is used depends on the application. For example, in natural language processing, "linear chain" CRFs are popular, for which each prediction is dependent only on its immediate neighbours. In image processing, the graph typically connects locations to nearby and/or similar locations to enforce that they receive similar predictions.

Other examples where CRFs are used are: labeling or parsing of sequential data for natural language processing or biological sequences,[1] part-of-speech tagging, shallow parsing,[2] named entity recognition,[3] gene finding, peptide critical functional region finding,[4] and object recognition[5] and image segmentation in computer vision.[6]

Description

CRFs are a type of discriminative undirected probabilistic graphical model.

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

Let [math]\displaystyle{ G = (V , E) }[/math] be a graph such that [math]\displaystyle{ \boldsymbol{Y} = (\boldsymbol{Y}_v)_{v\in V} }[/math], so that [math]\displaystyle{ \boldsymbol{Y} }[/math] is indexed by the vertices of [math]\displaystyle{ G }[/math].

Then [math]\displaystyle{ (\boldsymbol{X}, \boldsymbol{Y}) }[/math] is a conditional random field when each random variable [math]\displaystyle{ \boldsymbol{Y}_v }[/math], conditioned on [math]\displaystyle{ \boldsymbol{X} }[/math], obeys the Markov property with respect to the graph; that is, its probability is dependent only on its neighbours in G:

[math]\displaystyle{ P(\boldsymbol{Y}_v |\boldsymbol{X}, \{\boldsymbol{Y}_w: w \neq v\}) = P(\boldsymbol{Y}_v |\boldsymbol{X}, \{\boldsymbol{Y}_w: w \sim v\}) }[/math], where [math]\displaystyle{ \mathit{w} \sim v }[/math] means that [math]\displaystyle{ w }[/math] and [math]\displaystyle{ v }[/math] are neighbors in [math]\displaystyle{ G }[/math].

What this means is that a CRF is an undirected graphical model whose nodes can be divided into exactly two disjoint sets [math]\displaystyle{ \boldsymbol{X} }[/math] and [math]\displaystyle{ \boldsymbol{Y} }[/math], the observed and output variables, respectively; the conditional distribution [math]\displaystyle{ p(\boldsymbol{Y}|\boldsymbol{X}) }[/math] 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.[7] 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:

Parameter Learning

Learning the parameters [math]\displaystyle{ \theta }[/math] is usually done by maximum likelihood learning for [math]\displaystyle{ p(Y_i|X_i; \theta) }[/math]. If all nodes have exponential family distributions and all nodes are observed during training, this optimization is convex.[7] 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 [math]\displaystyle{ X }[/math] represents a sequence of observations and [math]\displaystyle{ Y }[/math] represents a hidden (or unknown) state variable that needs to be inferred given the observations. The [math]\displaystyle{ Y_{i} }[/math] are structured to form a chain, with an edge between each [math]\displaystyle{ Y_{i-1} }[/math] and [math]\displaystyle{ Y_{i} }[/math]. As well as having a simple interpretation of the [math]\displaystyle{ Y_{i} }[/math] as "labels" for each element in the input sequence, this layout admits efficient algorithms for:

  • model training, learning the conditional distributions between the [math]\displaystyle{ Y_{i} }[/math] and feature functions from some corpus of training data.
  • decoding, determining the probability of a given label sequence [math]\displaystyle{ Y }[/math] given [math]\displaystyle{ X }[/math].
  • inference, determining the most likely label sequence [math]\displaystyle{ Y }[/math] given [math]\displaystyle{ X }[/math].

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

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 [math]\displaystyle{ X }[/math] 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 [math]\displaystyle{ Y_{i} }[/math] dependent on a fixed number [math]\displaystyle{ k }[/math] of previous variables [math]\displaystyle{ Y_{i-k}, ..., Y_{i-1} }[/math]. In conventional formulations of higher order CRFs, training and inference are only practical for small values of [math]\displaystyle{ k }[/math] (such as k ≤ 5),[8] since their computational cost increases exponentially with [math]\displaystyle{ k }[/math].

However, another recent advance has managed to ameliorate these issues by leveraging concepts and tools from the field of Bayesian nonparametrics. Specifically, the CRF-infinity approach[9] constitutes a CRF-type model that is capable of learning infinitely-long temporal dynamics in a scalable fashion. This is effected by introducing a novel potential function for CRFs that is based on the Sequence Memoizer (SM), a nonparametric Bayesian model for learning infinitely-long dynamics in sequential observations.[10] To render such a model computationally tractable, CRF-infinity employs a mean-field approximation[11] of the postulated novel potential functions (which are driven by an SM). This allows for devising efficient approximate training and inference algorithms for the model, without undermining its capability to capture and model temporal dependencies of arbitrary length.

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

Finally, large-margin models for structured prediction, such as the structured Support Vector Machine can be seen as an alternative training procedure to CRFs.

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 = [math]\displaystyle{ x_1,\dots,x_n }[/math], the main problem the model must solve is how to assign a sequence of labels y = [math]\displaystyle{ y_1,\dots,y_n }[/math] from one finite set of labels Y. Instead of directly modeling P(y|x) as an ordinary linear-chain CRF would do, a set of latent variables h is "inserted" between x and y using the chain rule of probability:[13]

[math]\displaystyle{ P(\mathbf{y} | \mathbf{x}) = \sum_\mathbf{h} P(\mathbf{y}|\mathbf{h}, \mathbf{x}) P(\mathbf{h} | \mathbf{x}) }[/math]

This allows capturing latent structure between the observations and labels.[14] 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.[13] These models find applications in computer vision, specifically gesture recognition from video streams[14] and shallow parsing.[13]

See also

References

  1. 1.0 1.1 Lafferty, J.; McCallum, A.; Pereira, F. (2001). "Conditional random fields: Probabilistic models for segmenting and labeling sequence data". Morgan Kaufmann. pp. 282–289. http://repository.upenn.edu/cgi/viewcontent.cgi?article=1162&context=cis_papers. 
  2. Sha, F.; Pereira, F. (2003). "shallow parsing with conditional random fields". http://portal.acm.org/ft_gateway.cfm?id=1073473&type=pdf&CFID=4684435&CFTOKEN=39459323. 
  3. Settles, B. (2004). "Biomedical named entity recognition using conditional random fields and rich feature sets". pp. 104–107. http://www.aclweb.org/anthology/W04-1221.pdf. 
  4. Chang KY; Lin T-p; Shih L-Y; Wang C-K (2015). "Analysis and Prediction of the Critical Regions of Antimicrobial Peptides Based on Conditional Random Fields.". PLOS ONE 10 (3): e0119490. doi:10.1371/journal.pone.0119490. PMID 25803302. Bibcode2015PLoSO..1019490C. 
  5. J.R. Ruiz-Sarmiento; C. Galindo; J. Gonzalez-Jimenez (2015). "UPGMpp: a Software Library for Contextual Object Recognition.". https://www.researchgate.net/publication/281620302. 
  6. "Multiscale conditional random fields for image labeling". IEEE Computer Society. 2004. 
  7. 7.0 7.1 Sutton, Charles; McCallum, Andrew (2010). "An Introduction to Conditional Random Fields". arXiv:1011.4088v1 [stat.ML].
  8. Lavergne, Thomas; Yvon, François (September 7, 2017). "Learning the Structure of Variable-Order CRFs: a Finite-State Perspective". Copenhagen, Denmark: Association for Computational Linguistics. p. 433. http://aclweb.org/anthology/D17-1044. 
  9. Chatzis, Sotirios; Demiris, Yiannis (2013). "The Infinite-Order Conditional Random Field Model for Sequential Data Modeling". IEEE Transactions on Pattern Analysis and Machine Intelligence 35 (6): 1523–1534. doi:10.1109/tpami.2012.208. PMID 23599063. 
  10. Gasthaus, Jan; Teh, Yee Whye (2010). "Improvements to the Sequence Memoizer". https://papers.nips.cc/paper/3938-improvements-to-the-sequence-memoizer.pdf. 
  11. Celeux, G.; Forbes, F.; Peyrard, N. (2003). "EM Procedures Using Mean Field-Like Approximations for Markov Model-Based Image Segmentation". Pattern Recognition 36 (1): 131–144. doi:10.1016/s0031-3203(02)00027-4. Bibcode2003PatRe..36..131C. 
  12. Sarawagi, Sunita; Cohen, William W. (2005). "Semi-Markov conditional random fields for information extraction". in Lawrence K. Saul. Advances in Neural Information Processing Systems 17. Cambridge, MA: MIT Press. pp. 1185–1192. http://papers.nips.cc/paper/2648-semi-markov-conditional-random-fields-for-information-extraction.pdf. Retrieved 2015-11-12. 
  13. 13.0 13.1 13.2 Xu Sun; Takuya Matsuzaki; Daisuke Okanohara; Jun'ichi Tsujii (2009). "Latent Variable Perceptron Algorithm for Structured Classification". IJCAI. pp. 1236–1242. http://www.aaai.org/ocs/index.php/IJCAI/IJCAI-09/paper/download/356/970. Retrieved 2018-12-06. 
  14. 14.0 14.1 Morency, L. P.; Quattoni, A.; Darrell, T. (2007). "Latent-Dynamic Discriminative Models for Continuous Gesture Recognition". 2007 IEEE Conference on Computer Vision and Pattern Recognition. p. 1. doi:10.1109/CVPR.2007.383299. ISBN 978-1-4244-1179-5. http://dspace.mit.edu/bitstream/handle/1721.1/35276/MIT-CSAIL-TR-2007-002.pdf. 

Further reading

  • McCallum, A.: Efficiently inducing features of conditional random fields. In: Proc. 19th Conference on Uncertainty in Artificial Intelligence. (2003)
  • Wallach, H.M.: Conditional random fields: An introduction. Technical report MS-CIS-04-21, University of Pennsylvania (2004)
  • Sutton, C., McCallum, A.: An Introduction to Conditional Random Fields for Relational Learning. In "Introduction to Statistical Relational Learning". Edited by Lise Getoor and Ben Taskar. MIT Press. (2006) Online PDF
  • Klinger, R., Tomanek, K.: Classical Probabilistic Models and Conditional Random Fields. Algorithm Engineering Report TR07-2-013, Department of Computer Science, Dortmund University of Technology, December 2007. ISSN 1864-4503. Online PDF