Hidden Markov Models IP notice slides from Dan
- Slides: 80
Hidden Markov Models IP notice: slides from Dan Jurafsky
Outline Markov Chains l Hidden Markov Models l Three Algorithms for HMMs l § The Forward Algorithm § The Viterbi Algorithm § The Baum-Welch (EM Algorithm) l Applications: § The Ice Cream Task § Part of Speech Tagging
Chomsky Grammars l Distinguish grammatical English from ungrammatical English: § § § § § John thinks Sara hit the boy The hit thinks Sara John boy John thinks the boy was hit by Sara Who does John think Sara hit? John thinks Sara hit the boy and the girl Who does John think Sara hit the boy and? John thinks Sara hit the boy with the bat What does John think Sara hit the boy with? Colorless green ideas sleep furiously. Green sleep furiously ideas colorless.
Miniature English grammar and lexicon S → NP VP S → Aux NP VP S → VP NP → Pronoun NP → Proper-Noun NP → Det Nominal → Noun Nominal → Nominal PP VP → Verb NP PP VP → Verb PP VP → VP PP PP → Preposition NP Det → that | this | a Noun → book | flight | meal | money Verb → book | include | prefer Pronoun → I | she | me Proper-Noun → Houston | TWA Aux → does Preposition → from | to | on | near | through
Sentence Generation S → VP VP → Verb NP Verb → book NP → Det Nominal Det → that Nominal → Noun → flight Book that flight
Acceptors and Transformers Chomsky’s grammars are about which utterances are acceptable l Other research programs are aimed at transforming utterances l § Translate a English sentence into Japanese… § Transform a speech waveform into transcribed words… § Compress a sentence, summarize a text… § Transform a syntactic analysis into a semantic analysis… § Generate a text from a semantic representation…
Strings and Trees l Trees are a useful representation for grammatical structure § A sentence is a noun phrase (NP) followed by a verb phrase (VP) § A noun phrase is a determiner (DT) followed by a noun (NN) § A noun phrase is a noun phrase (NP) followed by a prepositional phrase (PP) § A PP is a preposition (IN) followed by an NP S NP NP PP IN l l VP NP A string is acceptable if it has an acceptable tree Transformations may take place at the tree level
Natural Language Processing 1980 s: Many tree-based grammatical formalisms l 1990 s: Regression to sequence-based formalisms l § Hidden Markov Models (HMM), Finite-State Acceptors (FSAs) and Transducers (FSTs) § N-gram models for accepting sentences [e. g. , Jelinek 90] § Taggers and other statistical transformations [e. g. , Church 88] § Machine translation [e. g. , Brown et al. 93] § Software toolkits implementing generic weighted FST operations [e. g. , Mohri, Pereira, Riley 00]
Natural Language Processing l 2000 s: Emerging interest in tree-based probabilistic models § Machine translation • [Wu 97, Yamada & Knight 02, Melamed 03, Chiang 05, …] § Summarization • [Knight & Marcu 00, …] § Paraphrasing • [Pang et al 03, …] § Question answering • [Echihabi & Marcu 03, …] § Natural language generation • [Bangalore & Rambow 00, …]
FSA and FST Unweighted Acceptors Transducers c c: z a a: x e Weighted e: y a/. 5 e/. 5 c/. 7 a: x/. 5 e: y/. 5 c: z/. 7
Finite-State Transducer (FST) Original input: k n i g h t k: ε i : AY q g: ε Transformation: q q 2 n: N q 3 h: ε qfinal q 4 t: T
Finite-State (String) Transducer Original input: k n i g h t i : AY Transformation: k: q g: ε ε q 2 n: N q 3 h: qfinal ε q 4 t: T q 2
Finite-State (String) Transducer Original input: k n i g h t i : AY Transformation: k: ε q g: ε q 2 n: N q 3 h: qfinal ε q 4 t: T N
Finite-State (String) Transducer Original input: k n i g h t i : AY Transformation: k : ε q g: ε q 2 n: N q 3 h : ε q 4 qfinal t: T N AY q
Finite-State (String) Transducer Original input: k i : AY n i Transformation: k: q g: ε ε q 2 n: N q 3 qfinal h: ε q 4 N t: T AY g h t q 3
Finite-State (String) Transducer Original input: Transformation: k i : AY n k: q g: i ε ε q 2 n: N q 3 qfinal h: ε q 4 t: T N AY g h t q 4
Finite-State (String) Transducer Original input: k n i i : AY Transformation: k: q g: ε ε q 2 n: N q 3 qfinal h: ε q 4 N t: T AY g h t T qfinal
Definitions l A Weighted Finite-State Automaton (WFSA) § An FSA with probabilities on the arcs § The sum of the probabilities leaving any arc must sum to one l A Markov Chain (or observable Markov Model) § a special case of a WFST in which the input sequence uniquely determines which states the automaton will go through l Markov Chains can’t represent inherently ambiguous problems § Useful for assigning probabilities to unambiguous sequences
Weighted Finite State Transducer l l l FST: FSA whose state transitions are labeled with both input and output symbols. A weighted transducer puts weights on transitions in addition to the input and output symbols Weights may encode probabilities, durations, penalties, . . . Used in speech recognition Tutorial at http: //www. cs. nyu. edu/~mohri/pub/hbka. pdf
Markov Chain for weather
Markov Chain for words
Markov Chain First-order observable Markov Model l A set of states Q l § q 1, q 2…q. N sequence of states: state at time t is qt l Transition probabilities: § a set of probabilities A = a 01 a 02…an 1…ann. § Each aij represents the probability of transitioning from state i to state j l Distinguished start and end states
Markov Chain Markov Assumption: l Current state only depends on previous state P(qi | q 1 … qi-1) = P(qi | qi-1)
Another representation for start state Instead of start state l Special initial probability vector l § An initial distribution over probability of start states l Constraints:
The weather model using
The weather model: specific example
Markov chain for weather What is the probability of 4 consecutive warm days? l Sequence is warm-warm-warm l i. e. , state sequence is 3 -3 -3 -3 l P(3, 3, 3, 3) = 3 a 33 a 33 = 0. 2 • (0. 6)3 = 0. 0432
How about? Hot hot hot l Cold hot cold hot l l What does the difference in these probabilities tell you about the real world weather info encoded in the figure?
HMM for Ice Cream l l l You are a climatologist in the year 2799 Studying global warming You can’t find any records of the weather in Baltimore, MD for summer of 2008 But you find Jason Eisner’s diary Which lists how many ice-creams Jason ate every date that summer Our job: figure out how hot it was
Hidden Markov Model l For Markov chains, the output symbols are the same as the states. § See hot weather: we are in state hot l But in named-entity or part-of-speech tagging (and speech recognition and other things) § The output symbols are words § But the hidden states are something else • Part-of-speech tags • Named entity tags So we need an extension! l A Hidden Markov Model is an extension of a Markov chain in which the input symbols are not the same as the states. l This means we don’t know which state we are in. l
Hidden Markov Models
Assumptions l Markov assumption: P(qi | q 1 … qi-1) = P(qi | qi-1) l Output-independence assumption
Eisner task l Given § Ice Cream Observation Sequence: 1, 2, 3, 2, 2, 2, 3… l Produce: § Weather Sequence: H, C, H, H, H, C…
HMM for ice cream
Different types of HMM structure Bakis = left-to-right Ergodic = fully-connected
The Three Basic Problems for HMMs l l l Jack Ferguson at IDA in the 1960 s Problem 1 (Evaluation): Given the observation sequence O=(o 1 o 2…o. T), and an HMM model = (A, B), how do we efficiently compute P(O| ), the probability of the observation sequence, given the model Problem 2 (Decoding): Given the observation sequence O=(o 1 o 2…o. T), and an HMM model = (A, B), how do we choose a corresponding state sequence Q=(q 1 q 2…q. T) that is optimal in some sense (i. e. , best explains the observations) Problem 3 (Learning): How do we adjust the model parameters = (A, B) to maximize P(O| )?
Problem 1: computing the observation likelihood l Given the following HMM: l How likely is the sequence 3 1 3?
How to compute likelihood For a Markov chain, we just follow the states 3 1 3 and multiply the probabilities l But for an HMM, we don’t know what the states are! l So let’s start with a simpler situation. l Computing the observation likelihood for a given hidden state sequence l § Suppose we knew the weather and wanted to predict how much ice cream Jason would eat. § i. e. P( 3 1 3 | H H C)
Computing likelihood of 3 1 3 given hidden state sequence
Computing joint probability of observation and state sequence
Computing total likelihood of 3 1 3 l We would need to sum over § § Hot hot cold Hot hot Hot cold hot …. l How many possible hidden state sequences are there for this sequence? l How about in general for an HMM with N hidden states and a sequence of T observations? § NT l So we can’t just do separate computation for each hidden state sequence.
Instead: the Forward algorithm l A kind of dynamic programming algorithm § Just like Minimum Edit Distance § Uses a table to store intermediate values l Idea: § Compute the likelihood of the observation sequence § By summing over all possible hidden state sequences § But doing this efficiently • By folding all the sequences into a single trellis
The forward algorithm l The goal of the forward algorithm is to compute P(o 1, o 2 … o. T, q. T = q. F | l) l We’ll do this by recursion
The forward algorithm l Each cell of the forward algorithm trellis at(j) § Represents the probability of being in state j § After seeing the first t observations § Given the automaton l Each cell thus expresses the following probability at(j) = P(o 1, o 2 … ot, qt = j | l)
The Forward Recursion
The Forward Trellis
We update each cell
The Forward Algorithm
Decoding l Given an observation sequence § 3 1 3 And an HMM l The task of the decoder l § To find the best hidden state sequence l Given the observation sequence O=(o 1 o 2…o. T), and an HMM model = (A, B), how do we choose a corresponding state sequence Q=(q 1 q 2…q. T) that is optimal in some sense (i. e. , best explains the observations)
Decoding l One possibility: § For each hidden state sequence Q • HHH, HHC, HCH, § Compute P(O|Q) § Pick the highest one l Why not? § NT l Instead: § § § The Viterbi algorithm Is again a dynamic programming algorithm Uses a similar trellis to the Forward algorithm
Viterbi intuition l We want to compute the joint probability of the observation sequence together with the best state sequence
Viterbi Recursion
The Viterbi trellis
Viterbi intuition l l l Process observation sequence left to right Filling out the trellis Each cell:
Viterbi Algorithm
Viterbi backtrace
Training a HMM Forward-backward or Baum-Welch algorithm (Expectation Maximization) l Backward probability (prob. of observations from t+1 to T) bt(i) = P(ot+1, ot+2…o. T | qt = i, l) b. T(i) = ai, F 1 i N l
function FORWARD-BACKWARD(observations of len T, output vocabulary V, hidden state set Q) returns HMM=(A, B) initialize A and B iterate until convergence E-step M-step return A, B
Hidden Markov Models for Part of Speech Tagging
Part of speech tagging l 8 (ish) traditional English parts of speech § Noun, verb, adjective, preposition, adverb, article, interjection, pronoun, conjunction, etc. § This idea has been around for over 2000 years (Dionysius Thrax of Alexandria, c. 100 B. C. ) § Called: parts-of-speech, lexical category, word classes, morphological classes, lexical tags, POS § We’ll use POS most frequently § Assuming that you know what these are
POS examples l l l l N V ADJ ADV P PRO DET noun chair, bandwidth, pacing verb study, debate, munch adj purple, tall, ridiculous adverb unfortunately, slowly, preposition of, by, to pronoun I, me, mine determiner the, a, that, those
POS Tagging example WORD tag the koala put the keys on the table DET N V DET N P DET N
POS Tagging l Words often have more than one POS: back § § l The back door = JJ On my back = NN Win the voters back = RB Promised to back the bill = VB The POS tagging problem is to determine the POS tag for a particular instance of a word. These examples from Dekang Lin
POS tagging as a sequence classification task l We are given a sentence (an “observation” or “sequence of observations”) § Secretariat is expected to race tomorrow § She promised to back the bill What is the best sequence of tags which corresponds to this sequence of observations? l Probabilistic view: l § Consider all possible sequences of tags § Out of this universe of sequences, choose the tag sequence which is most probable given the observation sequence of n words w 1…wn.
Getting to HMM l We want, out of all sequences of n tags t 1…tn the single tag sequence such that P(t 1…tn|w 1…wn) is highest. Hat ^ means “our estimate of the best one” l argmaxx f(x) means “the x such that f(x) is maximized” l
Getting to HMM l This equation is guaranteed to give us the best tag sequence But how to make it operational? How to compute this value? l Intuition of Bayesian classification: l § Use Bayes rule to transform into a set of other probabilities that are easier to compute
Using Bayes Rule
Likelihood and prior n
Two kinds of probabilities (1) l Tag transition probabilities P(ti|ti-1) § Determiners likely to precede adjs and nouns • • That/DT flight/NN The/DT yellow/JJ hat/NN So we expect P(NN|DT) and P(JJ|DT) to be high But P(DT|JJ) to be low § Compute P(NN|DT) by counting in a labeled corpus:
Two kinds of probabilities (2) l Word likelihood probabilities P(wi|ti) § VBZ (3 sg Pres verb) likely to be “is” § Compute P(is|VBZ) by counting in a labeled corpus:
An Example: the verb “race” Secretariat/NNP is/VBZ expected/VBN to/TO race/VB tomorrow/NR l People/NNS continue/VB to/TO inquire/VB the/DT reason/NN for/IN the/DT race/NN for/IN outer/JJ space/NN l How do we pick the right tag? l
Disambiguating “race”
ML Estimation l l l P(NN|TO) =. 00047 P(VB|TO) =. 83 P(race|NN) =. 00057 P(race|VB) =. 00012 P(NR|VB) =. 0027 P(NR|NN) =. 0012 P(VB|TO)P(race|VB)P(NR|VB) =. 00000027 l P(NN|TO)P(race|NN)P(NR|NN) =. 0000032 l l So we (correctly) choose the verb reading
HMM for Po. S tagging • Transitions probabilities A between the hidden states: tags
B observation likelihoods for POS HMM l Emission probabilities B: words
The A matrix for the POS HMM
The B matrix for the POS HMM
Viterbi intuition: we are looking for the best ‘path’ S 1 S 2 Slide from Dekang Lin S 3 S 4 S 5
Viterbi example
Outline l l l Markov Chains Hidden Markov Models Three Algorithms for HMMs § The Forward Algorithm § The Viterbi Algorithm § The Baum-Welch (EM Algorithm) l Applications: § The Ice Cream Task § Part of Speech Tagging § Next time: Named Entity Tagging
- A revealing introduction to hidden markov models
- A revealing introduction to hidden markov models
- Hidden markov models
- Hidden markov chain
- Hidden markov model rock paper scissors
- Hidden markov model tutorial
- Hidden markov chain
- Hidden markov chain
- Hidden markov map matching through noise and sparseness
- Rabiner hmm
- Hidden markov model
- Copyright notice on powerpoint slides
- A small child slides down the four frictionless slides
- Starting from rest a marble first rolls down
- Modals and semi-modals
- Markov chain absorbing state
- Markov chain absorbing state
- Gauss markov assumptions
- What is markov analysis
- Bing
- Mdp example
- Gauss markov assumptions
- Gauss markov assumptions
- Discrete bayes filter
- Embedded markov chain
- Markov chain nlp
- Aperiodic markov chain
- Embedded markov chain
- Markov random field
- Properties of directed acyclic graph
- Markov decision process merupakan tuple dari
- Markov model
- Markov decision
- Puterman markov decision processes
- Aperiodic markov chain
- Chapman kolmogorov equation
- Aperiodic markov chain
- What is markov analysis
- Markov localization
- Markov's inequality
- Markov localization
- Markov localization
- Bmics
- Interpolated markov model
- Markov employee transition in hrm
- Gauss-markov teoremi
- Aperiodic markov chain
- Gauss markov assumptions
- Aperiodic markov chain
- Chebyshev's theorem
- Markov decision
- Markov inequality proof
- Markov decision
- định lý gauss markov
- Properties of least square estimator
- Markov analysis
- What is markov analysis
- Example of markov analysis
- Cadenas
- Fuente de markov
- Markov localization
- Alimam
- Markov chain monte carlo tutorial
- Contoh soal rantai markov waktu diskrit
- Embedded markov chain
- Riset operasi
- Contoh soal ketaksamaan chebyshev
- Andrei andreyevich markov
- Rantai markov waktu diskrit
- Lee wee sun
- Value iteration
- Markov
- Contoh kasus, analisis markov
- Markov's inequality
- Markov process adalah
- Pijipin
- Markov model
- Value iteration
- Markov modell
- Djevojka nadmudrila marka analiza
- Markov