Docsity

Machine Learning - Sequence Labeling and Beyond | CS 5350, Papers of Computer Science

Toggle sidebar
bg1
Machine Learning (CS 5350/CS 6350) 08 Mar 2007
Sequence labeling and beyond (cont’d)
Structured Perceptron
Remember the CRF. . . We had the following basic algorithm for optimization:
1. Increase weights around correct paths
2. Decrease weights around incorrect paths
(decrease proportional to the probability of hitting those paths)
This is a general theme for structured prediction models. Other algorithms (that we don’t discuss) such
as max-margin Markov networks, structured SVMs, etc., all embody this basic premise, but with slightly
different parentheticals on step (2).
The problem with CRFs is that for most graph structures, step 2 above is intractable. So we’re going to
replace it with something more tractable. This leads to the structured perceptron.
1. Given data (x1, y1),...,(xN, yN) with structured ys.
2. Initialize a weight vector w←0
3. For a number of iterations:
(a) For each 1 ≤n≤N:
i. Compute predicted output ˆy= argmaxy∈Y w>Φ(xn, y)
ii. If ˆy6=yn, perform update:
w←w+ Φ(xn, yn)−Φ(xn,ˆy)
iii. (Optional: average weights)
This is just like the perceptron for binary classification, but extended to structured prediction. Note that for
sequence labeling problems, we write Φ(xn, yn) for the sum of all features over all substructures: Φ(xn, yn) =
PmΦ(xn, yn,m, yn,m−1) for instance.
Note that in comparison to the CRF, we have reduced the requirement of summing over all possible paths
(forward-backward) to the requirement of computing the best path (Viterbi). One way of thinking about
this is to consider the gradient of the log-likelihood for the CRF:
∇w`(yn|xn) = X
m
Φ(xn, yn,m, yn,m−1)−X
l,p
p(ym=l, ym−1=p)Φ(xn, l, p)
We obtain something that identical to the perceptron update if we assume that a single path—the best path—
has all of the probability mass. This is exactly the same relationship we had between logistic regression and
the (classification) perceptron from the first part of class.
One question that arises is: what if the argmax isn’t even tractable? The first solution is to use a best-guess
y, found using some search process, instead of the argmax. But, in general, we can do b etter. . .
1
pf3

Partial preview of the text

Download Machine Learning - Sequence Labeling and Beyond | CS 5350 and more Papers Computer Science in PDF only on Docsity!

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

Sequence labeling and beyond (cont’d)

Structured Perceptron

Remember the CRF... We had the following basic algorithm for optimization:

  1. Increase weights around correct paths
  2. Decrease weights around incorrect paths (decrease proportional to the probability of hitting those paths)

This is a general theme for structured prediction models. Other algorithms (that we don’t discuss) such as max-margin Markov networks, structured SVMs, etc., all embody this basic premise, but with slightly different parentheticals on step (2).

The problem with CRFs is that for most graph structures, step 2 above is intractable. So we’re going to replace it with something more tractable. This leads to the structured perceptron.

  1. Given data (x 1 , y 1 ),... , (xN , yN ) with structured ys.
  2. Initialize a weight vector w ← 0
  3. For a number of iterations:

(a) For each 1 ≤ n ≤ N : i. Compute predicted output ˆy = argmaxy∈Y w>Φ(xn, y) ii. If ˆy 6 = yn, perform update:

w ← w + Φ(xn, yn) − Φ(xn, yˆ)

iii. (Optional: average weights)

This is just like the perceptron for binary classification, but extended to structured prediction. Note that for sequence labeling problems, we write Φ(∑ xn, yn) for the sum of all features over all substructures: Φ(xn, yn) =

m Φ(xn, yn,m, yn,m−^1 ) for instance.

Note that in comparison to the CRF, we have reduced the requirement of summing over all possible paths (forward-backward) to the requirement of computing the best path (Viterbi). One way of thinking about this is to consider the gradient of the log-likelihood for the CRF:

∇w`(yn | xn) =

m

Φ(xn, yn,m, yn,m− 1 ) −

l,p

p(ym = l, ym− 1 = p)Φ(xn, l, p)

We obtain something that identical to the perceptron update if we assume that a single path—the best path— has all of the probability mass. This is exactly the same relationship we had between logistic regression and the (classification) perceptron from the first part of class.

One question that arises is: what if the argmax isn’t even tractable? The first solution is to use a best-guess y, found using some search process, instead of the argmax. But, in general, we can do better...

Machine Learning (CS 5350/CS 6350) 2

Search-based Structured Prediction

A problem near to my heart in machine translation: given an Arabic sentence a, find the best possible English translation e. I.e., for some scoring function f , for an input a, find ˆe = argmaxe f (e, a). In general, this will require considering a gigantic number of possible e: even for a dumbed down model, the problem is NP-hard. This is the case for many problems in many domains (eg. biology). An additional problem is that the loss functions we care about are complex.

So, what do we do in practice when we want to solve an NP-hard problem? We use an approximate search technique (or approximation algorithm, but they’re usually pretty similar).

Search(a, f ):

  1. Initialize a max-queue Q = {}
  2. While Q isn’t empty:

(a) Remove h, the top scoring partial hypothesis from Q (b) If h represents a complete hypothesis, return it (c) For all possible ways of extending h 7 → h′, i. Compute a score s′^ = f (a, h′) ii. Add h′^ to Q with score s′ (d) If Q is too large, drop some low-scoring elements from it.

In the translation example, we may consider a left-to-right search over e. In each “extension” step, we add a single word to e. The score will then depend on: (a) how grammatical is e up to the current position and (b) how well does it reflect a translation of a substring of a?

How can we do learning in such a system? Well, we can compute scores using a learned model. I.e., use s′^ = f (a, h′), where f is a learned function. The remaining question is: how can we learn f based on training data of the form of pairs of inputs and outputs?

What do we want? We want a function f so that (e, Search(a, f )) is as low as possible, where is a loss function. We’re going to do this via reductions. Specifically, we will reduce to cost-sensitive (multiclass) classification (from which we can apply, eg., weighted all pairs and costing).

To simplify the problem, consider greedy search:

GreedySearch(a, f ):

  1. Initialize output e = 
  2. While e is not complete:

(a) Choose an action we can take from e, f (Φ(a, e)). (b) Update e ← 〈e, a〉

  1. Return e

Here, f looks just like a classifier over (features of) actions.

So the question is how can we create training data to train such an f?

Obvious attempt number one: