hidden markov models

Hidden Markov Models Alan Ri1er Sequences of R.V.s - PowerPoint PPT Presentation

Hidden Markov Models Alan Ri1er Sequences of R.V.s Previously we assumed IID data P ( x 1 , x 2 , x 3 , . . . , x n ) = P ( x 1 ) P ( x 2 ) P ( x 3 ) . . . P ( x n ) This is


  1. Hidden ¡Markov ¡Models ¡ Alan ¡Ri1er ¡

  2. Sequences ¡of ¡R.V.s ¡ • Previously ¡we ¡assumed ¡IID ¡data ¡ P ( x 1 , x 2 , x 3 , . . . , x n ) ¡ = P ( x 1 ) P ( x 2 ) P ( x 3 ) . . . P ( x n ) • This ¡is ¡a ¡useful ¡assumpCon ¡ – Makes ¡inference ¡easy ¡ • But, ¡oFen ¡too ¡restricCve ¡ – E.g. ¡Sequences ¡of ¡words ¡not ¡really ¡independent ¡ • Q: ¡how ¡can ¡we ¡introduce ¡some ¡dependence ¡ without ¡blowing ¡up ¡inference ¡and ¡ #parameters? ¡

  3. ( non-­‑ hidden) ¡Markov ¡Models ¡ • Answer: ¡Markov ¡AssumpCon ¡ P ( x k | x 1 , x 2 , x 3 , . . . , x k − 1 ) = P ( x k | x k − 1 ) • EnCre ¡history ¡is ¡captured ¡by ¡previous ¡state ¡ P ( x 1 , x 2 , x 3 , . . . , x n ) = P ( x 1 ) P ( x 2 | x 1 ) P ( x 3 | x 1 , x 2 ) . . . P ( x n | x 1 , x 2 , x 3 , . . . , x n − 1 ) = P ( x 1 ) P ( x 2 | x 1 ) P ( x 3 | x 2 ) . . . P ( x n | x n − 1 )

  4. ApplicaCon: ¡Language ¡Modeling ¡ • Random ¡variables: ¡ – Sequences ¡of ¡words ¡or ¡characters ¡ • EsCmate ¡transiCon ¡probabiliCes ¡from ¡data ¡ using ¡maximum ¡likelihood ¡ • State ¡space: ¡all ¡English ¡words ¡ • IID ¡AssumpCon ¡=> ¡unigram ¡language ¡model ¡ • First-­‑order ¡Markov ¡Model ¡=> ¡bigram ¡LM ¡ • Second-­‑order ¡=> ¡trigram ¡LM ¡

  5. ApplicaCon: ¡Language ¡Modeling ¡ • Unigram ¡LM: ¡ P ( x k | x 1 , x 2 , x 3 , . . . , x k − 1 ) = P ( x k ) • Bigram ¡LM ¡(First-­‑order ¡Markov ¡Model): ¡ P ( x k | x 1 , x 2 , x 3 , . . . , x k − 1 ) = P ( x k | x k − 1 ) • Trigram ¡LM ¡(Second-­‑order ¡Markov ¡Model): ¡ P ( x k | x 1 , x 2 , x 3 , . . . , x k − 1 ) = P ( x k | x k − 1 , x k − 2 )

  6. Bigrams Unigrams _ a b c d e f g h i j k l m n o p q r s t u v w x y z 1 0.16098 _ _ 2 0.06687 a a 3 0.01414 b b 4 0.02938 c c 5 0.03107 d d 6 0.11055 e e 7 0.02325 f f 8 0.01530 g g 9 0.04174 h h 10 0.06233 i i 11 0.00060 j j 12 0.00309 k k 13 0.03515 l l 14 0.02107 m m 15 0.06007 n n 16 0.06066 o o 17 0.01594 p p 18 0.00077 q q 19 0.05265 r r 20 0.05761 s s 21 0.07566 t t 22 0.02149 u u 23 0.00993 v v 24 0.01341 w w 25 0.00208 x x 26 0.01381 y y 27 0.00039 z z

  7. What ¡is ¡Language ¡Modeling ¡Used ¡For? ¡ • Sentence ¡CompleCon ¡ – PredicCve ¡Text ¡Input ¡ • ClassificaCon ¡ – Naïve ¡bayes ¡== ¡unigram ¡ • Machine ¡TranslaCon ¡ ¡

  8. Hidden Markov Models (Slides ¡from ¡Pedro ¡Domingos) ¡ ¡ 1 ¡ 1 ¡ 1 ¡ 1 ¡ 1 ¡ … 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ … … … … … K ¡ K ¡ K ¡ K ¡ K ¡ … x 1 x 2 x 3 x K

  9. Example: The dishonest casino A casino has two dice: • Fair die P(1) = P(2) = P(3) = P(4) = P(5) = P(6) = 1/6 • Loaded die P(1) = P(2) = P(3) = P(4) = P(5) = 1/10 P(6) = 1/2 Casino player switches from fair to loaded die with probability 1/20 at each turn Game: 1. You bet $1 2. You roll (always with a fair die) 3. Casino player rolls (maybe with fair die, maybe with loaded die) 4. Highest number wins $2

  10. Question # 1 – Decoding GIVEN A sequence of rolls by the casino player 1245526462146146136136661664661636616366163616515615115146123562344 FAIR LOADED FAIR QUESTION What portion of the sequence was generated with the fair die, and what portion with the loaded die? This is the DECODING question in HMMs

  11. Question # 2 – Evaluation GIVEN A sequence of rolls by the casino player 1245526462146146136136661664661636616366163616515615115146123562344 Prob = 1.3 x 10 -35 QUESTION How likely is this sequence, given our model of how the casino works? This is the EVALUATION problem in HMMs

  12. Question # 3 – Learning GIVEN A sequence of rolls by the casino player 1245526462146146136136661664661636616366163616515615115146123562344 Prob(6) = 64% QUESTION How “ loaded ” is the loaded die? How “ fair ” is the fair die? How often does the casino player change from fair to loaded, and back? This is the LEARNING question in HMMs

  13. The dishonest casino model 0.05 0.95 0.95 FAIR ¡ LOADED ¡ P(1|F) = 1/6 P(1|L) = 1/10 P(2|F) = 1/6 P(2|L) = 1/10 0.05 P(3|F) = 1/6 P(3|L) = 1/10 P(4|F) = 1/6 P(4|L) = 1/10 P(5|F) = 1/6 P(5|L) = 1/10 P(6|F) = 1/6 P(6|L) = 1/2

  14. An HMM is memoryless 1 ¡ 2 ¡ At each time step t, the only thing that affects future states is the current state π t K ¡ … ¡

  15. An HMM is memoryless 1 ¡ 2 ¡ At each time step t, the only thing that affects future states is the current state π t K ¡ … ¡ P( π t+1 = k | “ whatever happened so far ” ) = P( π t+1 = k | π 1 , π 2 , … , π t , x 1 , x 2 , … , x t ) = P( π t+1 = k | π t )

  16. An HMM is memoryless 1 ¡ 2 ¡ At each time step t, the only thing that affects x t is the current state π t K ¡ … ¡ P(x t = b | “ whatever happened so far ” ) = P(x t = b | π 1 , π 2 , … , π t , x 1 , x 2 , … , x t-1 ) = P(x t = b | π t )

  17. Definition of a hidden Markov model Definition: A hidden Markov model (HMM) • Alphabet Σ = { b 1 , b 2 , … , b M } • Set of states Q = { 1, ..., K } • Transition probabilities between any two states 1 ¡ 2 ¡ a ij = transition prob from state i to state j a i1 + … + a iK = 1, for all states i = 1 … K • Start probabilities a 0i K ¡ … ¡ a 01 + … + a 0K = 1 • Emission probabilities within each state e i (b) = P( x i = b | π i = k) e i (b 1 ) + … + e i (b M ) = 1, for all states i = 1 … K

  18. A parse of a sequence Given a sequence x = x 1 …… x N , A parse of x is a sequence of states π = π 1 , …… , π N 1 ¡ 1 ¡ 1 ¡ 1 ¡ 1 ¡ … 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ … … … … … K ¡ K ¡ K ¡ K ¡ K ¡ … x 1 x 2 x 3 x K

  19. Generating a sequence by the model Given a HMM, we can generate a sequence of length n as follows: 1. Start at state π 1 according to prob a 0 π 1 2. Emit letter x 1 according to prob e π 1 (x 1 ) 3. Go to state π 2 according to prob a π 1 π 2 4. … until emitting x n 1 ¡ 1 ¡ 1 ¡ 1 ¡ 1 ¡ … a 02 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ … 0 ¡ … … … … K ¡ K ¡ K ¡ K ¡ K ¡ … e 2 (x 1 ) x 1 x 2 x 3 x n

  20. Likelihood of a parse 1 ¡ 1 ¡ 1 ¡ 1 ¡ 1 ¡ … 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ 2 ¡ … Given a sequence x = x 1 …… x N … … … … and a parse π = π 1 , …… , π N , K ¡ K ¡ K ¡ K ¡ K ¡ … x 1 x 2 x 3 x K To find how likely this scenario is: (given our HMM) P(x, π ) = P(x 1 , … , x N , π 1 , …… , π N ) = P(x N | π N ) P( π N | π N-1 ) …… P(x 2 | π 2 ) P( π 2 | π 1 ) P(x 1 | π 1 ) P( π 1 ) = a 0 π 1 a π 1 π 2 …… a π N-1 π N e π 1 (x 1 ) …… e π N (x N )

  21. Example: the dishonest casino Let the sequence of rolls be: x = 1, 2, 1, 5, 6, 2, 1, 5, 2, 4 Then, what is the likelihood of π = Fair, Fair, Fair, Fair, Fair, Fair, Fair, Fair, Fair, Fair? (say initial probs a 0Fair = ½ , a oLoaded = ½ ) ½ × P(1 | Fair) P(Fair | Fair) P(2 | Fair) P(Fair | Fair) … P(4 | Fair) = ½ × (1/6) 10 × (0.95) 9 = .00000000521158647211 ~= 0.5 × 10 -9

  22. Example: the dishonest casino So, ¡the ¡likelihood ¡the ¡die ¡is ¡fair ¡in ¡this ¡run ¡ is ¡just ¡0.521 ¡ × ¡10 -­‑9 ¡ ¡ What ¡is ¡the ¡likelihood ¡of ¡ ¡ π ¡ = ¡Loaded, ¡Loaded, ¡Loaded, ¡Loaded, ¡Loaded, ¡Loaded, ¡Loaded, ¡Loaded, ¡ Loaded, ¡Loaded? ¡ ½ ¡ × ¡P(1 ¡| ¡Loaded) ¡P(Loaded, ¡Loaded) ¡… ¡P(4 ¡| ¡Loaded) ¡= ¡ ¡ ½ ¡ × ¡(1/10) 9 ¡ × ¡(1/2) 1 ¡(0.95) 9 ¡= ¡.00000000015756235243 ¡~= ¡0.16 ¡ × ¡10 -­‑9 ¡ ¡ Therefore, ¡it ’ s ¡somewhat ¡more ¡likely ¡that ¡all ¡the ¡rolls ¡are ¡done ¡with ¡the ¡fair ¡ die, ¡than ¡that ¡they ¡are ¡all ¡done ¡with ¡the ¡loaded ¡die ¡

  23. Example: the dishonest casino Let the sequence of rolls be: x = 1, 6, 6, 5, 6, 2, 6, 6, 3, 6 Now, what is the likelihood π = F, F, … , F? ½ × (1/6) 10 × (0.95) 9 ~= 0.5 × 10 -9 , same as before What is the likelihood π = L, L, … , L? ½ × (1/10) 4 × (1/2) 6 (0.95) 9 = .00000049238235134735 ~= 0.5 × 10 -7 So, it is 100 times more likely the die is loaded

  24. The three main questions on HMMs 1. Decoding GIVEN a HMM M, and a sequence x, FIND the sequence π of states that maximizes P[ x, π | M ] 2. Evaluation GIVEN a HMM M, and a sequence x, FIND Prob[ x | M ] 3. Learning GIVEN a HMM M, with unspecified transition/emission probs., and a sequence x, FIND parameters θ = (e i (.), a ij ) that maximize P[ x | θ ]

  25. Problem 1: Decoding Find the most likely parse of a sequence

Recommend


More recommend