Hidden Markov Models
Materials are collected from
Objective 2: Determining hidden states given sequence and model
Obtaining the maximum a posteriori probability estimate of the most likely sequence of hidden states given a sequence of observed states
Viterbi Algorithm
Components:
Transition matrix and emission matrix of Hidden Markov Model
Auxiliary matrix which tracks the intermediate optional probability. is the number of hidden states and is the number of words in observed states (e.g.: a text sequence)
Auxiliary matrix , which tracks the indices of visited states
Initialization:
Fill the first column of ( the probability from start sate to the first word with each hidden state) with:
: The transition probability from start state to hidden state
: The emission probability of word 1 (which has column index in emission matrix) at hidden state .
Fill the first column of with 0. This is becase there is no preceding part of speech tags that we traversed from.
Forward Pass
Populate the rest of and matrix column by column with the following formula:
is the transition probability from state to state
Logic: Look at , we want to find the optimal probability for the word sequence up to word where the word speech tag is . This is by iteratively looking over all possible previous , i.e.: the tag optiosn ending at word . For each optimal probability ,we then multiply the probability of transition from to , hence the , and the emission probability of word at , hence . Formatrix, we want to track the argmax, which is which previous hidden states did we decide to travel from.
Backward Pass
Get . The probability at index is the posterior probability estimate of the sequence.
We go to column of , and find the index at row , i.e.:
Go to the left next column (), and find the index at row , i.e.:
Considerations: Log Probability
Because we are multiplying many small numbers, we should again consider using log probability, hence
Last updated