Graph-Based and Neural Dependency Parsing
Greedy transition parsing commits locally; the graph-based family scores whole trees instead. This lesson scores every candidate head-dependent edge and extracts the maximum spanning tree with Chu-Liu/Edmonds, develops the biaffine neural scorer that made graph-based parsing the accuracy leader, evaluates parsers with the unlabeled and labeled attachment scores (UAS and LAS), and closes on where the two parser families sit and what they feed downstream.
╌╌╌╌
This builds on dependency parsing, which fixed the dependency-tree formalism and built the transition-based parser — a greedy, linear-time stack-and-buffer machine. That family is fast but limited; the graph-based family scores whole trees instead, at a higher cost, which is where we pick up.
Graph-based parsing
Greedy transition parsing has two weaknesses: it commits locally, so a mistake is irreversible, and it cannot produce non-projective trees. Graph-based parsing fixes both by scoring whole trees rather than local decisions.1 It is more accurate than transition-based parsing on long sentences, where a head can sit far from its dependent, and it produces non-projective trees for free.
The search is over , the space of all trees for a sentence :
To make that argmax tractable we assume the score is edge-factored — the tree's score is the sum of independent edge scores:
Under this assumption the parser has two jobs: (1) assign a score to every possible edge, and (2) find the best tree given those scores.
Maximum spanning tree
Build a fully-connected weighted directed graph: one vertex per word plus , and a scored edge for every possible head-dependent pair (with having outgoing edges only). A spanning tree of this graph that starts from is exactly a valid parse, and the highest-scoring one — the maximum spanning tree — is the optimal parse.2
The Chu-Liu/Edmonds algorithm finds it. The idea rests on two facts. First, every vertex of a spanning tree has exactly one incoming edge, so a natural first move is greedy: for each vertex, keep only its single highest-scoring incoming edge. Second, only the relative weights of edges entering a vertex matter — subtracting a constant from every edge into a vertex leaves the maximum spanning tree unchanged. If greedy selection happens to yield a tree, it is optimal. When it instead produces a cycle, the algorithm re-scores (subtract each vertex's best incoming score from all its incoming edges, zeroing the selected ones), contracts the cycle into a single node, and recurses on the smaller graph; expanding the contracted node afterward reveals which single cycle edge to delete.2
- 1one best incoming edge per vertex
- 2for each do
- 3
- 4
- 5for each do
- 6re-score relative to best
- 7if is a spanning tree then
- 8return
- 9a cycle in
- 10collapse the cycle to one node
- 11recurse
- 12restore cycle, drop one edge
- 13return
On the fully connected graph the number of edges is , and this version of the algorithm runs in time; faster implementations reach . Nothing in the procedure references word order, so the maximum spanning tree may cross itself — that is, graph-based parsing produces non-projective trees whenever the scores favor them, which is precisely what transition-based parsing cannot do.
A worked Chu-Liu/Edmonds trace
The one-line description of the algorithm hides the interesting case — the cycle — so work it through on real numbers. Take three words , , plus , with these edge scores (only the relevant edges shown):
Round 1 — greedy selection. For each non-root vertex keep only its single highest-scoring incoming edge. Vertex 's best incoming edge is (9). Vertex 's best is (30, beating at 10 and at 3). Vertex 's best is (31, beating at 20). The selected set is — and is a cycle. Not a tree, so recurse.
Re-score. Subtract each vertex's best incoming score from all edges into that vertex, which zeroes the selected edge and makes every other incoming edge negative by its shortfall. Into : becomes , becomes , becomes . Into : becomes , becomes . Into : only , now .
Contract. Collapse the cycle into one node . An edge entering the cycle from outside now enters with its re-scored weight: gives a score of ; gives a score of . Edges leaving the cycle keep their original scores.
Recurse and expand. On the contracted graph, 's best incoming edge is (0) and 's best is (, since ). Those two form a spanning tree of the small graph, so the recursion returns . Now expand back into and . The edge into the cycle was , which came from , so 's head is ; that breaks the cycle exactly at , meaning we delete the cycle edge and keep . The final tree is
with total score . The greedy edge ( at 31) was dropped because keeping it would leave a cycle; the contraction found the best tree, not the best set of local edges.
Scoring the edges
The remaining job is scoring an edge. A feature-based scorer writes each edge score as a weighted sum of features — word forms, lemmas, and parts of speech of the head and dependent, features of the words between and around them, the candidate relation, its direction, and the head-to-dependent distance:
The weights are trained not to predict a class but to score correct trees above incorrect ones — inference-based learning with the perceptron rule: parse a training sentence, and if the predicted tree is wrong, lower the weights of the features present in the wrong parse but absent from the gold parse.1
A biaffine neural scorer is the modern state of the art.3 Encode the sentence once into contextual embeddings . For each token, two feedforward networks produce a head representation and a dependent representation:
The score of the directed edge (head , dependent ) is a biaffine function, which mixes a bilinear term (multiplicative interaction) with a linear term and a bias:
with learned , , . A softmax over all candidate heads of a fixed dependent turns these scores into , trained with cross-entropy; the resulting scores feed the maximum-spanning-tree extractor.
The full labeled biaffine parser trains two classifiers: an edge-scorer, which picks the tree structure via maximum spanning tree, and a separate label-scorer of the same form, which assigns the best relation to each edge in that tree.
Evaluation
An exact-match metric — how many sentences are parsed perfectly — is too pessimistic to guide development, since one wrong arc condemns a whole sentence. Dependency parsers are scored at the level of individual words with attachment accuracy: the fraction of words assigned the correct head.4
Compare a reference and a system parse of Book me the flight through Houston,
which has six scored words.
The system attaches five of the six words to the correct head — every word except
me, which it hangs off flight instead of Book. That is a UAS of 5/6. Of
those five, one more is labeled wrong (in Jurafsky & Martin's version the book flight arc is present but mislabeled), so four words have both the right head and
the right label: an LAS of 4/6.4 A third figure, label accuracy (LS),
counts correct labels regardless of attachment. Per-relation precision and recall
(how many nsubj arcs the system proposed were right, how many gold nsubj arcs it
found) diagnose which relations a parser handles poorly, and a confusion matrix
shows which relations it swaps.
Neural dependency parsers
Jurafsky & Martin describe the neural oracle and the biaffine scorer in outline; the papers that introduced them are worth reading in their own right, because each fixed a concrete failure of the linear-model parsers that preceded it.
Chen and Manning (2014) built the first neural transition-based parser and reported the result that started the shift.5 Feature-based oracles spend most of their time not on classification but on feature extraction: instantiating and looking up millions of sparse, hand-conjoined indicator features (the templates), which the authors measured at over 95% of parse time. Their model replaces those templates with dense embeddings of a fixed set of stack and buffer positions — words, part-of-speech tags, and already-assigned arc labels — concatenated and passed through a single hidden layer with a cube activation , chosen so the hidden units mix triples of inputs and so recover feature conjunctions automatically. On the English Penn Treebank it reached 92.0 UAS / 89.7 LAS while parsing over 1000 sentences per second, both faster and more accurate than the sparse-feature parsers, and it did so with no manually specified feature combinations.5 The lesson others took from it: the value of the sparse templates was the conjunctions, and a small network learns those from embeddings.
Dozat and Manning (2017) produced the biaffine graph-based parser sketched above, and it remains a strong baseline.6 Two design choices carry the result. First, before the biaffine scorer, each token's encoder state passes through a small feedforward network that strips it down to just the information needed for head-or-dependent decisions — the recurrence carries a lot of tagging and morphological detail the arc decision does not need. Second, the scoring is genuinely biaffine rather than a plain bilinear form: the extra linear term lets the model capture the prior probability that a given word is a head at all, independent of the candidate dependent, which a pure cannot express. On the standard English benchmark the parser reached about 95.7 UAS / 94.1 LAS, then state of the art, and the same architecture won or placed near the top across dozens of languages in the CoNLL 2017 multilingual shared task.6 Feed it a modern pretrained encoder in place of its biLSTM and the numbers climb further.
Two directions extend these. Kiperwasser and Goldberg (2016) showed that a biLSTM feature extractor could be shared and trained jointly for both the transition-based and graph-based parsers, closing much of the gap between the two families and making clear that the encoder, not the inference algorithm, was doing most of the work.7 And once large pretrained encoders arrived, the trend was to drop explicit parsing structure: some systems predict each word's head by a softmax over positions with no tree constraint at all and only project to a valid tree at decode time, while others question whether an explicit parse is needed downstream when a transformer's attention already encodes much syntactic structure.8 The parser families in this lesson did not disappear — the biaffine scorer plus Chu-Liu/Edmonds is still how you get a guaranteed well-formed tree — but the balance of effort moved decisively from the inference algorithm to the representation it scores.
Where this sits
Dependency parsing trades the constituency tree's phrasal structure for a flatter,
lexical picture that puts predicate-argument relations on the surface — the input
the next stage needs. Both parser families are supervised, both
learn from treebanks (built by hand for morphologically rich languages, or
converted from
constituency treebanks
by head rules for English), and both now run on neural encoders. Transition-based
parsing wins on speed with its linear greedy pass; graph-based parsing wins on
accuracy and on non-projective languages by scoring whole trees. The typed arcs
they produce — nsubj, dobj, and the rest — are the scaffold on which
semantic roles and information extraction
read off who did what to whom.
Footnotes
- Jurafsky & Martin, §14.5 — Graph-Based Dependency Parsing: edge-factored scoring, why graph-based parsers beat transition-based ones on long sentences and produce non-projective trees, and the feature-based edge scorer trained by inference-based perceptron learning. ↩ ↩2
- Jurafsky & Martin, §14.5.1 — Parsing via finding the maximum spanning tree: the fully connected rooted score graph, the equivalence of best parse and maximum spanning tree, and the Chu-Liu/Edmonds greedy-selection, re-scoring, contract-and-recurse algorithm running in here. ↩ ↩2
- Jurafsky & Martin, §14.5.3 — A neural algorithm for assigning scores: the biaffine parser of Dozat and Manning, separate head and dependent feedforward networks, the biaffine scoring function , and its separate edge-scorer and label-scorer. ↩
- Jurafsky & Martin, §14.6 — Evaluation: unlabeled and labeled attachment scores (UAS and LAS), the worked Book me the flight through Houston example giving LAS 4/6 and UAS 5/6, label accuracy, and per-relation precision, recall, and confusion matrices. ↩ ↩2
- Chen & Manning (2014),
A Fast and Accurate Dependency Parser using Neural Networks,
EMNLP 2014. The first neural transition-based parser: dense embeddings of a fixed set of stack/buffer word, POS, and label positions through a cube-activation hidden layer, replacing sparse feature templates; ~92.0 UAS / 89.7 LAS on the English Penn Treebank at over 1000 sentences/second. They report that feature extraction, not classification, dominated the runtime of prior sparse-feature parsers. ↩ ↩2 - Dozat & Manning (2017),
Deep Biaffine Attention for Neural Dependency Parsing,
ICLR 2017. The biaffine graph-based parser: per-token head/dependent feedforward reductions of a biLSTM encoding, a biaffine edge scorer mixing a bilinear term with a linear (head-prior) term, and a separate biaffine label scorer; about 95.7 UAS / 94.1 LAS on English, and top results across languages in the CoNLL 2017 shared task. ↩ ↩2 - Kiperwasser & Goldberg (2016),
Simple and Accurate Dependency Parsing Using Bidirectional LSTM Feature Representations,
TACL. A shared biLSTM feature extractor trained jointly with either a transition-based or a graph-based parser, showing the encoder does most of the work and narrowing the gap between the two parser families. ↩ - Hewitt & Manning (2019),
A Structural Probe for Finding Syntax in Word Representations,
NAACL 2019, showed that pretrained transformer representations linearly encode dependency-tree distances; together with graph-based decoders that predict heads by position-softmax and only project to a valid tree at decode time, this reflects the field's shift of effort from the inference algorithm to the learned representation. ↩
╌╌ END ╌╌