63
Dependency Parsing Computational Linguistics: Jordan Boyd-Graber University of Maryland INTRO / CHART PARSING Adapted from slides by Neelamadhav Gantayat and Ryan MacDonald Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 1 / 28

Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

  • Upload
    others

  • View
    19

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Dependency Parsing

Computational Linguistics: Jordan Boyd-GraberUniversity of MarylandINTRO / CHART PARSING

Adapted from slides by Neelamadhav Gantayat and Ryan MacDonald

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 1 / 28

Page 2: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Dependency Syntax

� Turns sentence into syntactic structure

� Essential for information extraction and other NLP tasks

Lucien Tesnière, 1959

The sentence is an organized whole, the constituent elements of which arewords. Every word that belongs to a sentence ceases by itself to beisolated as in the dictionary. Between the word and its neighbors, the mindpercieves connections, the totality of which forms the structure of thesentence. The structural connections establish dependency relationsbetween the words.

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 2 / 28

Page 3: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Dependency Grammar

� Basic Assumption: Syntactic structure essentially consists of lexicalitems linked by binary asymmetrical relations called dependencies.

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 3 / 28

Page 4: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Example of dependency parser output

Figure: Output of Stanford dependency parser

� Verb has an artificial root

� Notion of phrases: “by” and its children

� So how do we choose these edges?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 4 / 28

Page 5: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Example of dependency parser output

Figure: Output of Stanford dependency parser

� Verb has an artificial root

� Notion of phrases: “by” and its children

� So how do we choose these edges?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 4 / 28

Page 6: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Criteria for dependency

D is likely a dependent of head H in construction C:

� H determines syntactic category of C and can often replace C

� H gives semantic specification of C; D specifies H

� H is obligatory; D may be optional

� H selectes D and determines whether D is obligatory

� The form of D depends on H (agreement or government)

� The linear position of D is specified with reference to H

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 5 / 28

Page 7: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some clear cases . . .

� Modifiers: “nmod” and “vmod”

� Verb slots: “subject” and “object”

ROOT Economic news suddenly affected financial markets

W

root

W

nmod

W

subj

W

vmod

W

obj

W

nmod

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 6 / 28

Page 8: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 9: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 10: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 11: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 12: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 13: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W W W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 14: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W W W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 15: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W W WW W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 16: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W W WW W W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 17: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Which direction?

Some tricky cases . . .

� Complex verb groups

� Subordinate clauses

� Coordination

� Prepositions

� Punctuation

I can see that they rely on this and that.

W W WW W W WW W W

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 7 / 28

Page 18: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Dependency Parsing

� Input: Sentence x =w0,w1, ...,wn

� Output: Dependency graph G = (V ,A) for x where:� V = 0,1, ...,n is the vertex set,� A is the arc set, i.e., (i , j ,k) ∈ A represents a dependency from wi to wj with

label lk ∈ L� Notational Conventions� i→ j ≡ ∃k : (i , j ,k) ∈ A (unlabeled dependency)� i↔ j ≡ i→∨j→ i (undirected dependency)� i→∗j ≡ i = j ∨∃i ′ : i→ i ′, i ′→∗j (unlabeled closure)� i↔∗j ≡ i ∨∃i ′ : i↔ i ′,′ i↔∗j (undirected closure)

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 8 / 28

Page 19: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Conditions

� Intuitions� Syntactic structure is complete (Connectedness)� Syntactic structure is hierarchical (Acyclic)� Every word has at most one syntactic head (Single-Head)

� Connectedness is enforced by adding special root node

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 9 / 28

Page 20: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Conditions

� Connected: ∀i , j ∈ V , i↔∗j� Acyclic: If i→ j , then not j→∗i� Single-head: If i→ j , then not i ′→ j∀i ′ 6= i

� Projective: If i→ j , then i→∗i ′ for any i ′ such that i < i ′ < j or j < i ′ < i .

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 10 / 28

Page 21: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Motivation

Projectivity

� Equivalent to planar embedding

� Most theoretical frameworks do not assume projectivity

� Non-projective structures needed for free word order and long-distancedependencies

Non-projective example

� The algorithm later we’ll discuss is projective

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 11 / 28

Page 22: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

� Many algorithms exist (good overview inKübler et al)

� We will focus on a arc-factored projectivemodel� arc-factored: Score factorizes over edges� projective: no crossing lines (planar

embedding)

� This is a common, but not universalassumption

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 12 / 28

Page 23: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

How good is a given tree?

1. score(G) = score(V ,A) ∈R2. Arc-factored assumption:

score(G) =∑

(wi ,r ,wj)∈A

ψwi ,r ,wj(1)

3. Further simplification for class:

score(G) =∑

(wi ,wj)∈A

ψwi ,wj(2)

4. You can think about this probabilistically when

ψwi ,wj≡ log

p((wi ,wj) ∈ A)�

(3)

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 13 / 28

Page 24: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Dynamic Programming

� A parser should avoid re-analyzing sub-strings because the analysis ofa substring is independent of the rest of the parse.

� The parsers exploration of its search space can exploit thisindependence: dynamic programming (CS) / chart parsing (ling)

� Once solutions to sub-problems have been accumulated, solve theoverall problem by composing them

� Sub-trees are stored in a chart, which records all substructures:� re-parsing: sub-trees are looked up, not reparsed� ambiguity: chart implicitly stores all parses

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 14 / 28

Page 25: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� Like Viterbi algorithm, we’ll solve sub problems to find the overalloptimum

� Our overall goal is to find the best parse for the entire sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 15 / 28

Page 26: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� Like Viterbi algorithm, we’ll solve sub problems to find the overalloptimum

� Our overall goal is to find the best parse for the entire sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 15 / 28

Page 27: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� Like Viterbi algorithm, we’ll solve sub problems to find the overalloptimum

� Our overall goal is to find the best parse for the entire sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 15 / 28

Page 28: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� Like Viterbi algorithm, we’ll solve sub problems to find the overalloptimum

� Our overall goal is to find the best parse for the entire sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 15 / 28

Page 29: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� Like Viterbi algorithm, we’ll solve sub problems to find the overalloptimum

� Our overall goal is to find the best parse for the entire sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 15 / 28

Page 30: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� Like Viterbi algorithm, we’ll solve sub problems to find the overalloptimum

� Our overall goal is to find the best parse for the entire sentence

LEFT RIGHT

COMPLETE

INCOMPLETE

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 15 / 28

Page 31: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Central Idea: Spans

� To do this, we’ll find the best parse for contiguous spans of thesentence, characterized by� start 0 . . .n� stop 0 . . .n� direction←,→� completeness ◦, ·

� Each span gets an entry in a 4D chart (same as 2D chart for POStagging)

� Find the overall tree that gives highest score

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 16 / 28

Page 32: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Right Complete Spans

� We write the total score of thesespans C[s][t][→][·]

� “Root” of this subtree is at word s

� Can have arbitrary substructureuntil word t , but cannot takeadditional right children

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 17 / 28

Page 33: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Left Complete Spans

� We write the total score of thesespans C[s][t][←][·]

� “Root” of this subtree is at word t

� Can have arbitrary substructureuntil word s, but cannot takeadditional left children

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 18 / 28

Page 34: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Right Incomplete Spans

� We write the total score of thesespans C[s][t][→][◦]

� “Root” of this subtree is at word s

� Can have arbitrary substructureuntil word t , but can takeadditional right children

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 19 / 28

Page 35: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Right Incomplete Spans

� We write the total score of thesespans C[s][t][→][◦]

� “Root” of this subtree is at word s

� Can have arbitrary substructureuntil word t , but can takeadditional right children

Can accept additional right

children

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 19 / 28

Page 36: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Left Incomplete Spans

� We write the total score of thesespans C[s][t][←][◦]

� “Root” of this subtree is at word t

� Can have arbitrary substructureuntil word s, but can takeadditional left children

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 20 / 28

Page 37: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Left Incomplete Spans

Can accept additional left

children

� We write the total score of thesespans C[s][t][←][◦]

� “Root” of this subtree is at word t

� Can have arbitrary substructureuntil word s, but can takeadditional left children

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 20 / 28

Page 38: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Dynamic Programming Intuition

C[0][L][→][·] contains the best score for the overall tree.

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 21 / 28

Page 39: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Dynamic Programming Intuition

C[0][L][→][·] contains the best score for the overall tree.

Where's the main verb?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 21 / 28

Page 40: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Dynamic Programming Intuition

C[0][L][→][·] contains the best score for the overall tree.

Where's the main verb?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 21 / 28

Page 41: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Dynamic Programming Intuition

C[0][L][→][·] contains the best score for the overall tree.

Where's the main verb?

What are the right children of the root?

What are the left children of the main verb?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 21 / 28

Page 42: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Dynamic Programming Intuition

C[0][L][→][·] contains the best score for the overall tree.

Where's the main verb?

What are the right children of the verb?

What are the right children of the root?

What are the left children of the main verb?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 21 / 28

Page 43: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Building Incomplete Spans

Left incomplete spans are built by joining left complete to right complete

C[s][t][←][◦] = maxs≤q<t

C[s][q][→][·]+C[q+1][t][←][·]+λ(wt ,ws) (4)

?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 22 / 28

Page 44: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Building Incomplete Spans

Right incomplete spans are built by joining right complete to left complete

C[s][t][→][◦] = max s≤q<tC[s][q][→][·]+C[q+1][t][←][·]+λ(ws ,wt) (4)

?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 22 / 28

Page 45: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Building Incomplete Spans

Right incomplete spans are built by joining right complete to left complete

C[s][t][→][◦] = max s≤q<tC[s][q][→][·]+C[q+1][t][←][·]+λ(ws ,wt) (4)

?Dynamic Programming

When we compute the score for any span, we consider all possible waysthat the span could have been built.

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 22 / 28

Page 46: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Building Incomplete Spans

Right incomplete spans are built by joining right complete to left complete

C[s][t][→][◦] = max s≤q<tC[s][q][→][·]+C[q+1][t][←][·]+λ(ws ,wt) (4)

?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 22 / 28

Page 47: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Completing Spans

Right complete spans are built by taking an incomplete right span and then“completing” it with a right complete spanC[s][t][→][·] =maxs<q≤t C[s][q][→][◦]+C[q][t][→][·]

?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 23 / 28

Page 48: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Completing Spans

Left complete spans are built by taking an incomplete left span and then“completing” it with a left complete spanC[s][t][←][·] =maxs≤q<t C[s][q][←][·]+C[q][t][←][◦]

?

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 23 / 28

Page 49: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 50: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 51: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 52: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 53: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 54: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 55: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 56: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Example Sentence

Final step

Look at cell at corresponding to 0 to the length of the sentence, complete,and directed to the right. That is the best parse.

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 24 / 28

Page 57: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

What’s left: Breadcrumbs and Complexity

� As you build the chart, you must keep track of what the best subtreeswere to construct each cell; call this b

� Then look at b[0][L][→][·], and recursively build the tree� Complexity is O(n3):� Table is size O(n2)� Each cell requires at most n possible subtrees

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 25 / 28

Page 58: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Extensions to Dependency Parsing

� Horizontal and vertical Markovization (node depends on siblings andgrandparents in tree—logical!)� “saw with telescope” more likely than “bridge with telescope” (grandparent)� “fast sports car” more likely than “fast slow car” (sibling)

� Graph algorithms: allow non-projectivity� Sequential processing (next!)

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 26 / 28

Page 59: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Algorithms for Dependency Parsing

Extensions to Dependency Parsing

� Horizontal and vertical Markovization (node depends on siblings andgrandparents in tree—logical!)� “saw with telescope” more likely than “bridge with telescope” (grandparent)� “fast sports car” more likely than “fast slow car” (sibling)

� Graph algorithms: allow non-projectivity� Sequential processing (next!)

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 26 / 28

Page 60: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Evaluation and Estimation

Where does the attachment score come from?

� Language model: vertical rather than horizontal� How likely is the noun “bagel” the child of the “verb” eat?� Back off to noun being the child of the verb “eat” . . .� Back off to a noun being the child of a verb

� Discriminative models: minimize errors

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 27 / 28

Page 61: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Evaluation and Estimation

Where does the attachment score come from?

� Language model: vertical rather than horizontal� How likely is the noun “bagel” the child of the “verb” eat?� Back off to noun being the child of the verb “eat” . . .� Back off to a noun being the child of a verb

� Discriminative models: minimize errors

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 27 / 28

Page 62: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Evaluation and Estimation

Evaluation Methodology

� How many sentences are exactly correct

� Edge accuracy1. Labeled attachment score (LAS):

i.e. Tokens with correct head and label2. Unlabeled attachment score (UAS):

i.e. Tokens with correct head3. Label accuracy (LA):

i.e. Tokens with correct label

� Performance on downstream task (e.g., information extraction)

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 28 / 28

Page 63: Dependency Parsing - UMIACSusers.umiacs.umd.edu/~jbg/teaching/CMSC_723/14a_dependency.pdf · Algorithms for Dependency Parsing Dynamic Programming — A parser should avoid re-analyzing

Evaluation and Estimation

Evaluation Methodology

� How many sentences are exactly correct� Edge accuracy

1. Labeled attachment score (LAS):i.e. Tokens with correct head and label

2. Unlabeled attachment score (UAS):i.e. Tokens with correct head

3. Label accuracy (LA):i.e. Tokens with correct label

� Performance on downstream task (e.g., information extraction)

Computational Linguistics: Jordan Boyd-Graber | UMD Dependency Parsing | 28 / 28