A Dynamic Oracle for Linear-Time 2-Planar Dependency Parsing

We propose an efficient dynamic oracle for training the 2-Planar transition-based parser, a linear-time parser with over 99% coverage on non-projective syntactic corpora. This novel approach outperforms the static training strategy in the vast majority of languages tested and scored better on most datasets than the arc-hybrid parser enhanced with the Swap transition, which can handle unrestricted non-projectivity.

Dynamic oracles (Goldberg and Nivre, 2012) are known to improve the accuracy of greedy parsers by enabling more robust training, by exploring configurations beyond the gold path.While dynamic oracles have been defined for many transition-based algorithms (Goldberg and Nivre, 2013;Goldberg et al., 2014;Gómez-Rodríguez et al., 2014;Gómez-Rodríguez and Fernández-González, 2015;de Lhoneux et al., 2017), none is available so far for the 2-Planar system.The lack of the arc-decomposability property, which can be used to derive dynamic oracles for parsers that have it, makes the obtention of one non-trivial.
To fill this gap, we define an efficient dynamic oracle for the 2-Planar transition-based parser, using similar loss calculation techniques as described in (Gómez-Rodríguez and Fernández-González, 2015) for the non-arc-decomposable Covington parser (Covington, 2001).Training the 2-Planar parser with this novel strategy achieves accuracy gains in the vast majority of datasets tested.In addition, we empirically compare our novel approach to the most similar existing alternative: 1 the arc-hybrid parser with a swap transition trained with a static-dynamic oracle, recently introduced by de Lhoneux et al. (2017); which can handle unrestricted non-projective dependencies in O(n 2 ) worst-case time in theory, but expected linear time in practice (Nivre, 2009).Our approach outperforms this swap-based system on average over a standard set of dependency treebanks.

The 2-Planar parser
We briefly sketch the 2-Planar transition system, which was defined by Gómez-Rodríguez andNivre (2010, 2013) under the transition-based parsing framework (Nivre, 2008) and is based on the arc-eager algorithm (Nivre, 2003), keeping its linear time complexity.It works by building, in a single pass, two non-crossing graphs (called planes) whose union provides a dependency parse in the set of 2-planar (or pagenumber-2) graphs, which is known to cover over 99% of parses in a large number of real treebanks (Gómez-Rodríguez and Nivre, 2010;Gómez-Rodríguez, 2016).
Parser configurations have the form c = 1 Although the two-register parser by Pitler and McDonald (2015) is even closer to ours in terms of the transition system (being based on arc-eager and running in linear time), no dynamic oracle is known for it, to the best of our knowledge.
Σ 1 , Σ 2 , B, A , where Σ 1 and Σ 2 are, respectively, the active stack and inactive stack and are tied to each of the planes or pages of the output graph, B is a buffer of unread words, and A the set of dependency arcs built so far.For an input string w 1 • • • w n , the parser starts at configuration c s (w 1 . . .w A is reached, and A yields the output. Figure 1 shows the parser's transitions.The Shift transition pops the first (leftmost) word in the buffer, and pushes it to both stacks; the Reduce transition pops the top word from the active stack, implying that we have added all arcs to or from it on the plane tied to that stack; and the Left-Arc and Right-Arc transitions create a leftward or rightward dependency arc connecting the first word in the buffer to the top of the active stack.Finally, the Switch transition makes the active stack inactive and vice versa, changing the plane the parser is working with.Transitions that violate the singlehead or acyclicity constraints are disallowed, so that the output is a forest.Finally, to guarantee the termination of the parsing process, two consecutive Switch transitions are not allowed.

A dynamic oracle
We now define an efficient dynamic oracle to train the 2-Planar algorithm, which operates under the assumption of a fixed assignment of arcs to planes.
Following Goldberg and Nivre (2013), if the Hamming loss (L) between trees t and t G is the amount of words with a different head in t and t G , then implementing a dynamic oracle reduces to defining a loss function (c) which, given a parser configuration c and a gold tree t G , computes the minimum loss between t G and a tree reachable from c.2 We call this the minimum loss of configuration c, (c) = min t|c t L(t, t G ).A correct dynamic oracle will return the set of transitions τ that do not increase this loss (i.e., (τ (c)) − (c) = 0), thus leading to the best parse reachable from c.
For parsers that are arc-decomposable3 , (c) can be obtained by counting gold arcs that are not individually reachable from c, which is trivial in most parsers.Unfortunately, the 2-Planar parser is non-arc-decomposable.To show this, it suffices to consider any configuration where an incorrect arc created in A forms a cycle together with a set of otherwise reachable gold arcs, just as in the proof of non-arc-decomposability for Covington provided by Gómez-Rodríguez and Fernández-González (2015).In fact, the same counterexample provided there also works for this parser.
Note, however, that non-arc-decomposability in the 2-Planar parser not only comes from cycles (as in Covington) but also from situations where, due to a poor assignment of planes to already-built arcs, no possible plane assignment allows building a set of pending gold arcs.Thus, the loss calculation technique of the Covington dynamic oracle is not directly applicable to the 2-Planar parser.
However, if we statically choose a canonical plane assignment and we calculate loss with respect to that assignment (i.e., creating a correct arc in the non-canonical plane incurs loss), then the Covington technique, based on counting individually unreachable arcs and then correcting for the presence of cycles, works for the 2-Planar parser.This is the idea of our dynamic oracle, which therefore is a correct dynamic oracle only with respect to a preset criterion for plane assignment, and not for all the possible plane assignments that would produce the gold dependency structure.
In particular, given a 2-planar gold dependency tree whose set of arcs is t G , we need to divide it into two gold arc sets t 1 G and t 2 G , associated with each plane. 4In this paper, we take as canonical the division provided by the static oracle of Gómez-Rodríguez and Nivre (2010), which prefers to build arcs in the active plane to minimize the number of Switch transitions needed. 5nce the plane assignment is set, we can associate individually unreachable arcs to a plane.Then, we can calculate configuration loss as: Right-Arc: ) and wj → * wi ∈ A (acyclicity).
Switch: where for i ∈ {1, 2}, each set ; and n c (G) denotes the number of cycles in a graph G.
To compute the sets of individually unreachable arcs G (the set of already-built arcs from the plane of interest), and at least one of the following holds: min(x, y) must be in plane i's stack or in the buffer, and max(x, y) must be in the buffer so that the arc x → y can still be built), • there is some z = 0, z = x such that z → y ∈ A, (i.e., we cannot create x → y because it would violate the single-head constraint), • x and y are on the same weakly connected component of A (i.e., we cannot create x → y due to the acyclicity constraint).
• x → y ∈ A ∩ t 3−i G (i.e., the arc was already erroneously created in the other plane and, therefore, is unreachable in plane i).
Once we have U i (c, t i G ) for each of the two planes, I i (c, t i G ) can be obtained as G ) has in-degree 1, the algorithm by Tarjan (1972) can be used to implement the function n c to count its cycles in O(n) time.For this reason, the full loss calculation runs in linear time as well. 6iven a plane assignment, (c) is an exact expression of the loss of a configuration of the 2-Planar parser as expressed in Figure 1, without the control constraint that forbids two consecutive Switch transitions.This can be proven using the same reasoning as for the Covington loss expression of (Gómez-Rodríguez and Fernández-González, 2015).Thus, the computation of (c) provides a complete and correct dynamic oracle for this parser under a given plane assignment, by directly evaluating (τ (c)) − (c) for each transition τ .However, to make the oracle correct for the practical version, where consecutive Switch transitions are disallowed, we need to modify the cost calculation for the Switch transition.
In particular, applying a Switch transition does not affect the loss, so (Switch(c)) − (c) is always 0. Indeed, if Switch transitions are always allowed, their cost is zero because they can always be undone and thus never affect the reachability of any arcs.However, when consecutive Switch transitions are banned to ensure parser termination, choosing to Switch can have consequences as, in the resulting configuration, the parser will be forced to take one of the other four transitions, which may lead to suboptimal outcomes compared to not having switched.
To address this, we compute the cost of Switch transitions instead as min({ (τ (Switch(c))) − (c)|τ = Switch}), i.e., the minimum number of gold arcs missed after being forced to apply one of the other four transitions after Switch (if this cost is 0, then switching stacks is an optimal choice).Adding this modification makes the dynamic oracle correct for the practical version of the parser that disallows consecutive Switch transitions.
Regularization While the above dynamic oracle is theoretically correct, we noticed experimentally that the Switch transition tends to switch stacks very frequently during training, due to exploration.This leads the parser to learn unnecessarily long and complex transition sequences that change planes more than needed, harming accuracy.
To avoid this, we add a regularization term to (c) representing the transition sequence length from c to its minimum-loss reachable tree(s), to discourage unnecessarily long sequences.This amounts to penalizing the Switch transition if there is any zero-cost transition available in the active plane and changing planes will delay its application.Thus, arcs assigned to the currently active plane will be built before switching if possible, enforcing a global arc creation order.This is similar to the prioritization of monotonic paths in (Honnibal et al., 2013, §6), as they also penalize unneeded actions that will need to be undone later.

Data and Evaluation
We conduct our experiments on the commonlyused non-projective benchmark compounded of nine datasets from the CoNLL-X shared task (Buchholz and Marsi, 2006) and all datasets from the CoNLL-XI shared task (Nivre et al., 2007). 7We also use the Stanford Dependencies (de Marneffe and Manning, 2008) conversion (using the Stanford parser v3.3.0)8 of the WSJ Penn Treebank (PTB-SD) (Marcus et al., 1993) with standard splits.Labelled and Unlabelled Attachment Scores (LAS and UAS) are computed including punctuation for all datasets except for the PTB where, following common practice, the punctuation is excluded.We train our system for 15 iterations and choose the best model according to development set accuracy.Statistical significance is calculated using a paired test with 10,000 bootstrap samples.

Model
We implement both the static oracle and the dynamic oracle with aggressive exploration for the 2-Planar parser under the neural network architecture proposed by Kiperwasser and Goldberg (2016).We also add the static-dynamic arc-hybrid parser with Swap transition (de Lhoneux et al., 2017), implemented under the same framework to perform a fair comparison.
The neural network architecture used in this paper is taken from Kiperwasser and Goldberg (2016).We use the same BiLSTM-based featurization method that concatenates the representations of the top 3 words on the active stack and the leftmost word in the buffer for the arc-hybrid and 2-Planar algorithms, and we add the top 2 words on the inactive stack for the latter.Following Kiperwasser and Goldberg (2016), we also include the BiLSTM vectors of the rightmost and leftmost modifiers of words from the stacks, as well as the leftmost modifier of the first word in the buffer.We initialize word embeddings with 100-dimensional GloVe vectors (Pennington et al., 2014) for English and use 300-dimensional Facebook vectors (Bojanowski et al., 2016) for other languages.The other parameters of the neural network keep the same values as in (Kiperwasser and Goldberg, 2016).

Results
Table 1 shows that the 2-Planar parser trained with a dynamic oracle outperforms the static training strategy in terms of UAS in 15 out of 20 languages, with 8 of these improvements statistically significant (α = .05),and one statistically significant decrease.When comparing with the enhanced archybrid system in Table 2, our approach provides a better UAS in 12 out of 20 datasets tested, achieving statistically significant (α = .05)gains in accuracy on 7 of them, and significant losses on 3 of them.
We could not find a clear pattern to explain why the 2-Planar algorithm outperforms arc-hybrid plus Swap in some languages and vice versa.The latter seems to work better on treebanks with less non-projectivity such as the English, Chinese and Japanese datasets, and worse on those with higher amounts like Turkish, Dutch or Basque.However, some cases like Czech or Catalan go against this trend.From (Gómez-Rodríguez and Nivre, 2010), we also know that the Dutch and German treebanks have a relatively high proportion of non-2-planar trees, but the 2-Planar parser seems to be a better option on them than the extended arc- hybrid system that can handle unrestricted nonprojectivity.The reasons, beyond the scope of this research, might be related to different dependency length distributions or non-projective topologies.
We noticed that, in general, the 2-Planar parser has higher precision on non-projective arcs and the enhanced arc-hybrid parser has a better recall.

Conclusion
We present an efficient dynamic oracle to train the 2-Planar transition-based parser, which is correct with respect to a given plane assignment, and results in notable gains in accuracy.The parser trained with this dynamic oracle performs better on average than an expected linear-time parser supporting unrestricted non-projectivity.

Figure 1 :
Figure1: Transitions of the 2-Planar dependency parser.The notation w i → * w j ∈ A means that there is a (possibly empty) directed path from w i to w j in A.

Table 2 :
Parsing accuracy of the 2-Planar parser trained with the dynamic oracle and the arc-hybrid parser with the Swap transition trained with a static-dynamic oracle on CoNLL-XI (first block), CoNLL-X (second block) and PTB-SD (third block) datasets.Best results for each language are in boldface.Statistically significant improvements (α = .05)are marked with * .