Journal of Machine Learning Research 6 (2005) 1453–1484

Submitted 11/04; Published 9/05

Large Margin Methods for Structured andInterdependent Output Variables
Ioannis Tsochantaridis

IOANNIS @ GOOGLE . COM

Google, Inc.
Mountain View, CA 94043, USA

Thorsten Joachims

TJ @ CS . CORNELL . EDU

Department of Computer Science
Cornell University
Ithaca, NY 14853, USA

Thomas Hofmann

HOFMANN @ INT. TU - DARMSTADT. DE

Darmstadt University of Technology
Fraunhofer IPSI
Darmstadt, Germany

Yasemin Altun

ALTUN @ TTI - C . ORG

Toyota Technological Institute
Chicago, IL 60637, USA

Editor: Yoram Singer

Abstract
Learning general functional dependencies between arbitrary input and output spaces is one of the
key challenges in computational intelligence. While recent progress in machine learning has mainly
focused on designing flexible and powerful input representations, this paper addresses the complementary issue of designing classification algorithms that can deal with more complex outputs, suchas trees, sequences, or sets. More generally, we consider problems involving multiple dependent
output variables, structured output spaces, and classification problems with class attributes. In orderto accomplish this, we propose to appropriately generalize the well-known notion of a separation
margin and derive a corresponding maximum-margin formulation. While this leads to a quadratic
program with a potentially prohibitive, i.e. exponential, number of constraints, we present a cutting plane algorithm that solves the optimization problem in polynomial time for a large class ofproblems. The proposed method has important applications in areas such as computational biology,
natural language processing, information retrieval/extraction, and optical character recognition. Experiments from various domains involving different types of output spaces emphasize the breadthand generality of our approach.

1. Introduction
This paper deals with the general problem of learning a mapping from input vectors or patterns
x ∈ X to discrete response variables y ∈ Y , based on a training sample of input-output pairs(x1 , y1 ), . . . , (xn , yn ) ∈ X × Y drawn from some fixed but unknown probability distribution. Unlike multiclass classification, where the output space consists of an arbitrary finite set of labels orclass identifiers, Y = {1, ..., K}, or regression, where Y = R and the response variable is a scalar,
we consider the case where elements of Y are structured objects such as sequences, strings, trees,c 2005 Ioannis Tsochantaridis, Thorsten Joachims, Thomas Hofmann and Yasemin Altun.

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

lattices, or graphs. Such problems arise in a variety of applications, ranging from multilabel classification and classification with class taxonomies, to label sequence learning, sequence alignment
learning, and supervised grammar learning, to name just a few. More generally, these problems
fall into two generic cases: first, problems where classes themselves can be characterized by certainclass-specific attributes and learning should occur across classes as much as across patterns; second,
problems where y represents a macro-label, i.e. describes a configuration over components or statevariables y = (y1 , . . . , yT ), with possible dependencies between these state variables.
We approach these problems by generalizing large margin methods, more specifically multiclass
support vector machines (SVMs) (Weston and Watkins, 1998; Crammer and Singer, 2001), to thebroader problem of learning structured responses. The naive approach of treating each structure as aseparate class is often intractable, since it leads to a multiclass problem with a very large number ofclasses. We overcome this problem by specifying discriminant functions that exploit the structureand dependencies within Y . In that respect our approach follows the work of Collins (2002) on
perceptron learning with a similar class of discriminant functions. However, the maximum-margin
algorithm we propose has advantages in terms of accuracy and tunability to specific loss functions.
A maximum-margin algorithm has also been proposed by Collins and Duffy (2002a) in the context
of natural language processing. However, it depends on the size of the output space, therefore it
requires some external process to enumerate a small number of candidate outputs y for a given
input x. The same is true also for other ranking algorithms (Cohen et al., 1999; Herbrich et al.,
2000; Schapire and Singer, 2000; Crammer and Singer, 2002; Joachims, 2002). In contrast, wehave proposed an efficient algorithm (Hofmann et al., 2002; Altun et al., 2003; Joachims, 2003)
even in the case of very large output spaces, that takes advantage of the sparseness of the maximummargin solution.
A different maximum-margin algorithm that can deal with very large output sets, maximum
margin Markov networks, has been independently proposed by Taskar et al. (2004a). The structureof the output is modeled by a Markov network, and by employing a probabilistic interpretation of thedual formulation of the problem, Taskar et al. (2004a) propose a reparameterization of the problem,that leads to an efficient algorithm, as well as generalization bounds that do not depend on the sizeof the output space. The proposed reparameterization, however, assumes that the loss function canbe decomposed in the the same fashion as the feature map, thus does not support arbitrary loss
functions that may be appropriate for specific applications.
On the surface our approach is related to the kernel dependency estimation approach describedin Weston et al. (2003). There, however, separate kernel functions are defined for the input andoutput space, with the idea to encode a priori knowledge about the similarity or loss function in
output space. In particular, this assumes that the loss is input dependent and known beforehand.
More specifically, in Weston et al. (2003) a kernel PCA is used in the feature space defined over y to
reduce the problem to a (small) number of independent regression problems. The latter corresponds
to an unsupervised embedding (followed by dimension reduction) performed in the output spaceand no information about the patterns x is utilized in defining this low-dimensional representation.
In contrast, the key idea in our approach is not primarily to define more complex functions, but todeal with more complex output spaces by extracting combined features over inputs and outputs.
For a large class of structured models, we propose a novel SVM algorithm that allows us tolearn mappings involving complex structures in polynomial time despite an exponential (or infinite) number of possible output values. In addition to respective theoretical results, we empiricallyevaluate our approach for a number of specific problem instantiations: classification with class tax1454

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

Figure 1: Illustration of natural language parsing model.
onomies, label sequence learning, sequence alignment, and natural language parsing. This paper
extends Tsochantaridis et al. (2004) with additional theoretical and empirical results.
The rest of the paper is organized as follows: Section 2 presents the general framework oflarge margin learning over structured output spaces using representations of input-output pairs via
joint feature maps. Section 3 describes and analyzes a generic algorithm for solving the resulting
optimization problems. Sections 4 and 5 discuss numerous important special cases and experimental
results, respectively.

2. Large Margin Learning with Joint Feature Maps
We are interested in the general problem of learning functions f : X → Y between input spaces
X and arbitrary discrete output spaces Y based on a training sample of input-output pairs. As
an illustrating example, which we will continue to use as a prototypical application in the sequel,consider the case of natural language parsing, where the function f maps a given sentence x to aparse tree y. This is depicted graphically in Figure 1.
The approach we pursue is to learn a discriminant function F : X × Y → R over input-output
pairs from which we can derive a prediction by maximizing F over the response variable for a
specific given input x. Hence, the general form of our hypotheses f is
f (x; w) = argmax F(x, y; w) ,

(1)

y∈Y

where w denotes a parameter vector. It might be useful to think of F as a compatibility functionthat measures how compatible pairs (x, y) are, or, alternatively, −F can be thought of as a wparameterized family of cost functions, which we try to design in such a way that the minimum ofF(x, ·; w) is at the desired output y for inputs x of interest.
Throughout this paper, we assume F to be linear in some combined feature representation of
inputs and outputs Ψ(x, y), i.e.
F(x, y; w) = hw, Ψ(x, y)i .

(2)

The specific form of Ψ depends on the nature of the problem and special cases will be discussed
subsequently. However, whenever possible we will develop learning algorithms and theoretical1455

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

results for the general case. Since we want to exploit the advantages of kernel-based method, we will
pay special attention to cases where the inner product in the joint representation can be efficiently
computed via a joint kernel function J((x, y), (x0 , y0 )) = hΨ(x, y), Ψ(x0 , y0 )i.
Using again natural language parsing as an illustrative example, we can chose F such that we
get a model that is isomorphic to a probabilistic context free grammar (PCFG) (cf. Manning andSchuetze, 1999). Each node in a parse tree y for a sentence x corresponds to grammar rule g j , which
in turn has a score w j . All valid parse trees y (i.e. trees with a designated start symbol S as the root
and the words in the sentence x as the leaves) for a sentence x are scored by the sum of the w j of
their nodes. This score can thus be written in the form of Equation (2), with Ψ(x, y) denoting ahistogram vector of counts (how often each grammar rule g j occurs in the tree y). f (x; w) can be
efficiently computed by finding the structure y ∈ Y that maximizes F(x, y; w) via the CKY algorithm(Younger, 1967; Manning and Schuetze, 1999).
2.1 Loss Functions and Risk Minimization
The standard zero-one loss function typically used in classification is not appropriate for most kindsof structured responses. For example, in natural language parsing, a parse tree that is almost correctand differs from the correct parse in only one or a few nodes should be treated differently froma parse tree that is completely different. Typically, the correctness of a predicted parse tree ismeasured by its F1 score (see e.g. Johnson, 1998), the harmonic mean of precision and recall as
calculated based on the overlap of nodes between the trees.
In order to quantify the accuracy of a prediction, we will consider learning with arbitrary loss
functions 4 : Y × Y → R. Here 4(y, ŷ) quantifies the loss associated with a prediction ŷ, if thetrue output value is y. It is usually sufficient to restrict attention to zero diagonal loss functions with
4(y, y) = 0 and for which furthermore 4(y, y0 ) > 0 for y 6= y0 .1 Moreover, we assume the loss isbounded for every given target value y∗ , i.e. maxy {4(y∗ , y)} exists.
We investigate a supervised learning scenario, where input-output pairs (x, y) are generated
according to some fixed distribution P(x, y) and the goal is to find a function f in a given hypothesis
class such that the risk,

RP4 ( f ) =

Z

X ×Y

4(y, f (x)) dP(x, y) ,is minimized. Of course, P is unknown and following the supervised learning paradigm, we assume
that a finite training set of pairs S = {(xi , yi ) ∈ X × Y : i = 1, . . . , n} generated i.i.d. according to P
is given. The performance of a function f on the training sample S is described by the empiricalrisk,

RS4 ( f ) =1 n∑ 4(yi , f (xi )) ,n i=1

which is simply the expected loss under the empirical distribution induced by S. For w-parameterized
hypothesis classes, we will also write RP4 (w) ≡ RP4 ( f (·; w)) and similarly for the empirical risk.
1. Cases where 4(y, y0 ) = 0 for y 6= y0 can be dealt with, but lead to additional technical overhead, which we chose to
avoid for the sake of clarity.

1456

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

2.2 Margin Maximization
We consider various scenarios for the generalization of support vector machine learning over structured outputs. We start with the simple case of hard-margin SVMs, followed by soft-margin SVMs,
and finally we propose two approaches for the case of loss-sensitive SVMs, which is the most general case and subsumes the former ones.
2.2.1 S EPARABLE C ASEFirst, we consider the case where there exists a function f parameterized by w such that the empiricalrisk is zero. The condition of zero training error can then be compactly written as a set of nonlinear
constraints
max {hw, Ψ(xi , y)i} ≤ hw, Ψ(xi , yi )i .

∀i ∈ {1, . . . , n} :y∈Y \yi(3)

Notice that this holds independently of the loss functions, since we have assumed that 4(y, y) = 0
and 4(y, y0 ) > 0 for y 6= y0 .
Every one of the nonlinear inequalities in Equation (3) can be equivalently replaced by |Y | − 1
linear inequalities, resulting in a total of n|Y | − n linear constraints,∀i ∈ {1, . . . , n}, ∀y ∈ Y \ yi :hw, Ψ(xi , yi ) − Ψ(xi , y)i ≥ 0 .

(4)

As we will often encounter terms involving feature vector differences of the type appearing inEquation (4), we define δΨi (y) ≡ Ψ(xi , yi ) − Ψ(xi , y) so that the constraints can be more compactly
written as hw, δΨi (y)i ≥ 0.
If the set of inequalities in Equation (4) is feasible, there will typically be more than one solution w∗ . To specify a unique solution, we propose to select the w for which the separation marginγ, i.e. the minimal differences between the score of the correct label yi and the closest runner-upŷ(w) = argmaxy6=yi hw, Ψ(xi , y)i, is maximal. This generalizes the maximum-margin principle employed in support vector machines (Vapnik, 1998) to the more general case considered in this paper.
Restricting the L2 norm of w to make the problem well-posed leads to the following optimization
problem:max γ

γ,w:kwk=1

s.t. ∀i ∈ {1, . . . , n}, ∀y ∈ Y \ yi :hw, δΨi (y)i ≥ γ .

This problem can be equivalently expressed as a convex quadratic program in standard form
SVM0 :

1
kwk2
2
s.t. ∀i, ∀y ∈ Y \ yi : hw, δΨi (y)i ≥ 1 .

min
w

(5)
(6)

2.2.2 S OFT- MARGIN M AXIMIZATIONTo allow errors in the training set, we introduce slack variables and propose to optimize a softmargin criterion. As in the case of multiclass SVMs, there are at least two ways of introducing slack
variables. One may introduce a single slack variable ξi for violations of the nonlinear constraints
1457

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

(i.e. every instance xi ) (Crammer and Singer, 2001) or one may penalize margin violations forevery linear constraint (i.e. every instance xi and output y 6= yi ) (Weston and Watkins, 1998; HarPeled et al., 2002). Since the former will result in a (tighter) upper bound on the empirical risk
(cf. Proposition 1) and offers some advantages in the proposed optimization scheme (cf. Section 3),
we have focused on this formulation. Adding a penalty term that is linear in the slack variables tothe objective, results in the quadratic program
SVM1 :C n
1
kwk2 + ∑ ξi
2
n i=1

min
w,ξξ

(7)

s.t. ∀i, ∀y ∈ Y \ yi : hw, δΨi (y)i ≥ 1 − ξi , ξi ≥ 0 .
Alternatively, we can also penalize margin violations by a quadratic term leading to the following
optimization problem:
SVM2 :

min
w,ξξ

C n 2
1
kwk2 +∑ ξi
22n i=1s.t. ∀i, ∀y ∈ Y \ yi : hw, δΨi (y)i ≥ 1 − ξi .
In both cases, C > 0 is a constant that controls the trade-off between training error minimization andmargin maximization.
2.2.3 G ENERAL L OSS F UNCTIONS : S LACK R E - SCALING
The first approach we propose for the case of arbitrary loss functions, is to re-scale the slack variables according to the loss incurred in each of the linear constraints. Intuitively, violating a margin
constraint involving a y 6= yi with high loss 4(yi , y) should be penalized more severely than a violation involving an output value with smaller loss. This can be accomplished by multiplying themargin violation by the loss, or equivalently, by scaling the slack variable with the inverse loss,
which yields
SVM4s
1 :

min
w,ξξ

C n
1
kwk2 + ∑ ξi2
n i=1

s.t. ∀i, ∀y ∈ Y \ yi : hw, δΨi (y)i ≥ 1 −

ξi.
4(yi , y)A justification for this formulation is given by the subsequent proposition.

Proposition 1 Denote by ξ∗ (w) the optimal solution of the slack variables in SVM4s
1 for a given
4
1 n∗
weight vector w. Then n ∑i=1 ξi is an upper bound on the empirical risk RS (w).
Proof Notice first that ξ∗i = max{0, maxy6=yi {4(yi , y) (1 − hw, δΨi (y)i)}}.
Case 1: If f (xi ; w) = yi , then ξ∗i ≥ 0 = 4(yi , f (xi ; w)) and the loss is trivially upper bounded.
ξ∗Case 2: If ŷ ≡ f (xi ; w) 6= yi , then hw, δΨi (ŷ)i ≤ 0 and thus 4(yii ,y) ≥ 1 which is equivalent toξ∗i ≥ 4(yi , y).
Since the bound holds for every training instance, it also holds for the average.
The optimization problem SVM4s
2 can be derived analogously, where 4(yi , y) is replaced byin order to obtain an upper bound on the empirical risk.
1458

p4(yi , y)L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

2.2.4 G ENERAL L OSS F UNCTIONS : M ARGIN R E - SCALING
In addition to this slack re-scaling approach, a second way to include loss functions is to re-scale
the margin as proposed by Taskar et al. (2004a) for the special case of the Hamming loss. It is
straightforward to generalize this method to general loss functions. The margin constraints in thissetting take the following form:∀i, ∀y ∈ Y :hw, δΨi (y)i ≥ 4(yi , y) − ξi .

(8)

The set of constraints in Equation (8) combined with the objective in Equation (7) yield an opti4∗
mization problem SVM4m
1 which also results in an upper bound on RS (w ).
Proposition 2 Denote by ξ∗ (w) the optimal solution of the slack variables in SVM4m
1 for a given
weight vector w. Then n1 ∑ni=1 ξ∗i is an upper bound on the empirical risk RS4 (w).
Proof The essential observation is that ξ∗i = max {0, maxy {4(yi , y) − hw, δΨi (y)i}} which is guaranteed to upper bound 4(yi , y) for y such that hw, δΨi (y)i ≤ 0.
The optimization problem SVM4m
2 can be derived analogously, where 4(yi , y) is replaced by
2.2.5 G ENERAL L OSS F UNCTIONS : D ISCUSSIONp4(yi , y).

Let us discuss some of the advantages and disadvantages of the two formulations presented. An
appealing property of the slack re-scaling approach is its scaling invariance.
Proposition 3 Suppose 40 ≡ η4 with η > 0, i.e. 40 is a scaled version of the original loss 4.
40 s
0Then by re-scaling C0 = C/η, the optimization problems SVM4s
1 (C) and SVM1 (C ) are equivalent∗
as far as w is concerned. In particular the optimal weight vector w is the same in both cases.
40 s
Proof First note that each w is feasible for SVM4s
1 and SVM1 in the sense that we can find slack
variables such that all the constraints are satisfied. In fact we can chose them optimally and define0H(w) ≡ 21 kwk2 + Cn ∑i ξ∗i (w) and H 0 (w) ≡ 21 kwk2 + Cn ∑i ξ∗i 0 (w), where ξ∗ and ξ∗ 0 refer to the04s
optimal slacks in SVM4s
1 and SVM1 , respectively, for given w. It is easy to see that they are givenbyξ∗i = max{0, max{4(yi , y) (1 − hw, δΨi (y)i)}}
y6=yi

and
ξ∗i 0 = max{0, max{η4(yi , y) (1 − hw, δΨi (y)i)}},y6=yirespectively. Pulling η out of the max, one gets that ξ∗i 0 = ηξ∗i and thus ∑i ξ∗i = Cη ∑i ξ∗i 0 = C0 ∑i ξ∗i 0 .
From that it follows immediately that H = H 0 .

In contrast, the margin re-scaling formulation is not invariant under scaling of the loss function.
One needs, for example, to re-scale the feature map Ψ by a corresponding scale factor as well. This
seems to indicate that one has to calibrate the scaling of the loss and the scaling of the feature map
1459

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

4s
more carefully in the SVM4m
1 formulation. The SVM1 formulation on the other hand, represents
the loss scale explicitly in terms of the constant C.
A second disadvantage of the margin scaling approach is that it potentially gives significant
weight to output values y ∈ Y that are not even close to being confusable with the target values
yi , because every increase in the loss increases the required margin. If one interprets F(xi , yi ; w) −F(xi , y; w) as a log odds ratio of an exponential family model (Smola and Hofmann, 2003), thenthe margin constraints may be dominated by incorrect values y that are exponentially less likely
than the target value. To be more precise, notice that in the SVM4s
1 formulation, the penalty
part only depends on y for which hw, δΨi (y)i ≤ 1. These are output values y that all receive∗a relatively “high” (i.e. 1-close to the optimum) value of F(x, y; w). However, in SVM4m
1 , ξi∗has to majorize 4(yi , y) − hw, δΨi (y)i for all y. This means ξi can be dominated by a valueŷ = argmaxy {4(yi , y) − hw, δΨi (y)i} which has a large loss, but whose value of F(x, y; w) comes
nowhere near the optimal value of F.

3. Support Vector Algorithm for Structured Output Spaces
So far we have not discussed how to solve the optimization problems associated with the various
4m
4s
4m
formulations SVM0 , SVM1 , SVM2 , SVM4s
1 , SVM1 , SVM2 , and SVM2 . The key challenge
is that the size of each of these problems can be immense, since we have to deal with n|Y | − nmargin inequalities. In many cases, |Y | may be extremely large, in particular, if Y is a productspace of some sort (e.g. in grammar learning, label sequence learning, etc.), its cardinality may
grow exponentially in the description length of y. This makes standard quadratic programming
solvers unsuitable for this type of problem.
In the following, we will propose an algorithm that exploits the special structure of the maximummargin problem, so that only a much smaller subset of constraints needs to be explicitly examined.
We will show that the algorithm can compute arbitrary close approximations to all SVM optimization problems posed in this paper in polynomial time for a large range of structures and loss functions. Since the algorithm operates on the dual program, we will first derive the Wolfe dual for thevarious soft margin formulations.
3.1 Dual Programs
We will denote by α(iy) the Lagrange multiplier enforcing the margin constraint for label y 6= yi
and example (xi , yi ). Using standard Lagragian duality techniques, one arrives at the following dual
quadratic program (QP).
Proposition 4 The objective of the dual problem of SVM0 from Equation (6) is given by
Θ(α) ≡ −1∑ α(iy) α( jȳ) J(iy)( jȳ) + ∑ α(iy) ,2 i,y6∑=yi j,ȳ6=y ji,y6=yiwhere J(iy)( jȳ) = δΨi (y), δΨ j (ȳ) . The dual QP can be formulated asα∗ = argmax Θ(α),α

1460

s.t. α ≥ 0 .

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

Proof (sketch) Forming the Lagrangian function and eliminating the primal variables w by using
the optimality conditionw∗ (α) = ∑ ∑ α(iy) δΨi (y)i y6=yidirectly leads to the above dual program.

Notice that the J function that generates the quadratic from in the dual objective can be computedfrom inner products involving values of Ψ, which is a simple consequence of the linearity of theinner product. J can hence be alternatively computed from a joint kernel function over X × Y .
In the non-separable case, linear penalties introduce additional constraints, whereas the squared
penalties modify the kernel function.
Proposition 5 The dual problem to SVM1 is given by the program in Proposition 4 with additional
constraintsC∑ α(iy) ≤ n , ∀i = 1, . . . , n .
y6=yi
In the following, we denote with δ(a, b) the function that returns 1 if a = b, and 0 otherwise.
Proposition 6 The dual problem to SVM2 is given by the program in Proposition 4 with modified
kernel functionnJ(iy)( jȳ) ≡ δΨi (y), δΨ j (ȳ) + δ(i, j) .
C
In the non-separable case with slack re-scaling, the loss function is introduced in the constraints forlinear penalties and in the kernel function for quadratic penalties.
Proposition 7 The dual problem to SVM4s
1 is given by the program in Proposition 4 with additional
constraints
α(iy)C∑ 4(yi , y) ≤ n , ∀i = 1, . . . , n .
y6=yi
Proposition 8 The dual problem to SVM4s
2 is given by the program in Proposition 4 with modified
kernel functionnpJ(iy)( jȳ) = δΨi (y), δΨ j (ȳ) + δ(i, j) p.
C 4(yi , y) 4(y j , ȳ)

In the non-separable case with margin re-scaling, the loss function is introduced in the linear part ofthe objective function

4m
Proposition 9 The dual problems to SVM4m
1 and SVM2 are given by the dual problems to SVM1 andSVM2 with the linear part of the objective replaced byp∑ α(iy) 4(yi , y) and ∑ α(iy) 4(yi , y)i,y6=yii,y6=yirespectively.
1461

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

3.2 Algorithm
The algorithm we propose aims at finding a small set of constraints from the full-sized optimization
problem that ensures a sufficiently accurate solution. More precisely, we will construct a nested
sequence of successively tighter relaxations of the original problem using a cutting plane method(Kelley, 1960), implemented as a variable selection approach in the dual formulation. Similar to
its use with the Ellipsoid method (Grötschel et al., 1981; Karmarkar, 1984), we merely require aseparation oracle that delivers a constraint that is violated by the current solution. We will latershow that this is a valid strategy, since there always exists a polynomially sized subset of constraints
so that the solution of the relaxed problem defined by this subset fulfills all constraints from the full
optimization problem up to a precision of ε. This means, the remaining—potentially exponentially
many—constraints are guaranteed to be violated by no more than ε, without the need for explicitly
adding these constraints to the optimization problem.
We will base the optimization on the dual program formulation which has two important advantages over the primal QP. First, it only depends on inner products in the joint feature space definedby Ψ, hence allowing the use of kernel functions. Second, the constraint matrix of the dual programsupports a natural problem decomposition. More specifically, notice that the constraint matrix derived for the SVM0 and the SVM∗2 variants is diagonal, since the non-negativity constraints involve
only a single α-variable at a time, whereas in the SVM∗1 case, dual variables are coupled, but the
couplings only occur within a block of variables associated with the same training instance. Hence,the constraint matrix is (at least) block diagonal in all cases, where each block corresponds to a
specific training instance.
Pseudo-code of the algorithm is depicted in Algorithm 1. The algorithm maintains working
sets Si for each training instance to keep track of the selected constraints which define the current
relaxation. Iterating through the training examples (xi , yi ), the algorithm proceeds by finding the(potentially) “most violated” constraint for xi , involving some output value ŷ. If the (appropriately
scaled) margin violation of this constraint exceeds the current value of ξi by more than ε, the dual
variable corresponding to ŷ is added to the working set. This variable selection process in the dual
program corresponds to a successive strengthening of the primal problem by a cutting plane thatcuts off the current primal solution from the feasible set. The chosen cutting plane corresponds tothe constraint that determines the lowest feasible value for ξi . Once a constraint has been added,
the solution is re-computed with respect to S. Alternatively, we have also devised a scheme where
the optimization is restricted to Si only, and where optimization over the full S is performed muchless frequently. This can be beneficial due to the block diagonal structure of the constraint matrix,
which implies that variables α( jy) with j 6= i, y ∈ S j can simply be “frozen” at their current values.
Notice that all variables not included in their respective working set are implicitly treated as 0. The
algorithm stops, if no constraint is violated by more than ε. With respect to the optimization in step
10, we would like to point out that in some applications the constraint selection in step 6 may be
more expensive than solving the relaxed QP. Hence it may be advantageous to solve the full relaxed
QP in every iteration, instead of just optimizing over a subspace of the dual variables.
The presented algorithm is implemented in the software package SVMstruct , available on the web
at http://svmlight.joachims.org. Note that the SVM optimization problems from iteration toiteration differ only by a single constraint. We therefore restart the SVM optimizer from the current
solution, which greatly reduces the runtime.
1462

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

Algorithm 1 Algorithm for solving SVM0 and the loss re-scaling formulations SVM∗1 and SVM∗2 .
1: Input: (x1 , y1 ), . . . , (xn , yn ), C, ε2: Si ← 0/ for all i = 1, . . . , n
3: repeat4:
for i = 1, . . . , n do
5:/* prepare cost function for optimization */set up cost function
1 − hδΨi (y), wi(SVM0 )


(SVM4s(1 − hδΨi (y), wi) 4(yi , y)
1 )4m
H(y) ≡ 4(yi , y) − hδΨi (y), wi(SVM1 )p
(1 − hδΨi (y), wi) 4(yi , y)(SVM4s

2 )


p
4m
4(yi , y) − hδΨi (y), wi(SVM2 )
0where w ≡ ∑ j ∑y0 ∈S j α( jy0 ) δΨ j (y ).

6:/* find cutting plane */compute ŷ = arg maxy∈Y H(y)7:/* determine value of current slack variable */compute ξi = max{0, maxy∈Si H(y)}8:if H(ŷ) > ξi + ε then9:/* add constraint to the working set */Si ← Si ∪ {ŷ}10a:/* Variant (a): perform full optimization */αS ← optimize the dual of SVM0 , SVM∗1 or SVM∗2 over S, S = ∪i Si .

10b:/* Variant (b): perform subspace ascent */αSi ← optimize the dual of SVM0 , SVM∗1 or SVM∗2 over Si

end if13:
end for
14: until no Si has changed during iteration
12:

A convenient property of both variants of the cutting plane algorithm is that they have a very
general and well-defined interface independent of the choice of Ψ and 4. To apply the algorithm,
it is sufficient to implement the feature mapping Ψ(x, y) (either explicitly or via a joint kernel
function), the loss function 4(yi , y), as well as the maximization in step 6. All of those, in particular
the constraint/cut selection method, are treated as black boxes. While the modeling of Ψ(x, y)and 4(yi , y) is typically straightforward, solving the maximization problem for constraint selection
typically requires exploiting the structure of Ψ for output spaces that can not be dealt with byexhaustive search.
1463

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

In the slack re-scaling setting, it turns out that for a given example (xi , yi ) we need to identify
the maximum overŷ ≡ argmax{(1 − hw, δΨi (y)i)4(yi , y)} .
y∈YWe will discuss several cases for how to solve this problem in Section 4. Typically, it can besolved by an appropriate modification of the prediction problem in Equation (1), which recovers
f from F. For example, in the case of grammar learning with the F1 score as the loss function
via 4(yi , y) = (1 − F1 (yi , y)), the maximum can be computed using a modified version of the CKY
algorithm. More generally, in cases where 4(yi , ·) only takes on a finite number of values, a genericstrategy is a two stage approach, where one first computes the maximum over those y for which theloss is constant, 4(yi , y) = const, and then maximizes over the finite number of levels.
In the margin re-scaling setting, one needs to solve the maximization problemŷ ≡ argmax{4(yi , y) − hw, δΨi (y)i} .

(9)

y∈Y

In cases where the loss function has an additive decomposition that is compatible with the feature
map, one can fold the loss function contribution into the weight vector hw0 , δΨi (y)i = hw, δΨi (y)i −4(yi , y) for some w0 . This means the class of cost functions defined by F(x, ·; w) and F(x, ·; w) −4(y, ·) may actually be identical.
The algorithm for the zero-one loss is a special case of either algorithm. We need to identify thehighest scoring y that is incorrect,ŷ ≡ argmax{1 − hw, δΨi (y)i} .
y6=yi

It is therefore sufficient to identify the best solution ŷ = arg maxy∈Y hw, Ψ(xi , y)i as well as thesecond best solution ỹ = arg maxy∈Y \ŷ hw, Ψ(xi , y)i. The second best solution is necessary to detectmargin violations in cases where ŷ = yi , but hw, δΨi (ỹ)i < 1. This means that for all problems
where we can solve the inference problem in Equation (1) for the top two y, we can also apply ourlearning algorithms with the zero-one loss. In the case of grammar learning, for example, we canuse any existing parser that returns the two highest scoring parse trees.
We will now proceed by analyzing the presented family of algorithms. In particular, we willshow correctness and sparse approximation properties, as well as bounds on the runtime complexity.
3.3 Correctness and Complexity of the Algorithm
What we would like to accomplish first is to obtain a lower bound on the achievable improvement of
the dual objective by selecting a single variable α(iŷ) and adding it to the dual problem (cf. step 10
in Algorithm 1). While this is relatively straightforward when using quadratic penalties, the SVM1
formulation introduces an additional complication in the form of upper bounds on non-overlapping
subsets of variables, namely the set of variables α(iy) in the current working set that correspond to
the same training instance. Hence, we may not be able to answer the above question by optimizing
over α(iy) alone, but rather have to deal with a larger optimization problem over a whole subspace.
In order to derive useful bounds, it suffices to restrict attention to simple one-dimensional familiesof solutions that are defined by improving an existing solution along a specific direction η. Proving
1464

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

that one can make sufficient progress along a specific direction, clearly implies that one can make atleast that much progress by optimizing over a larger subspace that includes the direction η. A firststep towards executing this idea is the following lemma.
Lemma 10 Let J be a symmetric, positive semi-definite matrix, and define a concave objective in α1Θ(α) = − α0 Jα + hh, αi ,2which we assume to be bounded from above. Assume that a solution αo and an optimization direction η is given such that h∇Θ(αo ), ηi > 0. Then optimizing Θ starting from αo along the chosen
direction η will increase the objective by
max {Θ(αo + βη)} − Θ(αo ) =β>01 h∇Θ(αo ), ηi2
> 0.
2
η0 Jη

Proof The difference obtained by a particular β is given by


β 0
o
δΘ(β) ≡ β h∇Θ(α ), ηi − η Jη ,2
as can be verified by elementary algebra. Solving for β one arrives ath∇Θ(αo ), ηidδΘ = 0 ⇐⇒ β∗ =
.
dβ
η0 Jη
Notice that this requires η0 Jη > 0. Obviously, the positive semi-definiteness of J guarantees η0 Jη ≥0 for any η. Moreover η0 Jη = 0 together with h∇Θ(αo ), ηi > 0 would imply that limβ→∞ Θ(αo +βη) = ∞, which is in contradiction with the assumption that Θ is bounded. Plugging the value forβ∗ back into the above expression for δΘ yields the claim.

Corollary 11 Under the same assumption as in Lemma 10 and for the special case of an optimization direction η = er , the objective improves by1δΘ(β ) =
2Jrr
∗



∂Θ
∂αr

2

> 0.

Proof Notice that η = er implies h∇Θ, ηi = ∂∂αΘr and η0 Jη = Jrr .
Corollary 12 Under the same assumptions as in Lemma 10 and enforcing the constraint β ≤ D forsome D > 0, the objective improves by2
 h∇Θ(αo ),ηi
if h∇Θ(αo ), ηi ≤ Dη0 Jη
2η0 Jη
.
max {Θ(αo + βη)} − Θ(αo ) =Dh∇Θ(αo ), ηi − D2 η0 Jη otherwise
0<β≤D
2

1465

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

Moreover, the improvement can be upper bounded by1h∇Θ(αo ), ηioomax {Θ(α + βη)} − Θ(α ) ≥ min D,h∇Θ(αo ), ηi .
2
η0 Jη
0<β≤D
Proof We distinguish two cases of either β∗ ≤ D or β∗ > D. In the first case, we can simple applylemma 10 since the additional constraint is inactive and does not change the solution. In the second
case, the concavity of Θ implies that β = D achieves the maximum of δΘ over the constrained range.
Plugging in this result for β∗ into δΘ yields the second case in the claim.
Finally, the bound is obtained by exploiting that in the second caseβ∗ > D ⇐⇒ D <h∇Θ(αo ), ηi.
η0 Jη

Replacing one of the D factors in the D2 term of the second case with this bound yields an upperbound. The first (exact) case and the bound in the second case can be compactly combined as shownin the formula of the claim.

Corollary 13 Under the same assumption as in Corollary 12 and for the special case of a singlecoordinate optimization direction η = er , the objective improves at least by


∂Θ
o) 

(α
1
∂Θ o
max Θ(αo + βer ) − Θ(αo ) ≥ min D, ∂αr
(α )


2
J
∂α
0<β≤D
rr
r
Proof Notice that η = er implies h∇Θ, ηi = ∂∂αΘr and η0 Jη = Jrr .

We now apply the above lemma and corollaries to the four different SVM formulations, startingwith the somewhat simpler squared penalty case.
4s
Proposition 14 (SVM4s2 ) For SVM2 step 10 in Algorithm 1 the improvement δΘ of the dual objective is lower bounded by

δΘ ≥

1
ε2
,
2 4i R2i + Cn

where 4i ≡ max{4(yi , y)} and Ri ≡ max{kδΨi (y)k} .
yyProof Using the notation in Algorithm 1 one can apply Corollary 11 with multi-index r = (iŷ),h = 1, and J such that
δ(i, j)np.
J(iŷ)( jy) = hδΨi (ŷ), δΨ j (y)i + p
C 4(yi , ŷ) 4(yi , y)

Notice that the partial derivative of Θ with respect to α(iŷ) is given byξ∗∂Θ(αo ) = 1 − ∑ αo( jy) J(iŷ)( jy) = 1 − hw∗ , δΨi (ŷ)i − p i,∂α(iŷ)4(yi , ŷ)
j,y
1466

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

since the optimality equations for the primal variables yield the identitiesw =∑∗αo( jy) δΨ j (y),

and

ξ∗i =

j,y

Now, applying the condition of step 10, namelyboundnαo(iy).
∑ py6=yi C 4(yi , y)p4(yi , ŷ) (1 − hw∗ , δΨi (ŷ)i) > ξ∗i + ε, leads to theε∂Θ(αo ) ≥ p.
∂α(iŷ)4(yi , ŷ)nFinally, Jrr = kδΨi (ŷ)k2 + C4(yand inserting this expression and the previous bound into thei ,ŷ)
expression from Corollary 11 yields

1
2Jrr



∂Θ
∂α(iŷ)

2

≥

ε2
ε2
≥
.
n
2 4(yi , ŷ)kδΨi (ŷ)k2 + C
2 4i R2i + Cn

The claim follows by observing that jointly optimizing over a set of variables that include αr can
only further increase the value of the dual objective.

4m
Proposition 15 (SVM4m2 ) For SVM2 step 10 in Algorithm 1 the improvement δΘ of the dual
objective is lower bounded by

δΘ ≥

1 ε2
,
2 R2i + Cn

where Ri = max kδΨi (y)k .
yProof By re-defining δΨ̃i (y) ≡ √δΨi (y) we are back to Proposition 14 with
4(yi ,y)max{4(yi , y)kδΨ̃i (y)k2 } = max{kδΨi (y)k2 } = R2i ,
y

y

since
hw, δΨi (y)i ≥pξi4(yi , y) − ξi ⇐⇒ hw, δΨ̃i (y)i ≥ 1 − p.
4(yi , y)4s
Proposition 16 (SVM4s
1 ) For SVM1 step 10 in Algorithm 1 the improvement δΘ of the dual objective is lower bounded by


Cε
ε2
δΘ ≥ min,where 4i = max{4(yi , y)} and Ri = max{kδΨi (y)k} .
yy2n 842i R2i

Proof
1467

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

Case I:
If the working set does not contain an element (iy), then we can optimize over α(iŷ) under theconstraint that α(iŷ) ≤ 4(yi , ŷ) Cn = D. Notice that∂Θξ∗ + εε(αo ) = 1 − hw∗ , δΨi (ŷ)i > i≥,∂α(iŷ)4(yi , ŷ) 4(yi , ŷ)
where the first inequality follows from the pre-condition for selecting (iŷ) and the last one fromξ∗i ≥ 0. Moreover, notice that J(iŷ)(iŷ) ≤ R2i . Evoking Corollary 13 with the obvious identifications
yields


∂Θ
1
1 ∂Θ
o
δΘ ≥ min D,
(α )
(αo )
2
Jrr ∂α(iŷ)∂α(iŷ)
4(yi , ŷ)C
Cε
ε
ε
ε2
1
,
= min
,
> min
2
n
2n 2R2i 4(yi , ŷ)24(yi , ŷ)R2i 4(yi , ŷ)
The second term can be further bounded to yield the claim.
Case II:/ then we
If there are already active constraints for instance xi in the current working set, i.e. Si 6= 0,
may need to reduce dual variables α(iy) in order to get some slack for increasing the newly added
αn≤ 0 for y ∈ Si ,α(iŷ) . We thus investigate search directions η such that η(iŷ) = 1, η(iy) = − 4(y(iy)i ,ŷ) Cand η( jy0 ) = 0 in all other cases. For such η, we guarantee that αo + βη ≥ 0 since β ≤ Cn 4(yi , ŷ).
In finding a suitable direction to derive a good bound, we have two (possibly conflicting) goals.
First of all, we want the directional derivative to be positively bounded away from zero. Notice thath∇Θ(αo ), ηi = ∑ η(iy) (1 − hw∗ , δΨi (y)i) .
yFurthermore, by the restrictions imposed on η, η(iy) < 0 implies that the respective constraint is
active and hence 4(yi , y) (1 − hw∗ , δΨi (y)i) = ξ∗i . Moreover the pre-condition of step 10 ensuresthat 4(yi , ŷ) (1 − hw∗ , δΨi (ŷ)i) = ξ∗i + δ where δ ≥ ε > 0. Henceξ∗ih∇Θ(α ), ηi =4(yi , ŷ)oαo(iy)n1− ∑C y 4(yi , y)

!

+

ε
δ
≥
.
4(yi , ŷ) 4(yi , ŷ)

The second goal is to make sure the curvature along the chosen direction is not too large.
αo(iy)

αo(iy) n αo(iy0 ) nnη Jη = J(iŷ)(iŷ) − 2 ∑J(iŷ)(iy) + ∑ ∑J(iy)(iy0 )y6=ŷ 4(yi , ŷ) C
y6=ŷ y0 6=ŷ 4(yi , ŷ) C 4(yi , ŷ) C0≤ R2i + 2
≤ R2i + 2nR2i
n2 R2iαo(iy) +αo αo∑2 ∑ ∑ (iy) (iy0 )2
C4(yi , ŷ) y6=ŷ
C 4(yi , ŷ) y6=ŷ y0 6=ŷ
R2i 42i
4R2i 42iR2i 4i+≤.
4(yi , ŷ) 4(yi , ŷ)2 4(yi , ŷ)2
1468

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

αo

i
≤ C4
This follows from the fact that ∑y6=ŷ αo(iy) ≤ 4i ∑y6=ŷ 4(y(iy)n . Evoking Corollary 12 yields
i ,y)



1
h∇Θ(αo ), ηiδΘ ≥ min D,h∇Θ(αo ), ηi
2
η0 Jη




ε

 4(y , ŷ)C
ε
Cε
1
ε2
4(yi ,ŷ)
i
≥ min
, 2 2
= min
,
4Ri 4i  4(yi , ŷ)2n2n 8R2i 42i
4(yi ,ŷ)24m
Proposition 17 (SVM4m1 ) For SVM1 step 10 in Algorithm 1 the improvement δΘ of the dual
objective is lower bounded by

δΘ ≥

ε2
,
8R2i

where

Ri = max kδΨi (y)k .
yδΨi (y)we are back to Proposition 16 with
Proof By re-defining δΨ̃i (y) ≡ 4(yi ,y)max{4(yi , y)2 kδΨ̃i (y)k2 } = max{kδΨi (y)k2 } = R2i ,
y

y

since
hw, δΨi (y)i ≥ 4(yi , y) − ξi ⇐⇒ hw, δΨ̃i (y)i ≥ 1 −

ξi.
4(yi , y)This leads to the following polynomial bound on the maximum size of S.
Theorem 18 With R̄ = maxi Ri , 4̄ = maxi 4i and for a given ε > 0, Algorithm 1 terminates after
incrementally adding at most
2n4̄ 8C4̄R̄2
2n4̄ 8C4̄3 R̄2
C4̄2 R̄2 + n4̄
C4̄R̄2 + n4̄
,
,
max
,
,
and
max
ε
ε2
ε
ε2
ε2
ε2
4m
4s
4m
constraints to the working set S for the SVM4s
1 , SVM1 , SVM2 and SVM2 respectively.
Proof With S = 0/ the optimal value of the dual is 0. In each iteration a constraint is added thatis violated by at least ε, provided such a constraint exists. After solving the S-relaxed QP in step
10, the objective will increase by at least the amounts suggested by Propositions 16, 17, 14 and 15
respectively. Hence after t constraints, the dual objective will be at least t times these increments.
The result follows from the fact that the dual objective is upper bounded by the minimum of the
primal, which in turn can be bounded by C4̄ and 12 C4̄ for SVM∗1 and SVM∗2 respectively.

1469

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

Note that the number of constraints in S does not depend on |Y |. This is crucial, since |Y | isexponential or infinite for many interesting problems. For problems where step 6 can be computedin polynomial time, the overall algorithm has a runtime polynomial in n, R̄, 4̄, 1/ε, since at least
one constraint will be added while cycling through all n instances and since step 10 is polynomial.
This shows that the algorithm considers only a small number of constraints, if one allows an extra εslack, and that the solution is correct up to an approximation that depends on the precision parameter
ε. The upper bound on the number of active constraints in such an approximate solution depends
on the chosen representation, more specifically, we need to upper bound the difference vectorskΨ(xi , y) − Ψ(xi , ȳ)k2 for arbitrary y, ȳ ∈ Y . In the following, we will thus make sure that suitable
upper bounds are available.

4. Specific Problems and Special Cases
In the sequel, we will discuss a number of interesting special cases of the general scenario outlinedin the previous section. To model each particular problem and to be able to run the algorithm andbound its complexity, we need to examine the following three questions for each case:• Modeling: How can we define suitable feature maps Ψ(x, y) for specific problems?
• Algorithms: How can we compute the required maximization over Y for given x?
• Sparseness: How can we bound kΨ(x, y) − Ψ(x, y0 )k?
4.1 Multiclass Classification
A special case of Equation (1) is winner-takes-all (WTA) multiclass classification, where Y ={y1 , . . . , yK } and w = (v01 , . . . , v0K )0 is a stack of vectors, vk being a weight vector associated with thek-th class yk . The WTA rule is given by
F(x, yk ; w) = hvk , Φ(x)i .

f (x) = arg max F(x, y; w),
yk ∈Y

(10)

Here Φ(x) ∈ RD denotes an arbitrary feature representation of the inputs, which in many cases may
be defined implicitly via a kernel function.
4.1.1 M ODELINGThe above decision rule can be equivalently represented by making use of a joint feature map asfollows. First of all, we define the canonical (binary) representation of labels y ∈ Y by unit vectorsΛc (y) ≡ (δ(y1 , y), δ(y2 , y), . . . , δ(yK , y))0 ∈ {0, 1}K ,(11)

so that hΛc (y), Λc (y0 )i = δ(y, y0 ). It will turn out to be convenient to use direct tensor products ⊗to combine feature maps over X and Y . In general, we thus define the ⊗-operation in the following
manner⊗ : RD × RK → RD·K ,(a ⊗ b)i+( j−1)D ≡ ai · b j .

Now we can define a joint feature map for the multiclass problem byΨ(x, y) ≡ Φ(x) ⊗ Λc (y) .
1470

(12)

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

It is is easy to show that this results in an equivalent formulation of the multiclass WTA as expressedin the following proposition.
Proposition 19 F(x, y; w) = hw, Ψ(x, y)i, where F is defined in Equation (10) and Ψ in Equation (12).
KD
D
Proof For all yk ∈ Y : hw, Ψ(x, yk )i = ∑D·K
r=1 wr ψr (x, yk ) = ∑ j=1 ∑d=1 v jd φd (x)δ( j, k) = ∑d=1 vkd φd (x) =hvk , Φ(x)i.

4.1.2 A LGORITHMS
It is usually assumed that the number of classes K in simple multiclass problems is small enough,so that an exhaustive search can be performed to maximize any objective over Y . Similarly, we canfind the second best y ∈ Y .
4.1.3 S PARSENESS
In order to bound the norm of the difference feature vectors, we prove the following simple result.
Proposition 20 Define Ri ≡ kΦ(xi )k. Then kΨ(xi , y) − Ψ(xi , y0 )k2 ≤ 2R2i .
ProofkΨ(xi , y) − Ψ(xi , y0 )k2 ≤ kΨ(xi , y)k2 + kΨ(xi , y0 )k2 = 2kΦ(xi )k2 ,where the first step follows from the Cauchy-Schwarz inequality and the second step exploits thesparseness of Λc .

4.2 Multiclass Classification with Output Features
The first generalization we propose is to make use of more interesting output features Λ than the
canonical representation in Equation (11). Apparently, we could use the same approach as in Equation (12) to define a joint feature function, but use a more general form for Λ.
4.2.1 M ODELING
We first show that for any joint feature map Ψ constructed via the direct tensor product ⊗ thefollowing relation holds:
Proposition 21 For Ψ = Φ ⊗ Λ the inner product can be written asΨ(x, y), Ψ(x0 , y0 ) = Φ(x), Φ(x0 ) · Λ(y), Λ(y0 ) .

1471

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

Proof By simple algebra
D·K D·K

DK

D

r=1 s=1d=1 k=1 d 0 =1 k0 =1K

Ψ(x, y), Ψ(x0 , y0 ) = ∑ ∑ ψr (x, y)ψs (x0 , y0 ) = ∑ ∑ ∑ ∑ φd (x)λk (y)φd 0 (x0 )λk0 (y0 )
D

K

D

K

= ∑ ∑ φd (x)φd 0 (x0 ) ∑ ∑ λk (y)λk0 (y0 ) = Φ(x), Φ(x0 ) · Λ(y), Λ(y0 ) .
k=1 k0 =1

d=1 d 0 =1This implies that for feature maps Φ that are implicitly defined via kernel functions K, K(x, x0 ) ≡hΦ(x), Φ(x0 )i, one can define a joint kernel function as follows:
J((x, y), (x0 , y0 )) = Ψ(x, y), Ψ(x0 , y0 ) = Λ(y), Λ(y0 ) K(x, x0 ) .
Of course, nothing prevents us from expressing the inner product in output space via yet anotherkernel function L(y, y0 ) = hΛ(y), Λ(y0 )i. Notice that the kernel L is simply the identity in the standard multiclass case. How can this kernel be chosen in concrete cases? It basically may encode any
type of prior knowledge one might have about the similarity between classes. It is illuminating tonote the following proposition.
Proposition 22 Define Ψ(x, y) = Φ(x) ⊗ Λ(y) with Λ(y) ∈ RR ; then the discriminant function
F(x, y; w) can be written as
R

F(x, y; w) = ∑ λr (y)hvr , Φ(x)i,r=1

where w = (v01 , . . . , v0R )0 is the stack of vectors vr ∈ RD , one vector for each basis function of Λ.
Proof
R

D

R

r=1

d=1

r=1 d=1

D∑ λr (y) ∑ vrd φd (x) = ∑ ∑ wD·(d−1)+r λr (y)φd (x) = hw, Φ(x) ⊗ Λ(y)i= hw, Ψ(x, y)i = F(x, y; w).

We can give this a simple interpretation: For each output feature λr a corresponding weight vector vr
is introduced. The discriminant function can then be represented as a weighted sum of contributions
coming from the different features. In particular, in the case of binary features Λ : Y → {0, 1}R ,this will simply be a sum over all contributions hvr , Φ(x)i of features that are active for the class y,i.e. for which λr (y) = 1.
It is also important to note that the orthogonal representation provides a maximally large hypothesis class and that nothing can be gained in terms of representational power by including additionalfeatures.
1472

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

Corollary 23 Assume a mapping Λ(y) = (Λ̃(y)0 , Λc (y)0 )0 , Λ̃(y) ∈ RR and define Ψ̃(x, y) = Φ(x) ⊗Λ(y) and Ψ(x, y) = Φ(x)⊗Λc (y). Now, for every w̃ there is w such that w̃, Ψ̃(x, y) = hw, Ψ(x, y)iand vice versa.
Proof Applying Proposition 22 twice it follows that
*
R+K

R+K

r=1

r=1

w̃, Ψ̃(x, y) = ∑ λr (y)hṽr , Φ(x)i =+∑ λr (y)ṽr , Φ(x)= hvy , Φ(x)i = hw, Ψ(x, y)i .

R+Kλr (y)ṽr . The reverse direction is trivial and requires setting
where we have defined vy = ∑r=1ṽr = 0 for r = 1, . . . , R.

In the light of this corollary, we would like to emphasize that the rationale behind the use of classfeatures is not to increase the representational power of the hypothesis space, but to re-parameterize(or even constrain) the hypothesis space such that a more suitable representation for Y is produced.
We would like to generalize across classes as we want to generalize across input patterns in the standard formulation of classification problems. Obviously, orthogonal representations (corresponding
to diagonal kernels) will provide no generalization whatsoever across different classes y. The choiceof a good output feature map Λ is thus expected to provide an inductive bias, namely that learning
can occur across a set of classes sharing a common property.
Let us discuss some special cases of interest.
Classification with Taxonomies Assume that class labels y are arranged in a taxonomy. We willdefine a taxonomy as a set of elements Z ⊇ Y equipped with a partial order ≺. The partially orderedset (Z , ≺) might, for example, represent a tree or a lattice. Now we can define binary features forclasses as follows: Associate one feature λz with every element in Z according to(
1 if y ≺ z or y = z
λz (y) =0 otherwise.
This includes multiclass classification as a special case of an unordered set Z = Y . In general,
however, the features λz will be “shared” by all classes below z, e.g. all nodes y in the subtree
rooted at z in the case of a tree. One may also introduce a relative weight βz for every featureand define a β-weighted (instead of binary) output feature map Λ̃ as λ̃z = βz λz . If we reflect upon
the implication of this definition in the light of Proposition 22, one observes that this effectively
introduces a weight vector vz for every element of Z , i.e. for every node in the hierarchy.
Learning with Textual Class Descriptions As a second motivating example, we consider problems where classes are characterized by short glosses, blurbs or other textual descriptions. We
would like to exploit the fact that classes sharing some descriptors are likely to be similar, in orderto specify a suitable inductive bias. This can be achieved, for example, by associating a feature λwith every keyword used to describe classes, in addition to the class identity. Hence standard vector
space models like term-frequency of idf representations can be applied to model classes and theinner product hΛ(y), Λ(y0 )i then defines a similarity measure between classes corresponding to thestandard cosine-measure used in information retrieval.
1473

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

Learning with Class Similarities The above example can obviously be generalized to any situation, where we have access to a positive definite similarity function for pairs of classes. To come up
with suitable similarity functions is part of the domain model—very much like determining a good
representation of the inputs—and we assume here that it is given.
4.2.2 A LGORITHMS
As in the multiclass case, we assume that the number of classes is small enough to perform an
exhaustive search.
4.2.3 S PARSENESS
Proposition 20 can be generalized in the following way:
Proposition 24 Define Ri ≡ kΦ(xi )k and S ≡ maxy∈Y kΛ(y)k then kΨ(xi , y) − Ψ(xi , y0 )k2 ≤ 2R2i S2for all y, y0 ∈ Y .
Proof hΨ(xi , y), Ψ(xi , y)i = kΦ(xi )k2 · kΛ(y)k2 ≤ R2i S2 . In the last step, we have used Proposition 21.

4.3 Label Sequence Learning
The next problem we would like to formulate in the joint feature map framework is the problem oflabel sequence learning, or sequence segmentation/annotation. Here, the goal is to predict a label
sequence y = (y1 , . . . , yT ) for a given observation sequence x = (x1 , . . . , xT ). In order to simplify
the presentation, let us assume all sequences are of the same length T . Let us denote by Σ theset of possible labels for each individual variable yt , i.e. Y = ΣT . Hence each sequence of labels is
considered to be a class of its own, resulting in a multiclass classification problem with |Σ|T different
classes. To model label sequence learning in this manner would of course not be very useful, if one
were to apply standard multiclass classification methods. However, this can be overcome by anappropriate definition of the discriminant function.
4.3.1 M ODELING
Inspired by hidden Markov model (HMM) type of interactions, we propose to define Ψ to include
interactions between input features and labels via multiple copies of the input features as well asfeatures that model interactions between nearby label variables. It is perhaps most intuitive to startfrom the discriminant function
T −1T

F(x, y; w) = ∑ ∑ hw̄σ , Φ(xt )iδ(yt , σ) + η ∑ ∑ ∑ ŵσ,σ̄ δ(yt , σ)δ(yt+1 , σ̄)
t=1 σ∈Σ=*T

t=1 σ∈Σ σ̄∈Σ

+

*

T −1

w̄, ∑ Φ(x ) ⊗ Λ (y ) + η ŵ, ∑ Λ (y ) ⊗ Λ (y
t=1

t

c

t

t=1

c

t

c

t+1

+

)

.

(13)

Here w = (w̄0 , ŵ0 )0 , Λc denotes the orthogonal representation of labels over Σ, and η ≥ 0 is a scaling
factor which balances the two types of contributions. It is straightforward to read off the joint feature1474

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

map implicit in the definition of the HMM discriminant from Equation (13),T
Φ(xt ) ⊗ Λc (yt )∑t=1
Ψ(x, y) =.
T −1 c t
Λ (y ) ⊗ Λc (yt+1 )η ∑t=1
Notice that similar to the multiclass case, we can apply Proposition 21 in the case of an implicit
representation of Φ via a kernel function K and the inner product between labeled sequences canthus be written as
T

T −1

s,t=1

s,t=1

hΨ((x, y)), Ψ(x̄, ȳ)i = ∑ δ(yt , ȳs )K(xt , x̄s ) + η2 ∑ δ(yt , ȳs )δ(yt+1 , ȳs+1 ) .

(14)

A larger family of discriminant functions can be obtained by using more powerful feature functions
Ψ. We would like to mention three ways of extending the previous HMM discriminant. First ofall, one can extract features not just from xt , but from a window around xt , e.g. replacing Φ(xt )with Φ(xt−r , . . . , xt , . . . , xt+r ). Since the same input pattern xt now occurs in multiple terms, this has
been called the use of overlapping features (Lafferty et al., 2001) in the context of label sequencelearning. Secondly, it is also straightforward to include higher order label-label interactions beyond
pairwise interactions by including higher order tensor terms, for instance, label triplets ∑t Λc (yt ) ⊗Λc (yt+1 ) ⊗ Λc (yt+2 ), etc. Thirdly, one can also combine higher order y features with input features,for example, by including terms of the type ∑t Φ(xt ) ⊗ Λc (yt ) ⊗ Λc (yt+1 ).
4.3.2 A LGORITHMS
The maximization of hw, Ψ(xi , y)i over y can be carried out by dynamic programming, since thecost contributions are additive over sites and contain only linear and nearest neighbor quadratic
contributions. In particular, in order to find the best label sequence ŷ 6= yi , one can perform Viterbi
decoding (Forney Jr., 1973; Schwarz and Chow, 1990), which can also determine the second best
sequence for the zero-one loss (2-best Viterbi decoding). Viterbi decoding can also be used withother loss functions by computing the maximization for all possible values of the loss function.
4.3.3 S PARSENESS
Proposition 25 Define Ri ≡ maxt kΦ(xti )k; then kΨ(xi , y) − Ψ(xi , y0 )k2 ≤ 2T 2 (R2i + η2 ).
Proof Notice that kΨ(xi , y)k2 = k ∑t Φ(xti ) ⊗ Λc (yt )k2 + η2 k ∑t Λc (yt ) ⊗ Λc (yt+1 )k2 . The firstsquared norm can be upper bounded byk ∑ Φ(xti ) ⊗ Λc (yt )k2 = ∑ ∑ Φ(xsi ), Φ(xti ) δ(ys , yt ) ≤ T 2 R2itst

and the second one by η2 T 2 , which yields the claim.

4.4 Sequence Alignment
Next we show how to apply the proposed algorithm to the problem of learning to align sequencesx ∈ Σ∗ , where Σ∗ is the set of all strings over some finite alphabet Σ. For a given pair of sequences
1475

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUNx ∈ Σ∗ and y ∈ Σ∗ , alignment methods like the Smith-Waterman algorithm select the sequence of
operations (e.g. insertion, substitution) that transforms x into y and that maximizes a linear objectivefunctionâ(x, y) = argmax hw, Ψ(x, y, a)ia∈Athat is parameterized by the operation scores w. Ψ(x, y, a) is the histogram of alignment operations.
The value of hw, Ψ(x, y, â(x, y))i can be used as a measure of similarity between x and y. It is thescore of the highest scoring sequence of operations that transforms x into y. Such alignment models
are used, for example, to measure the similarity of two protein sequences.
4.4.1 M ODELING
In order to learn the score vector w we use training data of the following type. For each native
sequence xi there is a most similar homologous sequence yi along with the optimal alignment ai .
In addition we are given a set of decoy sequences yti , t = 1, . . . , k with unknown alignments. Notethat this data is more restrictive than what Ristad and Yianilos (1997) consider in their generativemodeling approach. The goal is to learn a discriminant function f that recognizes the homologous
sequence among the decoys. In our approach, this corresponds to finding a weight vector w so that
homologous sequences align to their native sequence with high score, and that the alignment scoresfor the decoy sequences are lower. With Yi = {yi , y1i , ..., yki } as the output space for the i-th example,
we seek a w so that hw, Ψ(xi , yi , ai )i exceeds hw, Ψ(xi , yti , a)i for all t and a. This implies a zero-one
loss and hypotheses of the formf (xi ) = argmax max hw, Ψ(x, y, a)i .
y∈Yi

a

(15)

The design of the feature map Ψ depends on the set of operations used in the sequence alignment
algorithm.
4.4.2 A LGORITHMS
In order to find the optimal alignment between a given native sequence x and a homologous/decoy
sequence y as the solution ofmax hw, Ψ(x, y, a)i ,a(16)

we can use dynamic programming as e.g. in the Smith-Waterman algorithm. To solve the argmax
in Equation (15), we assume that the number k of decoy sequences is small enough, so that we canselect among the scores computed in Equation (16) via exhaustive search.
4.4.3 S PARSENESS
If we select insertion, deletion, and substitution as our possible operations, each (non-redundant)
operation reads at least one character in either x or y. If the maximum sequence length is N,√then
the L1 -norm of Ψ(x, y, a) is at most 2N and the L2 -norm of Ψ(x, y, a) − Ψ(x, y0 , a0 ) is at most 2 2N.
1476

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

4.5 Weighted Context-Free Grammars
In natural language parsing, the task is to predict a labeled tree y based on a string x = (x1 , ..., xk )of terminal symbols. For this problem, our approach extends the approaches of Collins (2000) and
Collins and Duffy (2002b) to an efficient maximum-margin algorithm with general loss functions.
We assume that each node in the tree corresponds to the application of a context-free grammar rule.
The leaves of the tree are the symbols in x, while interior nodes correspond to non-terminal symbols
from a given alphabet N . For simplicity, we assume that the trees are in Chomsky normal form.
This means that each internal node has exactly two children. An exception are pre-terminal nodes(non-leaf nodes that have a terminal symbol as child) which have exactly one child.
4.5.1 M ODELING
We consider weighted context-free grammars to model the dependency between x and y. Grammar
rules are of the form nl [Ci → C j ,Ck ] or nl [Ci → xt ], where Ci ,C j ,Ck ∈ N are non-terminal symbols,and xt ∈ T is a terminal symbol. Each such rule is parameterized by an individual weight wl . A
particular kind of weighted context-free grammar are probabilistic context-free grammars (PCFGs),
where this weight wl is the log-probability of expanding node Hi with rule nl . In PCFGs, the individual node probabilities are assumed to be independent, so that the probability P(x, y) of sequencex and tree y is the product of the node probabilities in the tree. The most likely parse tree to yield x
from a designated start symbol is the predicted label h(x). This leads to the following maximization
problem, where we use rules(y) to denote the multi-set of nodes in y,h(x) = argmax P(y|x) = argmax
y∈Y

y∈Y

(

∑

nl ∈rules(y)

wl

)

.

More generally, weighted context-free grammars can be used in our framework as follows. Ψ(x, y)
contains one feature fi jk for each node of type ni jk [Ci → C j ,Ck ] and one feature fit for each nodeof type nit [Ci → xt ]. As illustrated in Figure 1, the number of times a particular rule occurs in thetree is the value of the feature. The weight vector w contains the corresponding weights so thathw, Ψ(x, y)i = ∑nl ∈rules(y) wl .

Note that our framework also allows more complex Ψ(x, y), making it more flexible than
PCFGs. In particular, each node weight can be a (kernelized) linear function of the full x andthe span of the subtree.
4.5.2 A LGORITHMS

The solution of argmaxy∈Y hw, Ψ(x, y)i for a given x can be determined efficiently using a CKYParser (see Manning and Schuetze, 1999), which can also return the second best parse for learning with the zero-one loss. To implement other loss functions, like 4(yi , y) = (1 − F1 (yi , y)), theCKY algorithm can be extended to compute both argmaxy∈Y (1 − hw, δΨi (y)i)4(yi , y) as well asargmaxy∈Y (4(yi , y) − hw, δΨi (y)i) by stratifying the maximization over all values of 4(yi , y) as
described in Joachims (2005) for the case of multivariate classification.
1477

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

flt 0/1 tax 0/1 flt 4
4 training instances per class
acc
28.32
28.32 27.47
4-loss
1.36
1.32
1.30
2 training instances per class
acc
20.20
20.46 20.20
4-loss
1.54
1.51
1.39

tax 4
29.74
1.21

+5.01 %
+12.40 %

21.73
1.33

+7.57 %
+13.67 %Table 1: Results on the WIPO-alpha corpus, section D with 160 groups using 3-fold and 5-foldcross validation, respectively. ‘flt’ is a standard (flat) SVM multiclass model, ‘tax’ thehierarchical architecture. ‘0/1’ denotes training based on the classification loss, ‘4’ refers
to training based on the tree loss.

4.5.3 S PARSENESS
Since the trees branch for each internal node, a tree over a sequence x of length N has N − 1 internal
nodes. Furthermore, it has N pre-terminal nodes. Thispmeans that the L1 -norm√ of Ψ(x, y) is 2N − 1and that the L2 -norm of Ψ(x, y) − Ψ(x, y0 ) is at most 4N 2 + 4(N − 1)2 < 2 2N.

5. Experimental Results
To demonstrate the effectiveness and versatility of our approach, we applied it to the problems oftaxonomic text classification (see also Cai and Hofmann, 2004), named entity recognition, sequencealignment, and natural language parsing.
5.1 Classification with Taxonomies
We have performed experiments using a document collection released by the World Intellectual
Property Organization (WIPO), which uses the International Patent Classification (IPC) scheme. We
have restricted ourselves to one of the 8 sections, namely section D, consisting of 1,710 documentsin the WIPO-alpha collection. For our experiments, we have indexed the title and claim tags. We
have furthermore sub-sampled the training data to investigate the effect of the training set size.
Document parsing, tokenization and term normalization have been performed with the MindServer
retrieval engine.2 As a suitable loss function 4, we have used a tree loss function which defines
the loss between two classes y and y0 as the height of the first common ancestor of y and y0 in
the taxonomy. The results are summarized in Table 1 and show that the proposed hierarchical
SVM learning architecture improves performance over the standard multiclass SVM in terms ofclassification accuracy as well as in terms of the tree loss.
5.2 Label Sequence Learning
We study our algorithm for label sequence learning on a named entity recognition (NER) problem.
More specifically, we consider a sub-corpus consisting of 300 sentences from the Spanish news
wire article corpus which was provided for the special session of CoNLL2002 devoted to NER.
2. This software is available at http://www.recommind.com.

1478

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

Method HMM CRF Perceptron SVM
Error
9.36 5.17
5.94
5.08
Table 2: Results of various algorithms on the named entity recognition task.
Method Train Err
SVM2
0.2±0.14s
SVM2
0.4±0.4SVM4m
0.3±0.2
2

Test Err
Const
Avg Loss
5.1±0.6 2824±106 1.02±0.01
5.1±0.8 2626±225 1.10±0.08
5.1±0.7 2628±119 1.17±0.12

Table 3: Results for various SVM formulations on the named entity recognition task (ε = 0.01,
C = 1).

The label set in this corpus consists of non-name and the beginning and continuation of personnames, organizations, locations and miscellaneous names, resulting in a total of |Σ| = 9 different
labels. In the setup followed in Altun et al. (2003), the joint feature map Ψ(x, y) is the histogramof state transition plus a set of features describing the emissions. An adapted version of the Viterbi
algorithm is used to solve the argmax in line 6. For both perceptron and SVM a second degree
polynomial kernel was used.
The results given in Table 2 for the zero-one loss, compare the generative HMM with conditional random fields (CRF) (Lafferty et al., 2001), Collins’ perceptron and the SVM algorithm. All
discriminative learning methods substantially outperform the standard HMM. In addition, the SVM
performs slightly better than the perceptron and CRFs, demonstrating the benefit of a large margin
approach. Table 3 shows that all SVM formulations perform comparably, attributed to the fact thevast majority of the support label sequences end up having Hamming distance 1 to the correct label
sequence. Notice that for 0-1 loss functions all three SVM formulations are equivalent.
5.3 Sequence Alignment
To analyze the behavior of the algorithm for sequence alignment, we constructed a synthetic dataset
according to the following sequence and local alignment model. The native sequence and the decoys
are generated by drawing randomly from a 20 letter alphabet Σ = {1, .., 20} so that letter c ∈ Σ hasprobability c/210. Each sequence has length 50, and there are 10 decoys per native sequence. To
generate the homologous sequence, we generate an alignment string of length 30 consisting of 4
characters “match”, “substitute”, “insert” , “delete”. For simplicity of illustration, substitutions
are always c → (c mod 20) + 1. In the following experiments, matches occur with probability 0.2,
substitutions with 0.4, insertion with 0.2, deletion with 0.2. The homologous sequence is createdby applying the alignment string to a randomly selected substring of the native. The shortening of
the sequences through insertions and deletions is padded by additional random characters.
We model this problem using local sequence alignment with the Smith-Waterman algorithm.
Table 4 shows the test error rates (i.e. the percentage of times a decoy is selected instead of thehomologous sequence) depending on the number of training examples. The results are averaged
over 10 train/test samples. The model contains 400 parameters in the substitution matrix Π and acost δ for “insert/delete”. We train this model using the SVM2 and compare against a generative1479

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

n
1
2
4
10
20
40
80

Train Error
GenModSVM220.0±13.3 0.0±0.0
20.0±8.2 0.0±0.0
10.0±5.5 2.0±2.0
2.0±1.3
0.0±0.0
2.5±0.8
1.0±0.7
2.0±1.0
1.0±0.4
2.8±0.5
2.0±0.5

Test Error
GenModSVM274.3±2.7 47.0±4.6
54.5±3.3 34.3±4.3
28.0±2.3 14.4±1.4
10.2±0.7 7.1±1.6
3.4±0.7
5.2±0.5
2.3±0.5
3.0±0.3
1.9±0.4
2.8±0.6

Table 4: Error rates and number of constraints |S| depending on the number of training examples(ε = 0.1, C = 0.01).

300

400

350
250

Average Number of Constraints

Average Number of Constraints

300
200

150

100

250

200

150

100
50
50

0
0

10

20

30
40
50
60
Number of Training Examples

70

0
0.001

80

0.01

0.1

1

EpsilonFigure 2: Number of constraints added to S depending on the number of training examples (middle)
and the value of ε (right). If not stated otherwise, ε = 0.1, C = 0.01, and n = 20.


P(xi ,z j )sequence alignment model, where the substitution matrix is computed as Πi j = log P(xi )P(z(seej)
e.g. Durbin et al., 1998) using Laplace estimates. For the generative model, we report the resultsfor δ = −0.2, which performs best on the test set. Despite this unfair advantage, the SVM performs
better for low training set sizes. For larger training sets, both methods perform similarly, with asmall preference for the generative model. However, an advantage of the SVM approach is that it isstraightforward to train gap penalties.
Figure 2 shows the number of constraints that are added to S before convergence. The graphon the left-hand side shows the scaling with the number of training examples. As predicted by
Theorem 18, the number of constraints is low. It appears to grow sub-linearly with the number ofexamples. The graph on the right-hand side shows how the number of constraints in the final Schanges with log(ε). The observed scaling appears to be better than suggested by the upper boundin Theorem 18. A good value for ε is 0.1. We observed that larger values lead to worse prediction
accuracy, while smaller values decrease efficiency while not providing further benefit.
1480

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

Method
PCFG
SVM2
4s
SVM2
SVM4m
2

Acc
61.4
66.3
62.2
63.5

Train
Prec Rec
92.4 88.5
92.8 91.2
93.9 90.4
93.9 90.8

F1
90.4
92.0
92.1
92.3

Acc
55.2
58.9
58.9
58.3

Test
Prec Rec86.8 85.2
85.3 87.2
88.9 88.1
88.7 88.1

Training Efficiency
F1 CPU-h %SVM Iter Const
86.0
0
N/A
N/A N/A
86.2
1.2
81.6
17 7494
88.5
3.4
10.5
12 8043
88.4
3.5
18.0
16 7117

Table 5: Results for learning a weighted context-free grammar on the Penn Treebank.
5.4 Weighted Context-Free Grammars
We test the feasibility of our approach for learning a weighted context-free grammar (see Figure 1)
on a subset of the Penn Treebank Wall Street Journal corpus. We consider the 4098 sentences oflength at most 10 from sections F2-21 as the training set, and the 163 sentences of length at most 10
from F22 as the test set. Following the setup in Johnson (1998), we start based on the part-of-speechtags and learn a weighted grammar consisting of all rules that occur in the training data. To solve theargmax in line 6 of the algorithm, we use a modified version of the CKY parser of Mark Johnson.3
The results are given in Table 5. They show micro-averaged precision, recall, and F1 for the
training and the test set. The first line shows the performance of the generative PCFG model using
the maximum likelihood estimate (MLE) as computed by Johnson’s implementation. The secondline show the SVM2 with zero-one loss, while the following lines give the results for the F1 -loss
4m
4(yi , y) = (1−F1 (yi , y)) using SVM4s
2 and SVM2 . All results are for C = 1 and ε = 0.01. All values of C between 10−1 to 102 gave comparable prediction performance. While the zero-one loss—
which is also implicitly used in Perceptrons (Collins and Duffy, 2002a; Collins, 2002)—achieves
better accuracy (i.e. predicting the complete tree correctly), the F1 -score is only marginally better
compared to the PCFG model. However, optimizing the SVM for the F1 -loss gives substantiallybetter F1 -scores, outperforming the PCFG substantially. The difference is significant according to a
McNemar test on the F1 -scores. We conjecture that we can achieve further gains by incorporating
more complex features into the grammar, which would be impossible or at best awkward to use ina generative PCFG model. Note that our approach can handle arbitrary models (e.g. with kernels
and overlapping features) for which the argmax in line 6 can be computed. Experiments with suchcomplex features were independently conducted by Taskar et al. (2004b) based on the algorithm
in Taskar et al. (2004a). While their algorithm cannot optimize F1-score as the training loss, theyreport substantial gains from the use of complex features.
In terms of training time, Table 5 shows that the total number of constraints added to the working
set is small. It is roughly twice the number of training examples in all cases. While the training isfaster for the zero-one loss, the time for solving the QPs remains roughly comparable. The rescaling formulations lose time mostly on the argmax in line 6 of the algorithm. This might be spedup, since we were using a rather naive algorithm in the experiments.

6. Conclusions
We presented a maximum-margin approach to learning functional dependencies for complex output
spaces. In particular, we considered cases where the prediction is a structured object or where
the prediction consists of multiple dependent variables. The key idea is to model the problem as
3. This software is available at http://www.cog.brown.edu/∼mj/Software.htm.

1481

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUNa (kernelized) linear discriminant function over a joint feature space of inputs and outputs. We
demonstrated that our approach is very general, covering problems from natural language parsing
and label sequence learning to multilabel classification and classification with output features.
While the resulting learning problem can be exponential in size, we presented an algorithm forwhich we prove polynomial convergence for a large class of problems. We also evaluated the algorithm empirically on a broad range of applications. The experiments show that the algorithm isfeasible in practice and that it produces promising results in comparison to conventional generative models. A key advantage of the algorithm is the flexibility to include different loss functions,making it possible to directly optimize the desired performance criterion. Furthermore, the ability
to include kernels opens the opportunity to learn more complex dependencies compared to conventional, mostly linear models.

References
Y. Altun, I. Tsochantaridis, and T. Hofmann. Hidden Markov support vector machines. In Proceedings of the Twentieth International Conference on Machine Learning, 2003.
L. Cai and T. Hofmann. Hierarchical document categorization with support vector machines. In
Proceedings of the ACM Thirteenth Conference on Information and Knowledge Management,
2004.
W. Cohen, R. Shapire, and Y. Singer. Learning to order things. Journal of Artificial Intelligence
Research, 10:243–270, 1999.
M. Collins. Discriminative reranking for natural language parsing. In Proceedings of the SeventiethInternational Conference on Machine Learning, 2000.
M. Collins. Discriminative training methods for hidden Markov models: theory and experimentswith perceptron algorithms. In Proceedings of the Conference on Empirical Methods in Natural
Language Processing, 2002.
M. Collins and N. Duffy. Convolution kernels for natural language. In Advances in Neural Information Processing Systems 14, pages 625–632, 2002a.
M. Collins and N. Duffy. New ranking algorithms for parsing and tagging: kernels over discrete
structures, and the voted perceptron. In Proceedings of the Fortieth Annual Meeting of the Association for Computational Linguistics, 2002b.
K. Crammer and Y. Singer. On the algorithmic implementation of multi-class kernel-based vector
machines. Machine Learning Research, 2:265–292, 2001.
K. Crammer and Y. Singer. Pranking with ranking. In Advances in Neural Information Processing
Systems 14, 2002.
R. Durbin, S. Eddy, A. Krogh, and G. Mitchison. Biological Sequence Analysis. Cambridge University Press, 1998.
G. D. Forney Jr. The Viterbi algorithm. Proceedings of the IEEE, 61:268–278, 1973.
1482

L ARGE M ARGIN M ETHODS FOR S TRUCTURED AND I NTERDEPENDENT O UTPUT VARIABLES

M. Grötschel, L. Lovàtz, and A. Schrijver. The ellipsoid method and its consequences in combinatorial optimization. Combinatorica, 1(2):169–197, 1981.
S. Har-Peled, D. Roth, and D. Zimak. Constraint classification for multiclass classification andranking. In Advances in Neural Information Processing Systems 14, 2002.
R. Herbrich, T. Graepel, and K. Obermayer. Large margin rank boundaries for ordinal regression.
In Advances in Large Margin Classifiers. MIT Press, Cambridge, MA, 2000.
T. Hofmann, I. Tsochantaridis, and Y. Altun. Learning over structured output spaces via joint kernel
functions. In Proceedings of the Sixth Kernel Workshop, 2002.
T. Joachims. Optimizing search engines using clickthrough data. In Proceedings of the ACM
Conference on Knowledge Discovery and Data Mining, 2002.
T. Joachims. Learning to align sequences: A maximum-margin approach. Technical report, Cornell
University, 2003.
T. Joachims. A support vector method for multivariate performance measures. In Proceedings of
the Twenty-Second International Conference on Machine Learning, 2005.
M. Johnson. PCFG models of linguistic tree representations. Computational Linguistics, 24(4):613–632, 1998.
N. Karmarkar. A new polynomial-time algorithm for linear programming. Combinatorica, 4(4):373–396, 1984.
J. E. Kelley. The cutting-plane method for solving convex programs. Journal of the Society for
Industrial Applied Mathematics, 8:703–712, 1960.
J. Lafferty, A. McCallum, and F. Pereira. Conditional random fields: Probabilistic models for segmenting and labeling sequence data. In Proceedings of the Eighteenth International Conference
on Machine Learning, pages 282–289, 2001.
C. D. Manning and H. Schuetze. Foundations of Statistical Natural Language Processing. MIT
Press, Cambridge, MA, 1999.
E. Ristad and P. Yianilos. Learning string edit distance. In Proceedings of the Seventeenth International Conference on Machine Learning, pages 287–295, 1997.
R. E. Schapire and Y. Singer. Boostexter: A boosting-based system for text categorization. Machine
Learning, 39(2-3):135–168, 2000.
R. Schwarz and Y. L. Chow. The n-best algorithm: An efficient and exact procedure for finding
the n most likely hypotheses. In Proceedings of the IEEE International Conference on Acoustics,
Speech and Signal Processing, pages 81–84, 1990.
A. Smola and T. Hofmann. Exponential families for generative and discriminative estimation. Technical report, 2003.
1483

T SOCHANTARIDIS , J OACHIMS , H OFMANN AND A LTUN

B. Taskar, C. Guestrin, and D. Koller. Max-margin Markov networks. In Advances in Neural
Information Processing Systems 16, 2004a.
B. Taskar, D. Klein, M. Collins, D. Koller, and C. Manning. Max-Margin parsing. In Proceedingsof the Conference on Empirical Methods in Natural Language Processing, 2004b.
I. Tsochantaridis, T. Hofmann, T. Joachims, and Y. Altun. Support vector machine learning forinterdependent and structured output spaces. In Proceedings of the Twenty-First International
Conference on Machine Learning, 2004.
V. Vapnik. Statistical Learning Theory. Wiley and Sons Inc., New York, 1998.
J. Weston, O. Chapelle, A. Elisseeff, B. Schölkopf, and V. Vapnik. Kernel dependency estimation.
In Advances in Neural Information Processing Systems 15, 2003.
J. Weston and C. Watkins. Multi-class support vector machines. Technical Report CSD-TR-98-04,
Department of Computer Science, Royal Holloway, University of London, 1998.
D. H. Younger. Recognition and parsing of context-free languages in time n3 . Information andControl, 2(10):189–208, 1967.

1484