• Keine Ergebnisse gefunden

Hidden Markov Models with Latent Annotations

2.3 Sequence Prediction

2.3.2 Hidden Markov Models with Latent Annotations

Hidden Markov models with latent annotations (HMM-LA) were introduced by Huang et al.

(2009). They are an adaptation of a similar algorithm developed for probabilistic context-free grammars (Petrov et al., 2006). We already discussed that the Markov assumption made during the training has an important effect on the runtime of the Viterbi algorithm. HMM-LAs soften the Markov assumptions of traditional HMMs by increasing the number of states. The approach is thus similar to increasing the order of the HMM, but differs in that the states are trained in a way to maximize the likelihood of the training data. The procedure consists of two iteratively executed steps. The first step is called “splitting” and splits every HMM state into two similar substates. Then the expectation–maximization (EM) algorithm is applied to optimize the param-eters of the new model. In the second step, called “merging” the improvement in likelihood that every single split provides is estimated and a certain fraction of the splits with the lowest gains are reversed. The two steps are then iterated until a certain number of states is reached. As an example from part-of-speech tagging: It might be beneficial to split the PoS tag “Noun” into common nouns and proper nouns in the first iteration and in the second iteration proper nouns could be split into company names (often followed by corp. or inc.) and person names (often proceeded byMr). On the other hand it makes little sense to have a high number of determiner tags so we would expect that the determiner splits get reversed in the merging step.

EM

The EM algorithm estimates models over unobserved latent variables (Dempster et al., 1977).

It was originally proposed as a method of handling incomplete data sets. The algorithm finds a local optimum in the marginal likelihood:

LLθ(D) = X

x∈D

p(x|D) =X

x∈D

X

z

p(x, z|θ) (2.32)

whereDis a data set of observed itemsx, thezare the values of the unobserved latent variables and θ is a model. EM iteratively improves θ: In the expectation step, it calculates estimated counts using the model:

ˆ

cD,θt(x, z) =cD(x)·p(z|x, θt) =cD(x)· p(x, z|θt) P

z0p(x, z0t) (2.33) From which a new model can be learned in the maximization step:

θt+1 = arg max

θ

X

x,z

ˆ

cD,θt(x, z)·p(x, z|θ) (2.34) It can be shown that this procedure produces models with monotonically increasing likeli-hood (Dempster et al., 1977). As we already discussed, EM is used in the training of HMM-LAs, where we observe input and output symbols and need to estimate the frequencies of the unobserved substates. In this casep(z|x, θt)cannot be computer by summation over all possible

sequences z as there are exponentially many. We thus use a more efficient dynamic program similar to the Viterbi algorithm.

Forward-Backward

The forward-backward algorithm allows us to calculate the posterior probabilities needed for the EM e-step. Given an input sequence, the forward-backward algorithm calculates the posterior probability of a transition from z to z0 at position t. This posterior can be decomposed into a product of three probabilities: The probability of all output sequences ending inz at positiont, the probability of a transition from z to z0 and the probability of all output sequences starting withz0at position t+ 1. While the transition probability is a simple model parameter, the other two probabilities have to be calculating using dynamic programs. We start with the probability of all sequences ending in z at position t, the corresponding program is known as the forward algorithm and is similar to the Viterbivmatrix except that the paths are combined by summation instead of maximization:

α0,start = 1 αz,t=X

z0

αt−1,z0 ·p(z|z0)·p(xt|z)

where for the sake of simplicity we ignore the dependencies onθ, xandzin the notation. The probability of all sequences starting at positiontin symbolz0can be calculated similarly:

βT+1,stop = 1 βz,t=X

z0

βt+1,z0 ·p(z0|z)·p(xt+1|z)

The probability of a transition at positiontis then given by:

p(x, z, z0|t) = αt,z·p(z0|z)·βz0,t+1 (2.35) Normalizing by the sum off all sequences, we obtain:

p(z, z0|x, t) = αt,z·p(z0|z)·βz0,t+1

αT+1,stop (2.36)

Just as for Viterbi the time complexity of the FB algorithm is dominated by the summation over all possible transitions at a specific position and thus grows polynomially with the number of states and exponentially with the model order. The posterior probability then allows us to estimate the frequencies needed for HMM training: The frequency of a state, following another state and of a state co-occurring with a specific input symbol:

ˆ

cD,θt(z, z0) = X

x,t

cD(x)·p(z, z0|x, t) ˆ

cD,θt(z, x) = X

x,z0,t

cD(x)·p(z, z0|x, t)

Here we derived the forward-backward computation for an unrestricted HMM. In the case of HMM-LA training we already know the correct output symbols and just need to calculate the probabilities of the possible substates. We thus calculate probabilities of the following form:

p(zy, zy0|x, t, y, y0). This can be easily achieved by updating the forward and backward defini-tions:

αz0

y,t = X

zy0∈Ω(y)

α0t−1,z0

y·p(zy|z0y)·p(xt|zy) (2.37) whereΩ(y)is the set of all substates ofy. With EM as the method to adjust the latent substates to the training set, we can continue with our description of split-merge training for HMMs. The procedure starts by collecting frequency counts for a bigram HMM from an annotated corpus.

We denote the transition frequency of statey0followingybycy,y0 and the emission frequency of symbolxoccurring with state yby cy,x. The training procedure consists of iteratively splitting tag symbols into two latent subsymbols and adjusting the resulting latent model to the training set using expectation–maximization (EM) training. It then approximates the gain in likelihood (L) of every split and reverts splits that give little increase and needlessly increase the complexity of the model.

Splitting

In the split phase we split every stateyinto two subtagsy0 andy1. We set cy0,x= cy,x

2 +r cy1,x= cy,x

2 −r

whereris a random number r ∈ [−ρcy,x, ρcy,x]andρ ∈ [0,1]controls how much the statistics fory0 andy1 differ. The exact value ofρis of secondary importance, if it is just big enough to break the symmetry (the model could not learn anything if the parameters for y0 and y1 were identical). Analogously to the emission frequencies we initialize the transition frequencies as follows:

cy0,y0

0 = cy,y0

4 +r cy0,y0

1 = cy,y0 4 −r cy1,y0

0 = cy,y0

4 +r0 cy1,y0

1 = cy,y0 4 −r0 We then run EM training to fit the new model to the training data.

Merging

To prevent the model from wasting parameters for splits that only yield small increases in likeli-hood we revert the splits with the lowest gains. The gain of a split can be calculated analogously toPetrov et al. (2006). To this end we calculate for each split, what we would lose in terms of likelihood if we were to reverse this split. The likelihood contribution at a certain positiontwith stateycan be recovered from the FB probabilities:

p(x,y|t) = X

zy∈Ω(y)

αt,zy ·βt,zy p(x|zy)

In order to calculate the likelihood of a model that does not splityintoy0andy1 we first have to derive the parameters of the new model from the parameters of the old model:

p(x|y) = X

i∈{0,1}

pi·p(x|yi) p(y0|y) = X

i∈{0,1}

pi·p(y0|yi) p(y|y0) = X

i∈{0,1}

p(yi|y0)

where p0 and p1 are the relative frequency of y0 and y1 given their parent tag y. We can now derive the approximated forward and backward probabilities by substituting the corresponding parameters. Huang et al.(2009) do not provide the equations or derivation for merging in their paper, but due to personal communication we think that their approximation has the same form:

α0t,y ≈p(xt|y) X

i∈{0,1}

αt,yi/p(xt|yi) βt,y0 ≈ X

i∈{0,1}

pi·βt,yi

where theα values can be added because they do not contain terms that directly depend on t, while the other terms have to be interpolated. This calculation is approximate because it ignores any influence that the merge might have at any other position in the sequence. The likelihood of the new model can then by calculated from the new FB values and a fraction of the states with the lowest likelihood improvements is reversed.