Statistical NLP: Hidden Markov Models Updated 8/12/2005.

Slides:



Advertisements
Similar presentations
HMM II: Parameter Estimation. Reminder: Hidden Markov Model Markov Chain transition probabilities: p(S i+1 = t|S i = s) = a st Emission probabilities:
Advertisements

Learning HMM parameters
Introduction to Hidden Markov Models
Hidden Markov Models Bonnie Dorr Christof Monz CMSC 723: Introduction to Computational Linguistics Lecture 5 October 6, 2004.
 CpG is a pair of nucleotides C and G, appearing successively, in this order, along one DNA strand.  CpG islands are particular short subsequences in.
Page 1 Hidden Markov Models for Automatic Speech Recognition Dr. Mike Johnson Marquette University, EECE Dept.
Ch 9. Markov Models 고려대학교 자연어처리연구실 한 경 수
Statistical NLP: Lecture 11
Ch-9: Markov Models Prepared by Qaiser Abbas ( )
Hidden Markov Models Theory By Johan Walters (SR 2003)
Foundations of Statistical NLP Chapter 9. Markov Models 한 기 덕한 기 덕.
1 Hidden Markov Models (HMMs) Probabilistic Automata Ubiquitous in Speech/Speaker Recognition/Verification Suitable for modelling phenomena which are dynamic.
Hidden Markov Models Fundamentals and applications to bioinformatics.
Natural Language Processing Spring 2007 V. “Juggy” Jagannathan.
Lecture 15 Hidden Markov Models Dr. Jianjun Hu mleg.cse.sc.edu/edu/csce833 CSCE833 Machine Learning University of South Carolina Department of Computer.
Hidden Markov Models 1 2 K … 1 2 K … 1 2 K … … … … 1 2 K … x1x1 x2x2 x3x3 xKxK 2 1 K 2.
Albert Gatt Corpora and Statistical Methods Lecture 8.
. Hidden Markov Model Lecture #6. 2 Reminder: Finite State Markov Chain An integer time stochastic process, consisting of a domain D of m states {1,…,m}
Part II. Statistical NLP Advanced Artificial Intelligence (Hidden) Markov Models Wolfram Burgard, Luc De Raedt, Bernhard Nebel, Lars Schmidt-Thieme Most.
Part II. Statistical NLP Advanced Artificial Intelligence Hidden Markov Models Wolfram Burgard, Luc De Raedt, Bernhard Nebel, Lars Schmidt-Thieme Most.
HMM-BASED PATTERN DETECTION. Outline  Markov Process  Hidden Markov Models Elements Basic Problems Evaluation Optimization Training Implementation 2-D.
FSA and HMM LING 572 Fei Xia 1/5/06.
Hidden Markov Model 11/28/07. Bayes Rule The posterior distribution Select k with the largest posterior distribution. Minimizes the average misclassification.
Hidden Markov Models I Biology 162 Computational Genetics Todd Vision 14 Sep 2004.
. Hidden Markov Model Lecture #6 Background Readings: Chapters 3.1, 3.2 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
Hidden Markov Models 1 2 K … 1 2 K … 1 2 K … … … … 1 2 K … x1x1 x2x2 x3x3 xKxK 2 1 K 2.
. Hidden Markov Model Lecture #6 Background Readings: Chapters 3.1, 3.2 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
Pattern Classification All materials in these slides were taken from Pattern Classification (2nd ed) by R. O. Duda, P. E. Hart and D. G. Stork, John Wiley.
Hidden Markov Models K 1 … 2. Outline Hidden Markov Models – Formalism The Three Basic Problems of HMMs Solutions Applications of HMMs for Automatic Speech.
1 HMM (I) LING 570 Fei Xia Week 7: 11/5-11/7/07. 2 HMM Definition and properties of HMM –Two types of HMM Three basic questions in HMM.
Forward-backward algorithm LING 572 Fei Xia 02/23/06.
1 Hidden Markov Model Instructor : Saeed Shiry  CHAPTER 13 ETHEM ALPAYDIN © The MIT Press, 2004.
Doug Downey, adapted from Bryan Pardo,Northwestern University
Hidden Markov Models David Meir Blei November 1, 1999.
Hidden Markov Models. Hidden Markov Model In some Markov processes, we may not be able to observe the states directly.
Learning HMM parameters Sushmita Roy BMI/CS 576 Oct 21 st, 2014.
Fall 2001 EE669: Natural Language Processing 1 Lecture 9: Hidden Markov Models (HMMs) (Chapter 9 of Manning and Schutze) Dr. Mary P. Harper ECE, Purdue.
Visual Recognition Tutorial1 Markov models Hidden Markov models Forward/Backward algorithm Viterbi algorithm Baum-Welch estimation algorithm Hidden.
. Class 5: Hidden Markov Models. Sequence Models u So far we examined several probabilistic model sequence models u These model, however, assumed that.
Hidden Markov Model Continues …. Finite State Markov Chain A discrete time stochastic process, consisting of a domain D of m states {1,…,m} and 1.An m.
1 Markov Chains. 2 Hidden Markov Models 3 Review Markov Chain can solve the CpG island finding problem Positive model, negative model Length? Solution:
ETHEM ALPAYDIN © The MIT Press, Lecture Slides for.
Combined Lecture CS621: Artificial Intelligence (lecture 25) CS626/449: Speech-NLP-Web/Topics-in- AI (lecture 26) Pushpak Bhattacharyya Computer Science.
Ch10 HMM Model 10.1 Discrete-Time Markov Process 10.2 Hidden Markov Models 10.3 The three Basic Problems for HMMS and the solutions 10.4 Types of HMMS.
CS344 : Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 21- Forward Probabilities and Robotic Action Sequences.
Fundamentals of Hidden Markov Model Mehmet Yunus Dönmez.
1 HMM - Part 2 Review of the last lecture The EM algorithm Continuous density HMM.
Sequence Models With slides by me, Joshua Goodman, Fei Xia.
S. Salzberg CMSC 828N 1 Three classic HMM problems 2.Decoding: given a model and an output sequence, what is the most likely state sequence through the.
NLP. Introduction to NLP Sequence of random variables that aren’t independent Examples –weather reports –text.
Hidden Markov Models & POS Tagging Corpora and Statistical Methods Lecture 9.
PGM 2003/04 Tirgul 2 Hidden Markov Models. Introduction Hidden Markov Models (HMM) are one of the most common form of probabilistic graphical models,
Hidden Markov Models 1 2 K … 1 2 K … 1 2 K … … … … 1 2 K … x1x1 x2x2 x3x3 xKxK 2 1 K 2.
1 CONTEXT DEPENDENT CLASSIFICATION  Remember: Bayes rule  Here: The class to which a feature vector belongs depends on:  Its own value  The values.
Hidden Markovian Model. Some Definitions Finite automation is defined by a set of states, and a set of transitions between states that are taken based.
1 CSE 552/652 Hidden Markov Models for Speech Recognition Spring, 2006 Oregon Health & Science University OGI School of Science & Engineering John-Paul.
Hidden Markov Models (HMMs) –probabilistic models for learning patterns in sequences (e.g. DNA, speech, weather, cards...) (2 nd order model)
Albert Gatt Corpora and Statistical Methods. Acknowledgement Some of the examples in this lecture are taken from a tutorial on HMMs by Wolgang Maass.
1 Hidden Markov Models Hsin-min Wang References: 1.L. R. Rabiner and B. H. Juang, (1993) Fundamentals of Speech Recognition, Chapter.
Hidden Markov Model Parameter Estimation BMI/CS 576 Colin Dewey Fall 2015.
Hidden Markov Models. A Hidden Markov Model consists of 1.A sequence of states {X t |t  T } = {X 1, X 2,..., X T }, and 2.A sequence of observations.
Data-Intensive Computing with MapReduce Jimmy Lin University of Maryland Thursday, March 14, 2013 Session 8: Sequence Labeling This work is licensed under.
Definition of the Hidden Markov Model A Seminar Speech Recognition presentation A Seminar Speech Recognition presentation October 24 th 2002 Pieter Bas.
N-Gram Model Formulas Word sequences Chain rule of probability Bigram approximation N-gram approximation.
Visual Recognition Tutorial1 Markov models Hidden Markov models Forward/Backward algorithm Viterbi algorithm Baum-Welch estimation algorithm Hidden.
Hidden Markov Models HMM Hassanin M. Al-Barhamtoshy
Hidden Markov Models BMI/CS 576
N-Gram Model Formulas Word sequences Chain rule of probability
CONTEXT DEPENDENT CLASSIFICATION
CPSC 503 Computational Linguistics
Presentation transcript:

Statistical NLP: Hidden Markov Models Updated 8/12/2005

Markov Models Markov models are statistical tools that are useful for NLP because they can be used for part-of-speech-tagging applications Their first use was in modeling the letter sequences in works of Russian literature They were later developed as a general statistical tool More specifically, they model a sequence (perhaps through time) of random variables that are not necessarily independent They rely on two assumptions: Limited Horizon and Time Invariant

Markov Assumptions Let X=(X 1,.., X t ) be a sequence of random variables taking values in some finite set S={s 1, …, s n }, the state space, the Markov properties are: Limited Horizon: P(X t+1 =s k |X 1,.., X t )=P(X t+1 = s k |X t ) i.e., a word ’ s tag only depends on the previous tag. Time Invariant: P(X t+1 =s k |X t )=P(X 2 =s k |X 1 ) i.e., the dependency does not change over time. If X possesses these properties, then X is said to be a Markov Chain

Markov Model parameters A Markov chain is described by: Stochastic transition matrix a ij = p(X t+1 = s j | X t = s i ) Probabilities of initial states of chain  i = p(X 1 = s i ) there are obvious normalization constraints on a and on . Finally a Markov Model is formally specified by a three-tuple (S, , A) where S is the set of states, and , A are the probabilities for the initial state and state transitions.

Probability of sequence of states By Markov assumption P(X 1, X 2, … X T ) = p(X 1 ) p(X 2 |X 1 ) … p(X T |X T-1 ) =  X1  t=1 T a Xt, Xt+1

Example of a Markov Chain te h a p i Start Probability of sequence of states: P(t, i, p) = p(X1 = t) p(X 2 =i| X 1 =t) p(X 3 =p| X 2 =i) = 1.0 * 0.3 * 0.6 = 0.18

Are n-gram models Markov Models? Bi-gram models are obviously Markov Models. What about tri-gram, four-gram models etc.?

Hidden Markov Models (HMM) Here states are hidden. We have only ‘ clues ’ about states by the symbols each state outputs: P(O t = k | X t = s i, X t+1 = s j ) = b i,j,k

The crazy soft drink machine lemice_tcola CP IP Cola Preffered Ice tea Preffered start Output probability Comment: for this machine the output really depends only on s i namely b ijk = b ij

The crazy soft drink machine – cont. What is the probability of observing {lem, ice_t}? Need to sum over all 4 possible paths that might be taken through the HMM: 0.7*0.3*0.7* *0.3*0.3* *0.3*0.5* *0.3*0.5*0.7 = 0.084

Why Use Hidden Markov Models? HMMs are useful when one can think of underlying events probabilistically generating surface events. Example: Part-of-Speech-Tagging or speech. HMMs can efficiently be trained using the EM Algorithm. Another example where HMMs are useful is in generating parameters for linear interpolation of n-gram models.

wawbwawb wbw1wbw1 wbw2wbw2 wbwMwbwM 1 ab 2 ab 3 ab w 1 : P 1 (w 1 )  : 1  : 2  : 3 w 2 :P 1 (w 2 ) w M :P 1 (w M ) w M :P 3 (w M | w a w b ) interpoloating parameters for n-gram models

interpoloating parameters for n- gram models – comments the HMM calculation of observing the sequence (w n-2, w n-1, w n ) is equivalent to P lin (w n |w n-2,w n-1 )= 1 P 1 (w n )+ 2 P 2 (w n |w n-1 )+ 3 P 3 (w n |w n-1,w n-2 ) Transitions are special transitions that produce no output symbol In the above model each word pair (a,b) has a different HMM. This is relaxed by using tied states.

General Form of an HMM An HMM is specified by a five-tuple (S, K, , A, B) where S and K are the set of states and the output alphabet, and , A, B are the probabilities for the initial state, state transitions, and symbol emissions, respectively. Given a specification of an HMM, we can simulate the running of a Markov process and produce an output sequence using the algorithm shown on the next page. More interesting than a simulation, however, is assuming that some set of data was generated by a HMM, and then being able to calculate probabilities and probable underlying state sequences.

A Program for a Markov Process modeled by HMM t:= 1; Start in state s i with probability  i (i.e., X 1 =i) Forever do Move from state s i to state s j with probability a ij (i.e., X t+1 = j) Emit observation symbol o t = k with probability b ijk t:= t+1 End

The Three Fundamental Questions for HMMs Given a model  =(A, B,  ), how do we efficiently compute how likely a certain observation is, that is, P(O|  ) Given the observation sequence O and a model , how do we choose a state sequence (X 1, …, X T+1 ) that best explains the observations? Given an observation sequence O, and a space of possible models found by varying the model parameters  = (A, B,  ), how do we find the model that best explains the observed data?

Finding the probability of an observation I Given the observation sequence O=(o 1, …, o T ) and a model  = (A, B,  ), we wish to know how to efficiently compute P(O|  ). This process is called decoding. For any state sequence X=(X 1, …, X T+1 ), we find: P(O|  )=  X1 … XT+1  X1  t=1 T a XtXt+1 b XtXt+1ot This is simply the sum of the probability of the observation occurring according to each possible state sequence. Direct evaluation of this expression, however, is extremely inefficient.

Finding the probability of an observation II In order to avoid this complexity, we can use dynamic programming or memorization techniques. In particular, we use trellis algorithms. We make a square array of states versus time and compute the probabilities of being at each state at each time in terms of the probabilities for being in each state at the preceding time. A trellis can record the probability of all initial subpaths of the HMM that end in a certain state at a certain time. The probability of longer subpaths can then be worked out in terms of the shorter subpaths.

Finding the probability of an observation III: The forward procedure A forward variable,  i (t)= P(o 1 o 2 … o t-1, X t =i|  ) is stored at (s i, t)in the trellis and expresses the total probability of ending up in state si at time t. Forward variables are calculated as follows: Initialization:  i (1)=  i, 1  i  N Induction:  j (t+1)=  i=1 N  i (t)a ij b ijot, 1  t  T, 1  j  N Total: P(O|  )=  i=1 N  i (T+1) This algorithm requires 2N 2 T multiplications (much less than the direct method which takes (2T+1).N T+1

Finding the probability of an observation IV: The backward procedure The backward procedure computes backward variables which are the total probability of seeing the rest of the observation sequence given that we were in state s i at time t. Backward variables are useful for the problem of parameter estimation.

Finding the probability of an observation V: The backward procedure Let  i (t) = P(o t … o T | X t = i,  ) be the backward variables. Backward variables can be calculated working backward through the trellis as follows: Initialization :  i (T+1) = 1, 1  i  N Induction:  i (t) =  j=1 N a ij b ijot  j (t+1), 1  t  T, 1  i  N Total: P(O|  )=  i=1 N  i  i (1)

Finding the probability of an observation VI: Combining Forward and backward P(O, X t = i |  ) = P(o 1 … o T,X t = i |  ) = P(o 1 … o t-1,X t = i, o t, … o T |  ) = P(o 1 … o t-1,X t = i |  ) P( o t, … o T |o 1 … o t-1, X t = i,  ) = P(o 1 … o t-1,X t = i |  ) P( o t, … o T |X t = i,  ) =  i (t)  i (t), Total: P(O|  ) =  i=1 N  i (t)  i (t), 1  t  T+1

Finding the Best State Sequence I One method consists of finding the states individually: For each t, 1  t  T+1, we would like to find X t that maximizes P(X t |O,  ). Let  i (t) = P(X t = i |O,  ) = P(X t = i, O|  )/P(O|  ) = (  i (t)  i (t)/  j=1 N  j (t)  j (t)) The individually most likely state is X t =argmax 1  i  N  i (t), 1  t  T+1 This quantity maximizes the expected number of states that will be guessed correctly. However, it may yield a quite unlikely state sequence. ^

Finding the Best State Sequence II: The Viterbi Algorithm The Viterbi algorithm efficiently computes the most likely state sequence. Commonly, we want to find the most likely complete path, that is: argmax X P(X|O,  ) To do this, it is sufficient to maximize for a fixed O: argmax X P(X,O|  ) We define  j (t) = max X1..Xt-1 P(X 1 … X t-1, o 1..o t-1, X t =j|  )  j (t) records the node of the incoming arc that led to this most probable path.

Finding the Best State Sequence II: The Viterbi Algorithm The Viterbi Algorithm works as follows: Initialization:  j (1) =  j, 1  j  N Induction:  j (t+1) = max 1  i  N  i (t)a ij b ijot, 1  j  N Store backtrace:  j (t+1) = argmax 1  i  N  j (t)a ij b ijot, 1  j  N Termination and path readout: X T+1 = argmax 1  i  N  j (T+1) Xt =  Xt+1 (t+1) P(X) = max 1  i  N  j (T+1) ^ ^ ^

Parameter Estimation III Given a certain observation sequence, we want to find the values of the model parameters  =(A, B,  ) which best explain what we observed. Using Maximum Likelihood Estimation, we can want find the values that maximize P(O|  ), i.e. argmax  P(O training |  ) There is no known analytic method to choose  to maximize P(O|  ). However, we can locally maximize it by an iterative hill-climbing algorithm known as Baum-Welch or Forward-Backward algorithm. (special case of the EM Algorithm)

Parameter Estimation III (1) We don ’ t know what the model is, but we can work out the probability of the observation sequence using some (perhaps randomly chosen) model. Looking at that calculation, we can see which state transitions and symbol emissions were probably used the most. By increasing the probability of those, we can choose a revised model which gives a higher probability to the observation sequence.

Parameter Estimation III (2) Define P t (i,j) as the probability of traversing a certain arc at time t given observation sequence:

Parameter Estimation III (3) The probability of traversing a certain arc at time t given observation sequence can be expressed as: The probability of leaving state i at time t i

Parameter Estimation III (4)