Dependency Parsing
Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20
48 cards
Introduction
- How do dependency grammars describe syntactic structure?Solely as directed binary grammatical relations between words, with arcs from heads to dependents; phrasal constituents and phrase-structure rules play no direct role.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Introduction, p. 449
- What is a typed dependency structure, and what is the root?A dependency structure whose arc labels come from a fixed inventory of grammatical relations. A root node marks the head of the entire structure.
“I prefer the morning flight through Denver”
word head relation I prefer nsubj prefer ROOT root the flight det morning flight compound flight prefer obj through Denver case Denver flight nmod Every word has exactly one head; no phrase nodes. - Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Introduction, p. 449
- Why are dependency grammars popular in NLP?Head–dependent relations directly encode information buried in phrase-structure trees, such as predicate–argument relations (the arguments of prefer link straight to it); they are a good proxy for semantic relations. They also handle free word order well.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Introduction, pp. 449–450
- Why do dependency grammars suit languages with free word order like Czech?A phrase-structure grammar needs a separate rule for each position where, say, an adverbial could appear; a dependency grammar needs just one link type for that relation, abstracting away from word order.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Introduction, p. 450
20.1 Dependency relations
- What are the two arguments of a dependency relation?A head, the central organizing word, and a dependent, a kind of modifier.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 450
- Why is labeling grammatical functions especially important in flexible word-order languages?In English, functions like subject and object correlate with position and constituent type, so they are partly redundant with phrase structure; in freer word-order languages the relation labels carry information phrase structure barely provides.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 450
- What is Universal Dependencies (UD)?An open community effort to annotate dependencies and other grammatical properties across more than 100 languages with a shared inventory of 37 relations.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 451
- Into which two sets can the core UD relations be divided?Clausal relations, describing syntactic roles with respect to a predicate (often a verb), and modifier relations, describing how words modify their heads.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 451
- Give core UD relations and their meanings.
relation meaning nsubj nominal subject obj direct object iobj indirect object ccomp clausal complement nmod nominal modifier amod adjectival modifier appos appositional modifier det determiner case preposition, postposition, case marker conj conjunct cc coordinating conjunction - Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 451
- Identify the relations in “We booked her the first flight to Miami.”We nsubj of booked; her iobj; flight obj; the det and first amod of flight; Miami nmod of flight, with to as its case marker.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 452
- How is a dependency structure represented formally?As a directed graph \(G = (V, A)\): vertices \(V\) (usually the words; possibly punctuation, or stems and affixes) and arcs \(A\) encoding head–dependent relations and their functions.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 451
- What constraints make a dependency structure a dependency tree?(1) A single root node with no incoming arcs; (2) every other vertex has exactly one incoming arc; (3) a unique path from the root to every vertex. So each word has one head and the structure is connected.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 452
- What is projectivity?An arc from head to dependent is projective if the head has a path to every word between them in the sentence; a tree is projective if all its arcs are, i.e. it can be drawn with no crossing arcs.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 452
- Give an example of a non-projective dependency.In “JetBlue canceled our flight this morning which was already late”, the arc from flight to its modifier late must cross the arc linking morning to its head; flexible word order languages have many such cases.
The two arcs cross: the tree is non-projective. - Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 452
- Why does projectivity matter for dependency parsing?English dependency treebanks converted from phrase-structure treebanks via head rules are always projective (so wrong for non-projective cases), and transition-based parsers can only produce projective trees.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 453
- How are dependency treebanks created?By annotators directly building dependency structures, by hand-correcting parser output, or (for some early treebanks) by deterministically converting constituency treebanks.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.1, p. 453
20.2 Transition-based parsing
- What are the components of a transition-based dependency parser?A stack on which the parse is built, a buffer of input tokens, a set of relations, and an oracle (a predictor) that chooses the next transition given the configuration. It derives from shift-reduce parsing for programming languages.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 454
- What three intuitive actions does transition-based parsing formalize?Make the current word the head of a previously seen word; make a previously seen word the head of the current word; or postpone the current word for later.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 454
- Define the arc-standard transitions LEFTARC, RIGHTARC and SHIFT.LEFTARC: the top of the stack becomes head of the second word; pop the second. RIGHTARC: the second word becomes head of the top; pop the top. SHIFT: move the next buffer word onto the stack. LEFTARC can’t apply when ROOT is second; both arcs need two stack elements.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, pp. 454–455
- What characterizes arc-standard parsing?Transitions only relate the top two stack elements, and once a word is assigned its head it is removed from the stack and unavailable for further processing.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 455
- What are the initial and final configurations of a transition-based parse?Initial: stack [ROOT], buffer = all words, no relations. Final: buffer empty and only ROOT on the stack; the relations form the parse.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 455
- Why is transition-based parsing efficient, and what is its weakness?It is linear in sentence length: one left-to-right pass, each word shifted once and reduced once. But it is greedy: one choice per step, no backtracking, so a wrong decision can’t be undone.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 455
- Trace an arc-standard parse of “Book me the morning flight”.
stack buffer action root book me the morning flight SHIFT root book me the morning flight SHIFT root book me the morning flight RIGHTARC (book → me) root book the morning flight SHIFT ×3 root book the morning flight LEFTARC (morning ← flight) root book the flight LEFTARC (the ← flight) root book flight RIGHTARC (book → flight) root book RIGHTARC (root → book) - Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, pp. 456–457
- How does a transition-based parser produce labeled trees?Parameterize the arc transitions by relation, e.g. LEFTARC(nsubj), RIGHTARC(obj), giving one LEFTARC and RIGHTARC per label plus SHIFT; the oracle’s choice becomes harder.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 457
- How is training data for the oracle obtained from a treebank?Treebanks give sentences with trees, not configurations, so simulate the parser on each training sentence with a training oracle that consults the reference parse to pick the correct transition at each configuration, recording (configuration, transition) pairs.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 457
- What rules does the training oracle follow for arc-standard parsing?Choose LEFTARC if it creates a correct relation in the reference parse; otherwise RIGHTARC if it creates a correct relation and all dependents of the top word have already been attached; otherwise SHIFT.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 458
- Why must RIGHTARC wait until the top word has all its dependents?RIGHTARC pops the dependent off the stack; popping it early (e.g. attaching flight to book before through Houston) would make it unavailable as the head of later words.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 458
- What features does a feature-based transition oracle use?Word forms, lemmas, POS tags, heads and relations of the top stack elements and front buffer words, via templates like ⟨s1.w, op⟩, ⟨b1.t, op⟩, ⟨s1.wt, op⟩, and combinations like s1.t ∘ s2.t (e.g. NNS∘VBD); any classifier (logistic regression, SVM) can be used.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 459
- How does a neural oracle for transition-based parsing work?Encode the sentence, take the encodings of the top two stack words and the first buffer word, concatenate them, and feed a feedforward network with a softmax over transitions, trained with cross-entropy.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 460
- What problem does the arc-eager transition system solve?In arc-standard, a word can only be attached to its head after all its dependents are found, so attachments wait long (e.g. book → flight waits for through Houston), and long waits invite errors. Arc-eager attaches words to heads as early as possible.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 461
- How do arc-eager transitions differ from arc-standard ones?LEFTARC and RIGHTARC relate the top of the stack and the front of the buffer. RIGHTARC shifts the dependent onto the stack (so it can still take dependents), and a new REDUCE operator pops the stack.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 461
- How can beam search improve transition-based parsing?Instead of one greedy choice, apply all valid transitions to each configuration on an agenda, score the new configurations, and keep the best \(k\) (beam width). A configuration’s score is its predecessor’s score plus the transition’s score.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.2, p. 462
20.3 Graph-based parsing
- Why can graph-based dependency parsers be more accurate than transition-based ones?They score entire trees rather than making greedy local decisions, which helps especially with long sentences and distant heads, and they can produce non-projective trees.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 463
- What does an edge-factored model assume?That the score of a tree is the sum of the scores of its edges.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 464
- How is dependency parsing cast as a maximum spanning tree problem?Build a fully connected weighted directed graph over the words plus ROOT (edges = all possible head–dependent pairs, weights = scores); the best parse is the maximum spanning tree rooted at ROOT.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 464
- What two intuitions underlie the Chu-Liu-Edmonds algorithm?Every vertex (and every connected component) of a spanning tree has exactly one incoming edge; and only the relative weights of edges entering a vertex matter, so subtracting a constant from all of them doesn’t change the best tree.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, pp. 464–465
- Describe the Chu-Liu-Edmonds maximum spanning tree algorithm.Greedily pick the highest-scoring incoming edge for each vertex; if this forms a tree, done. Otherwise subtract each vertex’s best incoming score from its incoming edges, collapse a cycle into one node, recursively find the MST of the contracted graph, then expand the node, dropping the one cycle edge the chosen entering edge replaces.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 465
- What is the running time of Chu-Liu-Edmonds for parsing?\(O(mn)\) for \(m\) edges and \(n\) nodes, so \(O(n^3)\) on a fully connected graph; faster implementations reach \(O(m + n\log n)\).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 466
- What features does a feature-based edge scorer use, and how is it trained?Forms, lemmas and POS of head and dependent, context features before/after/between them, the relation, its direction and the distance. Weights are learned with inference-based learning and the perceptron rule: parse a training sentence; if wrong, lower the weights of features in the wrong parse not present in the reference.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, pp. 466–467
- How does the biaffine parser score a dependency edge?Encode the sentence; pass each token’s encoding through two feedforward networks to get a head representation and a dependent representation; score edge \(i \to j\) with \(\text{Biaff}(h^{head}_i, h^{dep}_j) = x^\top Uy + W(x \oplus y) + b\), which captures multiplicative interactions.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 468
- How does the biaffine parser turn edge scores into a labeled tree?A softmax over each word’s possible heads gives \(p(i \to j)\) (trained with cross-entropy); maximum spanning tree finds the best tree; then a second classifier of the same form picks the best label for each chosen edge.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.3, p. 469
20.4 Evaluation
- Why isn’t exact match a good metric for dependency parsers?It is too pessimistic: most sentences are marked wrong, so it isn’t fine-grained enough to guide development.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.4, p. 469
- What are LAS, UAS and LS?Labeled attachment score: % of words with the correct head and relation. Unlabeled attachment score: % with the correct head regardless of label. Label accuracy score: % with the correct label regardless of head.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.4, p. 469
- If a parse of a 6-relation sentence gets 4 relations fully right and one more with the correct head but wrong label, what are LAS and UAS?LAS = 4/6 = 2/3; UAS = 5/6.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.4, p. 469
- How can performance on a particular relation like nsubj be evaluated?With precision (share of system nsubj labels that are correct) and recall (share of gold nsubj relations found), and a confusion matrix of dependency types.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, §20.4, pp. 469–470
Historical notes
- How old is dependency grammar compared with constituency grammar?Much older: it goes back to Pāṇini (7th–4th c. BCE) and ancient Greek traditions; modern theories draw on Tesnière (1959). Constituency grammars date only to the 20th century.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Historical notes, p. 471
- Who introduced the main modern dependency parsing approaches?Covington (2001) the word-by-word deterministic idea; Yamada & Matsumoto and Kudo & Matsumoto shift-reduce with SVMs; Nivre (2003) the modern transition-based approach; McDonald et al. (2005) graph-based MST parsing; Chen & Manning (2014) neural transition parsing.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Historical notes, p. 471
- What notable dependency treebank projects exist?The Prague Dependency Treebank (multiple layers of morphological, syntactic and semantic annotation) and Universal Dependencies (nearly 200 treebanks in over 100 languages, evolved from Stanford dependencies and Google universal POS tags); CoNLL shared tasks drove much evaluation.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 20, Historical notes, pp. 471–472
Source
- Daniel Jurafsky and James H. Martin. Speech and Language Processing. 3rd edition (draft). https://web.stanford.edu/~jurafsky/slp3/