CS 2750: Machine Learning Hidden Markov Models Prof. Adriana Kovashka University of Pittsburgh March 21, 2016 All slides are from Ray Mooney.

Slides:



Advertisements
Similar presentations
Three Basic Problems Compute the probability of a text: P m (W 1,N ) Compute maximum probability tag sequence: arg max T 1,N P m (T 1,N | W 1,N ) Compute.
Advertisements

Three Basic Problems 1.Compute the probability of a text (observation) language modeling – evaluate alternative texts and models P m (W 1,N ) 2.Compute.
CPSC 422, Lecture 16Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 16 Feb, 11, 2015.
HMM II: Parameter Estimation. Reminder: Hidden Markov Model Markov Chain transition probabilities: p(S i+1 = t|S i = s) = a st Emission probabilities:
Part of Speech Tagging The DT students NN went VB to P class NN Plays VB NN well ADV NN with P others NN DT Fruit NN flies NN VB NN VB like VB P VB a DT.
Part-of-speech tagging. Parts of Speech Perhaps starting with Aristotle in the West (384–322 BCE) the idea of having parts of speech lexical categories,
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.
Statistical NLP: Lecture 11
Chapter 6: HIDDEN MARKOV AND MAXIMUM ENTROPY Heshaam Faili University of Tehran.
Hidden Markov Models Theory By Johan Walters (SR 2003)
Lecture 15 Hidden Markov Models Dr. Jianjun Hu mleg.cse.sc.edu/edu/csce833 CSCE833 Machine Learning University of South Carolina Department of Computer.
Tagging with Hidden Markov Models. Viterbi Algorithm. Forward-backward algorithm Reading: Chap 6, Jurafsky & Martin Instructor: Paul Tarau, based on Rada.
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.
Hidden Markov Model 11/28/07. Bayes Rule The posterior distribution Select k with the largest posterior distribution. Minimizes the average misclassification.
Ch 10 Part-of-Speech Tagging Edited from: L. Venkata Subramaniam February 28, 2002.
Hidden Markov Models K 1 … 2. Outline Hidden Markov Models – Formalism The Three Basic Problems of HMMs Solutions Applications of HMMs for Automatic Speech.
Learning HMM parameters Sushmita Roy BMI/CS 576 Oct 21 st, 2014.
Rutgers CS440, Fall 2003 Introduction to Statistical Learning Reading: Ch. 20, Sec. 1-4, AIMA 2 nd Ed.
Crash Course on Machine Learning
1 Sequence Labeling Raymond J. Mooney University of Texas at Austin.
Raymond J. Mooney University of Texas at Austin
ETHEM ALPAYDIN © The MIT Press, Lecture Slides for.
Computer vision: models, learning and inference
1 Computational Lexicology, Morphology and Syntax Course 5 Diana Trandab ă ț Academic year:
CS 4705 Hidden Markov Models Julia Hirschberg CS4705.
Named Entity Tagging Thanks to Dan Jurafsky, Jim Martin, Ray Mooney, Tom Mitchell for slides.
Sequence Models With slides by me, Joshua Goodman, Fei Xia.
CS774. Markov Random Field : Theory and Application Lecture 19 Kyomin Jung KAIST Nov
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
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.
1 CONTEXT DEPENDENT CLASSIFICATION  Remember: Bayes rule  Here: The class to which a feature vector belongs depends on:  Its own value  The values.
CPSC 422, Lecture 15Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 15 Oct, 14, 2015.
CSE 517 Natural Language Processing Winter 2015
Web-Mining Agents Probabilistic Reasoning over Time Prof. Dr. Ralf Möller Universität zu Lübeck Institut für Informationssysteme Karsten Martiny (Übungen)
1 Hidden Markov Models Hsin-min Wang References: 1.L. R. Rabiner and B. H. Juang, (1993) Fundamentals of Speech Recognition, Chapter.
Statistical Models for Automatic Speech Recognition Lukáš Burget.
Hidden Markov Model Parameter Estimation BMI/CS 576 Colin Dewey Fall 2015.
Part-of-Speech Tagging CSCI-GA.2590 – Lecture 4 Ralph Grishman NYU.
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.
Dan Roth University of Illinois, Urbana-Champaign 7 Sequential Models Tutorial on Machine Learning in Natural.
Part-of-Speech Tagging CSE 628 Niranjan Balasubramanian Many slides and material from: Ray Mooney (UT Austin) Mausam (IIT Delhi) * * Mausam’s excellent.
Hidden Markov Models HMM Hassanin M. Al-Barhamtoshy
Hidden Markov Models BMI/CS 576
Learning, Uncertainty, and Information: Learning Parameters
Introduction to Machine Learning and Text Mining
Named Entity Tagging Thanks to Dan Jurafsky, Jim Martin, Ray Mooney, Tom Mitchell for slides.
Statistical Models for Automatic Speech Recognition
CSC 594 Topics in AI – Natural Language Processing
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 15
Data Mining Lecture 11.
CS 388: Natural Language Processing: Statistical Parsing
CS 2750: Machine Learning Hidden Markov Models
CSCI 5832 Natural Language Processing
CSC 594 Topics in AI – Natural Language Processing
Machine Learning in Natural Language Processing
Hidden Markov Models Part 2: Algorithms
CS 1675: Intro to Machine Learning Probabilistic Graphical Models
Statistical Models for Automatic Speech Recognition
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 15
N-Gram Model Formulas Word sequences Chain rule of probability
CONTEXT DEPENDENT CLASSIFICATION
Named Entity Tagging Thanks to Dan Jurafsky, Jim Martin, Ray Mooney, Tom Mitchell for slides.
Raymond J. Mooney University of Texas at Austin
Raymond J. Mooney University of Texas at Austin
Part-of-Speech Tagging Using Hidden Markov Models
Presentation transcript:

CS 2750: Machine Learning Hidden Markov Models Prof. Adriana Kovashka University of Pittsburgh March 21, 2016 All slides are from Ray Mooney

2 Motivating Example: Part Of Speech Tagging Annotate each word in a sentence with a part-of-speech marker. Lowest level of syntactic analysis. Useful for subsequent syntactic parsing and word sense disambiguation. John saw the saw and decided to take it to the table. NNP VBD DT NN CC VBD TO VB PRP IN DT NN

3 English Parts of Speech Noun (person, place or thing) –Singular (NN): dog, fork –Plural (NNS): dogs, forks –Proper (NNP, NNPS): John, Springfields –Personal pronoun (PRP): I, you, he, she, it –Wh-pronoun (WP): who, what Verb (actions and processes) –Base, infinitive (VB): eat –Past tense (VBD): ate –Gerund (VBG): eating –Past participle (VBN): eaten –Non 3 rd person singular present tense (VBP): eat –3 rd person singular present tense: (VBZ): eats –Modal (MD): should, can –To (TO): to (to eat)

4 English Parts of Speech (cont.) Adjective (modify nouns) –Basic (JJ): red, tall –Comparative (JJR): redder, taller –Superlative (JJS): reddest, tallest Adverb (modify verbs) –Basic (RB): quickly –Comparative (RBR): quicker –Superlative (RBS): quickest Preposition (IN): on, in, by, to, with Determiner: –Basic (DT) a, an, the –WH-determiner (WDT): which, that Coordinating Conjunction (CC): and, but, or, Particle (RP): off (took off), up (put up)

5 Ambiguity in POS Tagging “Like” can be a verb or a preposition –I like/VBP candy. –Time flies like/IN an arrow. “Around” can be a preposition, particle, or adverb –I bought it at the shop around/IN the corner. –I never got around/RP to getting a car. –A new Prius costs around/RB $25K.

6 Classification Learning Typical machine learning addresses the problem of classifying a feature-vector description into a fixed number of classes. There are many standard learning methods for this task: –Decision Trees and Rule Learning –Naïve Bayes and Bayesian Networks –Logistic Regression / Maximum Entropy (MaxEnt) –Perceptron and Neural Networks –Support Vector Machines (SVMs) –Nearest-Neighbor / Instance-Based

7 Beyond Classification Learning Standard classification problem assumes individual cases are disconnected and independent (i.i.d.: independently and identically distributed). Many NLP problems do not satisfy this assumption and involve making many connected decisions, each resolving a different ambiguity, but which are mutually dependent. More sophisticated learning and inference techniques are needed to handle such situations in general.

8 Sequence Labeling Problem Many NLP problems can viewed as sequence labeling. Each token in a sequence is assigned a label. Labels of tokens are dependent on the labels of other tokens in the sequence, particularly their neighbors (not i.i.d). foo bar blam zonk zonk bar blam

9 Information Extraction Identify phrases in language that refer to specific types of entities and relations in text. Named entity recognition is task of identifying names of people, places, organizations, etc. in text. people organizations places –Michael Dell is the CEO of Dell Computer Corporation and lives in Austin Texas. Extract pieces of information relevant to a specific application, e.g. used car ads: make model year mileage price –For sale, 2002 Toyota Prius, 20,000 mi, $15K or best offer. Available starting July 30, 2006.

10 Semantic Role Labeling For each clause, determine the semantic role played by each noun phrase that is an argument to the verb. agent patient source destination instrument –John drove Mary from Austin to Dallas in his Toyota Prius. –The hammer broke the window. Also referred to a “case role analysis,” “thematic analysis,” and “shallow semantic parsing”

11 Bioinformatics Sequence labeling also valuable in labeling genetic sequences in genome analysis. extron intron –AGCTAACGTTCGATACGGATTACAGCCT

12 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier NNP

13 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier VBD

14 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier DT

15 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier NN

16 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier CC

17 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier VBD

18 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier TO

19 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier VB

20 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier PRP

21 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier IN

22 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier DT

23 Sequence Labeling as Classification Classify each token independently but use as input features, information about the surrounding tokens (sliding window). John saw the saw and decided to take it to the table. classifier NN

24 Sequence Labeling as Classification Using Outputs as Inputs Better input features are usually the categories of the surrounding tokens, but these are not available yet. Can use category of either the preceding or succeeding tokens by going forward or back and using previous output.

25 Forward Classification John saw the saw and decided to take it to the table. classifier NNP

26 Forward Classification NNP John saw the saw and decided to take it to the table. classifier VBD

27 Forward Classification NNP VBD John saw the saw and decided to take it to the table. classifier DT

28 Forward Classification NNP VBD DT John saw the saw and decided to take it to the table. classifier NN

29 Forward Classification NNP VBD DT NN John saw the saw and decided to take it to the table. classifier CC

30 Forward Classification NNP VBD DT NN CC John saw the saw and decided to take it to the table. classifier VBD

31 Forward Classification NNP VBD DT NN CC VBD John saw the saw and decided to take it to the table. classifier TO

32 Forward Classification NNP VBD DT NN CC VBD TO John saw the saw and decided to take it to the table. classifier VB

33 Forward Classification NNP VBD DT NN CC VBD TO VB John saw the saw and decided to take it to the table. classifier PRP

34 Forward Classification NNP VBD DT NN CC VBD TO VB PRP John saw the saw and decided to take it to the table. classifier IN

35 Forward Classification NNP VBD DT NN CC VBD TO VB PRP IN John saw the saw and decided to take it to the table. classifier DT

36 Forward Classification NNP VBD DT NN CC VBD TO VB PRP IN DT John saw the saw and decided to take it to the table. classifier NN

37 Backward Classification Disambiguating “to” in this case would be even easier backward. John saw the saw and decided to take it to the table. classifier NN

38 Backward Classification Disambiguating “to” in this case would be even easier backward. NN John saw the saw and decided to take it to the table. classifier DT

39 Backward Classification Disambiguating “to” in this case would be even easier backward. DT NN John saw the saw and decided to take it to the table. classifier IN

40 Backward Classification Disambiguating “to” in this case would be even easier backward. IN DT NN John saw the saw and decided to take it to the table. classifier PRP

41 Backward Classification Disambiguating “to” in this case would be even easier backward. PRP IN DT NN John saw the saw and decided to take it to the table. classifier VB

42 Backward Classification Disambiguating “to” in this case would be even easier backward. VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier TO

43 Backward Classification Disambiguating “to” in this case would be even easier backward. TO VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier VBD

44 Backward Classification Disambiguating “to” in this case would be even easier backward. VBD TO VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier CC

45 Backward Classification Disambiguating “to” in this case would be even easier backward. CC VBD TO VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier NN

46 Backward Classification Disambiguating “to” in this case would be even easier backward. VBD CC VBD TO VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier DT

47 Backward Classification Disambiguating “to” in this case would be even easier backward. DT VBD CC VBD TO VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier VBD

48 Backward Classification Disambiguating “to” in this case would be even easier backward. VBD DT VBD CC VBD TO VB PRP IN DT NN John saw the saw and decided to take it to the table. classifier NNP

49 Problems with Sequence Labeling as Classification Not easy to integrate information from category of tokens on both sides. Difficult to propagate uncertainty between decisions and “collectively” determine the most likely joint assignment of categories to all of the tokens in a sequence.

50 Probabilistic Sequence Models Probabilistic sequence models allow integrating uncertainty over multiple, interdependent classifications and collectively determine the most likely global assignment. Two standard models –Hidden Markov Model (HMM) –Conditional Random Field (CRF)

51 Markov Model / Markov Chain A finite state machine with probabilistic state transitions. Makes Markov assumption that next state only depends on the current state and independent of previous history.

52 Sample Markov Model for POS stop start Det Noun PropNoun Verb

53 Sample Markov Model for POS stop start Det Noun PropNoun Verb P(PropNoun Verb Det Noun) = 0.4*0.8*0.25*0.95*0.1=0.0076

54 Hidden Markov Model Probabilistic generative model for sequences. Assume an underlying set of hidden (unobserved) states in which the model can be (e.g. parts of speech). Assume probabilistic transitions between states over time (e.g. transition from POS to another POS as sequence is generated). Assume a probabilistic generation of tokens from states (e.g. words generated for each POS).

55 Sample HMM for POS PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop start

56 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop start

57 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop start

58 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John start

59 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John start

60 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John bit start

61 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John bit start

62 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John bit the start

63 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John bit the start

64 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John bit the apple start

65 Sample HMM Generation PropNoun John Mary Alice Jerry Tom Noun cat dog car pen bed apple Det a the that a the a Verb bit ate saw played hit gave 0.05 stop John bit the apple start

A set of N +2 states S={s 0,s 1,s 2, … s N, s F } –Distinguished start state: s 0 –Distinguished final state: s F A set of M possible observations V={v 1,v 2 …v M } A state transition probability distribution A={a ij } Observation probability distribution for each state j B={b j (k)} Total parameter set λ={A,B} 66 Formal Definition of an HMM

67 HMM Generation Procedure To generate a sequence of T observations: O = o 1 o 2 … o T Set initial state q 1 =s 0 For t = 1 to T Transit to another state q t+1 =s j based on transition distribution a ij for state q t Pick an observation o t =v k based on being in state q t using distribution b qt (k)

68 Three Useful HMM Tasks Observation Likelihood: To classify and order sequences. Most likely state sequence (Decoding): To tag each token in a sequence with a label. Maximum likelihood training (Learning): To train models to fit empirical training data.

69 HMM: Observation Likelihood Given a sequence of observations, O, and a model with a set of parameters, λ, what is the probability that this observation was generated by this model: P(O| λ) ? Allows HMM to be used as a language model: A formal probabilistic model of a language that assigns a probability to each string saying how likely that string was to have been generated by the language. Useful for two tasks: –Sequence Classification –Most Likely Sequence

70 Sequence Classification Assume an HMM is available for each category (i.e. language). What is the most likely category for a given observation sequence, i.e. which category’s HMM is most likely to have generated it? Used in speech recognition to find most likely word model to have generate a given sound or phoneme sequence. AustinBoston ? ? P(O | Austin) > P(O | Boston) ? ah s t e n O

71 Most Likely Sequence Of two or more possible sequences, which one was most likely generated by a given model? Used to score alternative word sequence interpretations in speech recognition. Ordinary English dice precedent core vice president Gore O1O1 O2O2 ? ? P(O 2 | OrdEnglish) > P(O 1 | OrdEnglish) ?

72 HMM: Observation Likelihood Naïve Solution Consider all possible state sequences, Q, of length T that the model could have traversed in generating the given observation sequence. Compute the probability of a given state sequence from A, and multiply it by the probabilities of generating each of given observations in each of the corresponding states in this sequence to get P(O,Q| λ) = P(O| Q, λ) P(Q| λ). Sum this over all possible state sequences to get P(O| λ). Computationally complex: O(TN T ).

73 HMM: Observation Likelihood Efficient Solution Due to the Markov assumption, the probability of being in any state at any given time t only relies on the probability of being in each of the possible states at time t−1. Forward Algorithm: Uses dynamic programming to exploit this fact to efficiently compute observation likelihood in O(TN 2 ) time. –Compute a forward trellis that compactly and implicitly encodes information about all possible state paths.

Forward Probabilities Let  t (j) be the probability of being in state j after seeing the first t observations (by summing over all initial paths leading to j). 74

Forward Step 75 s1s1 s2s2 sNsN  sjsj  t-1 (i)  t (i) a 1j a 2j a Nj a 2j Consider all possible ways of getting to s j at time t by coming from all possible states s i and determine probability of each. Sum these to get the total probability of being in state s j at time t while accounting for the first t −1 observations. Then multiply by the probability of actually observing o t in s j.

Forward Trellis 76 s1s1 s2s2 sNsN   s0s0 sFsF       t1t1 t2t2 t3t3 t T-1 tTtT Continue forward in time until reaching final time point and sum probability of ending in final state.

Computing the Forward Probabilities Initialization Recursion Termination 77

Forward Computational Complexity Requires only O(TN 2 ) time to compute the probability of an observed sequence given a model. Exploits the fact that all state sequences must merge into one of the N possible states at any point in time and the Markov assumption that only the last state effects the next one. 78

79 Most Likely State Sequence (Decoding) Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple.

80 Most Likely State Sequence Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple. Det Noun PropNoun Verb

81 Most Likely State Sequence Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple. Det Noun PropNoun Verb

82 Most Likely State Sequence Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple. Det Noun PropNoun Verb

83 Most Likely State Sequence Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple. Det Noun PropNoun Verb

84 Most Likely State Sequence Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple. Det Noun PropNoun Verb

85 Most Likely State Sequence Given an observation sequence, O, and a model, λ, what is the most likely state sequence,Q=q 1,q 2,…q T, that generated this sequence from this model? Used for sequence labeling, assuming each state corresponds to a tag, it determines the globally best assignment of tags to all tokens in a sequence using a principled approach grounded in probability theory. John gave the dog an apple. Det Noun PropNoun Verb

86 HMM: Most Likely State Sequence Efficient Solution Obviously, could use naïve algorithm based on examining every possible state sequence of length T. Dynamic Programming can also be used to exploit the Markov assumption and efficiently determine the most likely state sequence for a given observation and model. Standard procedure is called the Viterbi algorithm (Viterbi, 1967) and also has O(N 2 T) time complexity.

Viterbi Scores Recursively compute the probability of the most likely subsequence of states that accounts for the first t observations and ends in state s j. 87 Also record “backpointers” that subsequently allow backtracing the most probable state sequence.  bt t (j) stores the state at time t-1 that maximizes the probability that system was in state s j at time t (given the observed sequence).

Computing the Viterbi Scores Initialization Recursion Termination 88 Analogous to Forward algorithm except take max instead of sum

Computing the Viterbi Backpointers Initialization Recursion Termination 89 Final state in the most probable state sequence. Follow backpointers to initial state to construct full sequence.

Viterbi Backpointers 90 s1s1 s2s2 sNsN   s0s0 sFsF       t1t1 t2t2 t3t3 t T-1 tTtT

Viterbi Backtrace 91 s1s1 s2s2 sNsN   s0s0 sFsF       t1t1 t2t2 t3t3 t T-1 tTtT Most likely Sequence: s 0 s N s 1 s 2 …s 2 s F

HMM Learning Supervised Learning: All training sequences are completely labeled (tagged). Unsupervised Learning: All training sequences are unlabelled (but generally know the number of tags, i.e. states). Semisupervised Learning: Some training sequences are labeled, most are unlabeled. 92

93 Supervised HMM Training If training sequences are labeled (tagged) with the underlying state sequences that generated them, then the parameters, λ={A,B} can all be estimated directly. Supervised HMM Training John ate the apple A dog bit Mary Mary hit the dog John gave Mary the cat Training Sequences Det Noun PropNoun Verb

Supervised Parameter Estimation Estimate state transition probabilities based on tag bigram and unigram statistics in the labeled data. Estimate the observation probabilities based on tag/word co-occurrence statistics in the labeled data. Use appropriate smoothing if training data is sparse. 94

Learning and Using HMM Taggers Use a corpus of labeled sequence data to easily construct an HMM using supervised training. Given a novel unlabeled test sequence to tag, use the Viterbi algorithm to predict the most likely (globally optimal) tag sequence. 95

96 Unsupervised Maximum Likelihood Training ah s t e n a s t i n oh s t u n eh z t en Training Sequences HMM Training Austin

97 Maximum Likelihood Training Given an observation sequence, O, what set of parameters, λ, for a given model maximizes the probability that this data was generated from this model (P(O| λ))? Used to train an HMM model and properly induce its parameters from a set of training data. Only need to have an unannotated observation sequence (or set of sequences) generated from the model. Does not need to know the correct state sequence(s) for the observation sequence(s). In this sense, it is unsupervised.

Maximum Likelihood vs. Maximum A Posteriori (MAP) The MAP parameter estimate is the most likely given the observed data, O. If all parameterizations are assumed to be equally likely a priori, then MLE and MAP are the same. If parameters are given priors (e.g. Gaussian or Laplacian with zero mean), then MAP is a principled way to perform smoothing or regularization.

99 HMM: Maximum Likelihood Training Efficient Solution There is no known efficient algorithm for finding the parameters, λ, that truly maximizes P(O| λ). However, using iterative re-estimation, the Baum- Welch algorithm (a.k.a. forward-backward), a version of a standard statistical procedure called Expectation Maximization (EM), is able to locally maximize P(O| λ). In practice, EM is able to find a good set of parameters that provide a good fit to the training data in many cases.

100 EM Algorithm Iterative method for learning probabilistic categorization model from unsupervised data. Initially assume random assignment of examples to categories. Learn an initial probabilistic model by estimating model parameters  from this randomly labeled data. Iterate following two steps until convergence: –Expectation (E-step): Compute P(c i | E) for each example given the current model, and probabilistically re-label the examples based on these posterior probability estimates. –Maximization (M-step): Re-estimate the model parameters, , from the probabilistically re-labeled data.

101 EM Unlabeled Examples +  +  +  +   + Assign random probabilistic labels to unlabeled data Initialize:

102 EM Prob. Learner +  +  +  +   + Give soft-labeled training data to a probabilistic learner Initialize:

103 EM Prob. Learner Prob. Classifier +  +  +  +   + Produce a probabilistic classifier Initialize:

104 EM Prob. Learner Prob. Classifier Relabel unlabeled data using the trained classifier +  +  +  +   + E Step:

105 EM Prob. Learner +  +  +  +   + Prob. Classifier Continue EM iterations until probabilistic labels on unlabeled data converge. Retrain classifier on relabeled data M step:

106 Sketch of Baum-Welch (EM) Algorithm for Training HMMs Assume an HMM with N states. Randomly set its parameters λ=(A,B) (making sure they represent legal distributions) Until converge (i.e. λ no longer changes) do: E Step: Use the forward/backward procedure to determine the probability of various possible state sequences for generating the training data M Step: Use these probability estimates to re-estimate values for all of the parameters λ

Backward Probabilities Let  t (i) be the probability of observing the final set of observations from time t+1 to T given that one is in state i at time t. 107

Computing the Backward Probabilities Initialization Recursion Termination 108

Estimating Probability of State Transitions Let  t (i,j) be the probability of being in state i at time t and state j at time t + 1 s1s1 s2s2 sNsN  sisi a 1i a 2i a Ni a 3i s1s1 s2s2 sNsN  sjsj a j1 a j2 a jN a j3 t-1 t t+1 t+2

Re-estimating A

Estimating Observation Probabilities Let  t (i) be the probability of being in state i at time t given the observations and the model.

Re-estimating B

113 Pseudocode for Baum-Welch (EM) Algorithm for Training HMMs Assume an HMM with N states. Randomly set its parameters λ=(A,B) (making sure they represent legal distributions) Until converge (i.e. λ no longer changes) do: E Step: Compute values for  t (j) and  t (i,j) using current values for parameters A and B. M Step: Re-estimate parameters:

EM Properties Each iteration changes the parameters in a way that is guaranteed to increase the likelihood of the data: P(O| ). Anytime algorithm: Can stop at any time prior to convergence to get approximate solution. Converges to a local maximum.