Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

27
Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Transcript of Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Page 1: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Lexicalized and Probabilistic Parsing

Read J & M Chapter 12.

Page 2: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Using Probabilities

•Resolving ambiguities:

I saw the Statue of Liberty flying over New York.

•Predicting for recognition:

I have to go. vs. I half to go.

vs.

I half way thought I’d go.

Page 3: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

It’s Mostly About Semantics

He drew one card.

I saw the Statue of Liberty flying over New York.

I saw a plane flying over New York.

Workers dumped sacks into a bin.

Moscow sent more than 100,000 soldiers into Afghanistan.

John hit the ball with the bat.

John hit the ball with the autograph.

Visiting relatives can be trying.

Visiting museums can be trying.

Page 4: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

How to Add Semantics to Parsing?

The classic approach to this problem:

Ask a semantics module to choose. Two ways to do that:

•Cascade the two systems. Build all the parses, then pass them to semantics to rate them. Combinatorially awful.

•Do semantics incrementally. Pass constituents, get ratings and filter.

In either case, we need to reason about the world.

Page 5: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

The “Modern” Approach

The modern approach:

Skip “meaning” and the corresponding need for a knowledge base and an inference engine.

Notice that the facts about meaning manifest themselves in probabilities of observed sentences if there are enough sentences.

Why is this approach in vogue?

•Building world models is a lot harder than early researchers realized.

•But, we do have huge text corpora from which we can draw statistics.

Page 6: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Probabilistic Context-Free Grammars

A PCFG is a context-free grammar in which each rule has been augmented with a probability:

A [p] is the probability that a given nonterminalsymbol A will be rewritten as via thisrule.

Another way to think of this is:

P(A |A)

So the sum of all the probabilities of rules with left hand side A must be 1.

Page 7: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

A Toy Example

Page 8: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

How Can We Use These?

In a top-down parser, we can follow the more likely path first.

In a bottom-up parser, we can build all the constituents and then compare them.

Page 9: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

The Probability of Some Parse T

P(T) = ))((Tn

nrp where p(r(n)) means the probability that rule r will apply to expand the nonterminal n.

Note the independence assumption.

)(maxarg)(ˆ)(

TPSTST

So what we want is:

where (S) is the set of possible parses for S.

Page 10: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

An Example

Can you book TWA flights?

Page 11: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

An Example – The Probabilities

= 1.5 10-6 = 1.7 10-6

Note how small the probabilities are, even with this tiny grammar.

Page 12: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Using Probabilities for Language Modeling

Since there are fewer grammar rules than there are word sequences, it can be useful, in language modeling, to use grammar probabilities instead of flat n-gram frequencies. So the probability of some sentence S is the sum of the probabilities of its possible parses:

)(

)()(ST

TPSP

Contrast with:

)...|()|()|()()( 3214213121 wwwwPwwwPwwPwPSP

Page 13: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Adding Probabilities to a Parser

•Adding probabilities to a top-down parser, e.g., Earley:

This is easy since we’re going top-down, we can choose which rule to prefer.

•Adding probabilities to a bottom-up parser:

At each step, build the pieces, then add probabilities to them.

Page 14: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Limitations to Attaching Probabilities Just to Rules

Sometimes it’s enough to know that one rule applies more often than another:

Can you book TWA flights?

But often it matters what the context is. Consider:S NP VPNP Pronoun[.8]NP LexNP [.2]

But, when the NP is the subject, the true probability of a pronoun is .91. When the NP is the direct object, the true probability of a pronoun is .34.

Page 15: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Often the Probabilities Depend on Lexical Choices

I saw the Statue of Liberty flying over New York.

I saw a plane flying over New York.

Workers dumped sacks into a bin.

Workers dumped sacks of potatoes.

John hit the ball with the bat.

John hit the ball with the autograph.

Visiting relatives can be trying.

Visiting museums can be trying.

There were dogs in houses and cats.

There were dogs in houses and cages.

Page 16: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

The Dogs in Houses Example

The problem is that both parses used the same rules so they will get the same probabilities assigned to them.

Page 17: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

The Fix – Use the Lexicon

The lexicon is an approximation to a knowledge base. It will let us treat into and of differently with respect to dumping without any clue what dumping means or what into and of mean.

Note the difference between this approach and subcategorization rules, e.g.,

dump [SUBCAT NP][SUBCAT LOCATION]

Subcategorization rules specify requirements, not preferences.

Page 18: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Lexicalized Trees

Key idea: Each constituent has a HEAD word:

Page 19: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Adding Lexical Items to the Rules

VP(dumped) VBD (dumped) NP (sacks) PP (into) 3 10-10

VP(dumped) VBD (dumped) NP (cats) PP (into) 8 10-10

VP(dumped) VBD (dumped) NP (hats) PP (into) 4 10-10

VP(dumped) VBD (dumped) NP (sacks) PP (above) 1 10-12

We need fewer numbers than we would for N-gram frequencies:The workers dumped sacks of potatoes into a bin.The workers dumped sacks of onions into a bin.The workers dumped all the sacks of potatoes into a bin.

But there are still too many and most will be 0 in any given corpus.

Page 20: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Collapsing These Cases

Instead of caring about specific rules like:

VP(dumped) VBD (dumped) NP (sacks) PP (into) 3 10-10

Or about very general rules like:

VP VBD NP PP

We’ll do something partway in between:

VP(dumped) VBD NP PP p(r(n) | n, h(n))

Page 21: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Computing Probabilities of Heads

We’ll let the probability of some node n having head h depend on two factors:

•the syntactic category of the node, and

•the head of the node’s mother (h(m(n)))

So we will compute:

P(h(n) = wordi | n, h(m(n)))

VP (dumped) VP (dumped) NP (sacks)

p = p1 p = p2 p = p3

PP (into) PP (of) PP (of)

So now we’ve got probabilistic subcat information.

Page 22: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Revised Rule for Probability of a Parse

Our initial rule:

P(T) = ))((Tn

nrp where p(r(n)) means the probability that rule r will apply to expand the nonterminal n.

Our new rule:

)))((,|)(())(,|)(( nmhnnhpnhnnrpTn

P(T) =

probability of choosing this rule given the nonterminal and its head

probability that this node has head h given the nonterminal and the head of its mother

Page 23: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

So We Can Solve the Dumped Sacks Problem

From the Brown corpus:

p(VP VBD NP PP | VP, dumped) = .67

p(VP VBD NP | VP, dumped) = 0

p(into | PP, dumped) = .22

p(into | PP, sacks) = 0

So, the contribution of this part of the parse to the total scores for the two candidates is:

[dumped into] .67 .22 = .147

[sacks into] 0 0 = 0

Page 24: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

It’s Mostly About Semantics But It’s Also About Psychology

What do people do?

People have limited memory for processing language.

So we should consider two aspects of language skill:

•competence (what could we in principle do?), and

•performance (what do we actually do, including mistakes?)

Page 25: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Garden Path Sentences

Are people deterministic parsers?

Consider garden path sentences such as:

•The horse raced past the barn fell.

•The complex houses married and single students and their families.

•I told the boy the dog bit Sue would help him.

Page 26: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Embedding Limitations

There are limits to the theoretical ability to apply recursion in grammar rules:

# The Republicans who the senator who she voted for chastised were trying to cut all benefits for veterans.

# Tom figured that that Susan wanted to take the cat out bothered Betsy out. (Church)

Harold heard [that John told the teacher that Bill said that Sam thought that Mike threw the first punch] yesterday. (Church)

Page 27: Lexicalized and Probabilistic Parsing Read J & M Chapter 12.

Building Deterministic Parsers

What if we impose performance constraints on our parsers? Will they work?

•Require that the parser be deterministic. At any point, it must simply choose the best parse given what has come so far and, perhaps, some limited number of lookahead constituents (Marcus allowed 3).

•Limit the amount of memory that the parser may use. This effectively makes the parser an FSM, in fact a deterministic FSM.