Docsity

Machine Learning – Sequence Labeling - Notes | CS 5350, Study notes of Computer Science

Toggle sidebar
bg1
Machine Learning (CS 5350/CS 6350) 01 Mar 2007
Sequence labeling
We now return to supervised learning for a bit. However, we are interested in solving problems whose output
has structure. We will begin with the simplest non-trival structure: sequences. There are lots of problems
from langauge and biology that fit in this paradigm.
Sequence labeling is the following problem: we get a sequence of Minputs and want to produce a sequence
of Mlabels. Training data will be Nsuch input/output pairs.
Example: “The/det man/noun ate/verb a/det sandwith/noun with/prep mayo/noun” We get the sentence
and want to produce the part of speech labels. We will usually talk about a label set Yof size L.
Several non-options:
1. Treat it as a classification problem into MLclasses. Doesn’t work – too many classes, Mnot constant.
2. Treat as Mseparate L-class classification problems. Works okay, but doesn’t reflect structure (eg.,
unlikely to have “verb” follow “det”).
We adopt a Markov model. This model makes two assumptions:
1. The value of the word depends only on its label and not on surrounding labels/words
2. Conditioned on the Kprevious labels, the current label is independent of all others
Number 2 is called a K-th order Markov assumption.
The generative model looks something like:
1. Choose a label y1
2. Generate input x1conditioned on y1
3. For m= 2 . . . M ,
(a) Choose a label ymconditioned on {ym−1,...,ym−K}
(b) Generate input xmconditioned on ym
For simplicity we will stick with K= 1; the extension is straightforward.
For this, we need three ingredients:
1. Initial state probabilities π. This is a vector of length L, all positive with sum 1. These are used to
choose y1.πlis the probability that y1=l.
2. Emission probabilities β. This is a matrix of size LtimesV , where Vis the size of the output vocabulary.
βl,v is the probability of “emitting” word vgiven that the label is l.
3. Transition probabilities α. This is a matrix of size LtimesL, where αp,l is the probability of transi-
tioning to state lgiven that we were in state p(“p” for previous).
1
pf3

Partial preview of the text

Download Machine Learning – Sequence Labeling - Notes | CS 5350 and more Study notes Computer Science in PDF only on Docsity!

Machine Learning (CS 5350/CS 6350) 01 Mar 2007

Sequence labeling

We now return to supervised learning for a bit. However, we are interested in solving problems whose output has structure. We will begin with the simplest non-trival structure: sequences. There are lots of problems from langauge and biology that fit in this paradigm.

Sequence labeling is the following problem: we get a sequence of M inputs and want to produce a sequence of M labels. Training data will be N such input/output pairs.

Example: “The/det man/noun ate/verb a/det sandwith/noun with/prep mayo/noun” We get the sentence and want to produce the part of speech labels. We will usually talk about a label set Y of size L.

Several non-options:

  1. Treat it as a classification problem into M L^ classes. Doesn’t work – too many classes, M not constant.
  2. Treat as M separate L-class classification problems. Works okay, but doesn’t reflect structure (eg., unlikely to have “verb” follow “det”).

We adopt a Markov model. This model makes two assumptions:

  1. The value of the word depends only on its label and not on surrounding labels/words
  2. Conditioned on the K previous labels, the current label is independent of all others

Number 2 is called a K-th order Markov assumption.

The generative model looks something like:

  1. Choose a label y 1
  2. Generate input x 1 conditioned on y 1
  3. For m = 2... M ,

(a) Choose a label ym conditioned on {ym− 1 ,... , ym−K } (b) Generate input xm conditioned on ym

For simplicity we will stick with K = 1; the extension is straightforward.

For this, we need three ingredients:

  1. Initial state probabilities π. This is a vector of length L, all positive with sum 1. These are used to choose y 1. πl is the probability that y 1 = l.
  2. Emission probabilities β. This is a matrix of size LtimesV , where V is the size of the output vocabulary. βl,v is the probability of “emitting” word v given that the label is l.
  3. Transition probabilities α. This is a matrix of size LtimesL, where αp,l is the probability of transi- tioning to state l given that we were in state p (“p” for previous).

Machine Learning (CS 5350/CS 6350) 2

Putting this all together, the joint probability of an input sequence x and state sequence y (both of length M ) is:

p(x, y | π, α, β) = πy 1 βy 1 ,x 1

∏^ M

m=

αym− 1 ,ym βym,xm

It becomes frustrating to have to separate out the first element all the time. So what we’ll do instead is define y 0 to be a state with a unique label z and define αz,· = π. Then, we get:

p(x, y | α, β) =

∏^ M

m=

αym− 1 ,ym βym,xm

∏^ M

m=

l

v

β^1 l,v[xm=v]

p

α^1 p,l[ym−^1 =p]

) 1 [ym=l]

Given data, we can estimate α and β exactly as in the naive Bayes classification model:

αˆp,l =

of times l follows p

of times p occurs

βˆl,v = # of times^ v^ has label^ l

of times l occurs

We can generalize this to a simple naive Bayes model over emissions, rather than the “label emits word” part. I.e., if xm itself is a bunch of features, xm, 1 ,... , xm,D , then bel becomes a vector of length D instead of V , but everything else remains the same.

The key problem in such models is at test time: given a word sequence x, find the best label sequence y. This question is somewhat ill-posed: there are many possible interpretations of “best:”

  1. Best = output sequence y that maximizes p(x, y | α, β)
  2. Best = output sequence y that maximizes

m p(x, ym^ |^ α, β)

Typically people consider the first because it is “parsimonious.”

This problem is most easily considered by picturing a lattice of possible states, with connections between adjacent time steps.

We ask ourselves: what is the probability that the most likely path will pass through state l at time m? We store this as Am,l; leaving off conditioning on α and β, we have:

Am,l = max y1:m− 1 p(y1:m− 1 , x1:m− 1 , ym = l)

We can compute this probability recursively: