CPSC 503 Computational Linguistics

Slides:



Advertisements
Similar presentations
Probabilistic and Lexicalized Parsing CS Probabilistic CFGs: PCFGs Weighted CFGs –Attach weights to rules of CFG –Compute weights of derivations.
Advertisements

Chapter 12 Lexicalized and Probabilistic Parsing Guoqiang Shan University of Arizona November 30, 2006.
10. Lexicalized and Probabilistic Parsing -Speech and Language Processing- 발표자 : 정영임 발표일 :
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing Probabilistic Context Free Grammars (Chapter 14) Muhammed Al-Mulhem March 1,
For Monday Read Chapter 23, sections 3-4 Homework –Chapter 23, exercises 1, 6, 14, 19 –Do them in order. Do NOT read ahead.
PCFG Parsing, Evaluation, & Improvements Ling 571 Deep Processing Techniques for NLP January 24, 2011.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
6/9/2015CPSC503 Winter CPSC 503 Computational Linguistics Lecture 11 Giuseppe Carenini.
Parsing with PCFG Ling 571 Fei Xia Week 3: 10/11-10/13/05.
Basic Parsing with Context- Free Grammars 1 Some slides adapted from Julia Hirschberg and Dan Jurafsky.
1 Basic Parsing with Context- Free Grammars Slides adapted from Dan Jurafsky and Julia Hirschberg.
BİL711 Natural Language Processing1 Statistical Parse Disambiguation Problem: –How do we disambiguate among a set of parses of a given sentence? –We want.
Probabilistic Parsing Reading: Chap 14, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
1 Statistical Parsing Chapter 14 October 2012 Lecture #9.
December 2004CSA3050: PCFGs1 CSA305: Natural Language Algorithms Probabilistic Phrase Structure Grammars (PCFGs)
10/12/2015CPSC503 Winter CPSC 503 Computational Linguistics Lecture 10 Giuseppe Carenini.
GRAMMARS David Kauchak CS159 – Fall 2014 some slides adapted from Ray Mooney.
Parsing I: Earley Parser CMSC Natural Language Processing May 1, 2003.
PARSING David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
11 Chapter 14 Part 1 Statistical Parsing Based on slides by Ray Mooney.
Page 1 Probabilistic Parsing and Treebanks L545 Spring 2000.
Lecture 1, 7/21/2005Natural Language Processing1 CS60057 Speech &Natural Language Processing Autumn 2007 Lecture August 2007.
Albert Gatt Corpora and Statistical Methods Lecture 11.
CSA2050 Introduction to Computational Linguistics Parsing I.
PARSING 2 David Kauchak CS159 – Spring 2011 some slides adapted from Ray Mooney.
CPSC 503 Computational Linguistics
Supertagging CMSC Natural Language Processing January 31, 2006.
CPSC 422, Lecture 28Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 28 Nov, 18, 2015.
CPSC 422, Lecture 27Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27 Nov, 16, 2015.
December 2011CSA3202: PCFGs1 CSA3202: Human Language Technology Probabilistic Phrase Structure Grammars (PCFGs)
PARSING David Kauchak CS159 – Fall Admin Assignment 3 Quiz #1  High: 36  Average: 33 (92%)  Median: 33.5 (93%)
Natural Language Processing : Probabilistic Context Free Grammars Updated 8/07.
Chapter 12: Probabilistic Parsing and Treebanks Heshaam Faili University of Tehran.
Roadmap Probabilistic CFGs –Handling ambiguity – more likely analyses –Adding probabilities Grammar Parsing: probabilistic CYK Learning probabilities:
Probabilistic and Lexicalized Parsing. Probabilistic CFGs Weighted CFGs –Attach weights to rules of CFG –Compute weights of derivations –Use weights to.
Natural Language Processing Vasile Rus
CSC 594 Topics in AI – Natural Language Processing
Parsing Recommended Reading: Ch th Jurafsky & Martin 2nd edition
CSC 594 Topics in AI – Natural Language Processing
CS60057 Speech &Natural Language Processing
Basic Parsing with Context Free Grammars Chapter 13
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 28
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
Probabilistic and Lexicalized Parsing
CSCI 5832 Natural Language Processing
CPSC 503 Computational Linguistics
CS 388: Natural Language Processing: Syntactic Parsing
CPSC 503 Computational Linguistics
CSCI 5832 Natural Language Processing
Probabilistic and Lexicalized Parsing
CSCI 5832 Natural Language Processing
Natural Language - General
CS4705 Natural Language Processing
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 27
Parsing and More Parsing
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 26
CPSC 503 Computational Linguistics
CS4705 Natural Language Processing
CPSC 503 Computational Linguistics
CPSC 503 Computational Linguistics
CPSC 503 Computational Linguistics
CPSC 503 Computational Linguistics
David Kauchak CS159 – Spring 2019
CPSC 503 Computational Linguistics
CPSC 503 Computational Linguistics
CPSC 503 Computational Linguistics
David Kauchak CS159 – Spring 2019
CPSC 503 Computational Linguistics
Presentation transcript:

CPSC 503 Computational Linguistics Lecture 9 Giuseppe Carenini 4/13/2019 CPSC503 Winter 2007

Knowledge-Formalisms Map State Machines (and prob. versions) (Finite State Automata,Finite State Transducers, Markov Models) Morphology Syntax Rule systems (and prob. versions) (e.g., (Prob.) Context-Free Grammars) Semantics Last time Big transition state machines (Regular languages)  CFGgrammars (CF languages) Parsing two approaches TD vs. BU (combine them with left corners) Still inefficient for 3 reasons Pragmatics Discourse and Dialogue Logical formalisms (First-Order Logics) AI planners 4/13/2019 CPSC503 Winter 2007

Today 9/10 Probabilistic CFGs: assigning prob. to parse trees and to sentences parse with prob. acquiring prob. Probabilistic Lexicalized CFGs 4/13/2019 CPSC503 Winter 2007

Ambiguity only partially solved by Earley parser “the man saw the girl with the telescope” I saw the planet with the telescope... The man has the telescope The girl has the telescope 4/13/2019 CPSC503 Winter 2007

Probabilistic CFGs (PCFGs) Each grammar rule is augmented with a conditional probability The expansions for a given non-terminal sum to 1 VP -> Verb .55 VP -> Verb NP .40 VP -> Verb NP NP .05 P(A->beta|A) D is a function assigning probabilities to each production/rule in P Formal Def: 5-tuple (N, , P, S,D) 4/13/2019 CPSC503 Winter 2007

Sample PCFG 4/13/2019 CPSC503 Winter 2007

PCFGs are used to…. Estimate Prob. of parse tree Estimate Prob. to sentences The probability of a derivation (tree) is just the product of the probabilities of the rules in the derivation. Product because rule applications are independent (because CFG) integrate them with n-grams The probability of a word sequence (sentence) is the probability of its tree in the unambiguous case. It’s the sum of the probabilities of the trees in the ambiguous case. 4/13/2019 CPSC503 Winter 2007

Example 4/13/2019 CPSC503 Winter 2007

Probabilistic Parsing: Slight modification to dynamic programming approach (Restricted) Task is to find the max probability tree for an input We will look at a solution to a restricted version of the general problem of finding all possible parses of a sentence and their corresponding probabilities 4/13/2019 CPSC503 Winter 2007

Probabilistic CYK Algorithm Ney, 1991 Collins, 1999 CYK (Cocke-Younger-Kasami) algorithm A bottom-up parser using dynamic programming Assume the PCFG is in Chomsky normal form (CNF) Definitions w1… wn an input string composed of n words wij a string of words from word i to word j µ[i, j, A] : a table entry holds the maximum probability for a constituent with non-terminal A spanning words wi…wj A First described by Ney, but the version we are seeing here is adapted from Collins 4/13/2019 CPSC503 Winter 2007

CYK: Base Case Fill out the table entries by induction: Base case Consider the input strings of length one (i.e., each individual word wi) P(A  wi) Since the grammar is in CNF: A * wi iff A  wi So µ[i, i, A] = P(A  wi) “Can1 you2 book3 TWA4 flight5 ?” Aux 1 .4 Noun 5 .5 …… 4/13/2019 CPSC503 Winter 2007

CYK: Recursive Case A C B Recursive case For strings of words of length > 1, A * wij iff there is at least one rule A  BC where B derives the first k words and C derives the last j-k words A C B i i-1+k i+k j µ[i, j, A)] = µ [i, i-1 +k, B] * µ [i+k, j,C] * P(A  BC) Choose the max among all possibilities Compute the probability by multiplying together the probabilities of these two pieces (note that they have been calculated in the recursion) 2<= k <= j – i - 1 4/13/2019 CPSC503 Winter 2007

CYK: Termination S The max prob parse will be µ [1, n, S] 5 1.7x10-6 “Can1 you2 book3 TWA4 flight5 ?” Any other filler for this matrix? 1,3 and 1,4 and 3,5 ! 4/13/2019 CPSC503 Winter 2007

Acquiring Grammars and Probabilities Manually parsed text corpora (e.g., PennTreebank) Grammar: read it off the parse trees Ex: if an NP contains an ART, ADJ, and NOUN then we create the rule NP -> ART ADJ NOUN. Probabilities: We can create a PCFG automatically by exploiting manually parsed text corpora, such as the Penn Treebank. We can read off them grammar found in the treebank. Probabilities: can be assigned by counting how often each item is found in the treebank Ex: if the NP -> ART ADJ NOUN rule is used 50 times and all NP rules are used 5000 times, then the rule’s probability is 50/5000 = .01 Ex: if the NP -> ART ADJ NOUN rule is used 50 times and all NP rules are used 5000 times, then the rule’s probability is 50/5000 = .01 4/13/2019 CPSC503 Winter 2007

“Limitations” of treebank grammars Only about 50,000 hand-parsed sentences. But in practice, rules that are not in the treebank are relatively rare. Missing rule often replaced by similar ones that reduce accuracy only slightly Treebank grammars were not expected to work well because they would have no grammar rules for syntactic constructions that didn’t appear in the training corpus. (The Penn Treebank has only about 50,000 hand-parsed sentences.) But in practice, rules that are not in the treebank are relatively rare. So missing them doesn’t affect parsing very often. When the grammar is missing a rule, often there are similar rules in the grammar that can produce parses that are only off by a little. In short, treebank grammars give you the most common grammar rules that will occur in new sentences. Missing the others doesn’t affect the scoring results very much! 4/13/2019 CPSC503 Winter 2007

Non-supervised PCFG Learning Take a large collection of text and parse it If sentences were unambiguous: count rules in each parse and then normalize But most sentences are ambiguous: weight each partial count by the prob. of the parse tree it appears in (?!) What if you don’t have a treebank (and can’t get one) 4/13/2019 CPSC503 Winter 2007

Non-supervised PCFG Learning Start with equal rule probs and keep revising them iteratively Parse the sentences Compute probs of each parse Use probs to weight the counts Reestimate the rule probs What if you don’t have a treebank (and can’t get one) Inside-Outside algorithm (generalization of forward-backward algorithm) 4/13/2019 CPSC503 Winter 2007

Problems with PCFGs Most current PCFG models are not vanilla PCFGs Usually augmented in some way Vanilla PCFGs assume independence of non-terminal expansions But statistical analysis shows this is not a valid assumption Structural and lexical dependencies Probabilities for NP expansions do not depend on context. 4/13/2019 CPSC503 Winter 2007

Structural Dependencies: Problem E.g. Syntactic subject of a sentence tends to be a pronoun Subject tends to realize the topic of a sentence Topic is usually old information Pronouns are usually used to refer to old information So subject tends to be a pronoun In Switchboard corpus: I do not get good estimates for the pro Parent annotation technique 91% of subjects in declarative sentences are pronouns 66% of direct objects are lexical (nonpronominal) (i.e., only 34% are pronouns) 4/13/2019 CPSC503 Winter 2007

Structural Dependencies: Solution Split non-terminal. E.g., NPsubject and NPobject Parent Annotation: Hand-write rules for more complex struct. dependencies I do not get good estimates for the pro Parent annotation technique Automatic/Optimal split – Split and Merge algorithm [Petrov et al. 2006- COLING/ACL] 4/13/2019 CPSC503 Winter 2007

Lexical Dependencies: Problem Two parse trees for the sentence “Moscow sent troops into Afghanistan” The verb send subcategorises for a destination, which could be a PP headed by “into” VP-attachment NP-attachment Typically NP-attachment more frequent than VP-attachment 4/13/2019 CPSC503 Winter 2007

Lexical Dependencies: Solution Add lexical dependencies to the scheme… Infiltrate the influence of particular words into the probabilities in the derivation I.e. Condition on the actual words in the right way No only the key ones All the words? P(VP -> V NP PP | VP = “sent troops into Afg.”) P(VP -> V NP | VP = “sent troops into Afg.”) 4/13/2019 CPSC503 Winter 2007

Heads To do that we’re going to make use of the notion of the head of a phrase The head of an NP is its noun The head of a VP is its verb The head of a PP is its preposition (but for other phrases can be more complicated and somewhat controversial) Should the complementizer TO or the verb be the head of an infinite VP? Most linguistic theories of syntax of syntax generally include a component that defines heads. 4/13/2019 CPSC503 Winter 2007

More specific rules We used to have Now we have Sample sentence: VP -> V NP PP P(r|VP) That’s the count of this rule divided by the number of VPs in a treebank Now we have VP(h(VP))-> V(h(VP)) NP(h(NP)) PP(h(PP)) P(r|VP, h(VP), h(NP), h(PP)) Sample sentence: “Workers dumped sacks into the bin” Also associate the head tag e.g., NP(sacks,NNS) where NNS is noun, plural VP(dumped)-> V(dumped) NP(sacks) PP(into) P(r|VP, dumped is the verb, sacks is the head of the NP, into is the head of the PP) 4/13/2019 CPSC503 Winter 2007

Example (right) (Collins 1999) Attribute grammar 4/13/2019 Each non-terminal is annotated with a single word which is its lexical head A CFG with a lot more rules! 4/13/2019 CPSC503 Winter 2007

Example (wrong) 4/13/2019 CPSC503 Winter 2007

Problem with more specific rules VP(dumped)-> V(dumped) NP(sacks) PP(into) P(r|VP, dumped is the verb, sacks is the head of the NP, into is the head of the PP) Not likely to have significant counts in any treebank! 4/13/2019 CPSC503 Winter 2007

Usual trick: Assume Independence When stuck, exploit independence and collect the statistics you can… We’ll focus on capturing two aspects: Verb subcategorization Particular verbs have affinities for particular VPs Objects affinities for their predicates (mostly their mothers and grandmothers) Some objects fit better with some predicates than others 4/13/2019 CPSC503 Winter 2007

Subcategorization Condition particular VP rules only on their head… so r: VP -> V NP PP P(r|VP, h(VP), h(NP), h(PP)) Becomes P(r | VP, h(VP)) x …… e.g., P(r | VP, dumped) What’s the count? How many times was this rule used with dump, divided by the number of VPs that dump appears in total First step 4/13/2019 CPSC503 Winter 2007

Objects affinities for their Predicates r: VP -> V NP PP ; P(r|VP, h(VP), h(NP), h(PP)) Becomes P(r | VP, h(VP)) x P(h(NP) | NP, h(VP))) x P(h(PP) | PP, h(VP))) E.g. P(r | VP,dumped) x P(sacks | NP, dumped)) x P(into | PP, dumped)) Normalize = divide by the count of the places where dumped is the head of a constituent that has a PP daughter count the places where dumped is the head of a constituent that has a PP daughter with into as its head and normalize 4/13/2019 CPSC503 Winter 2007

Example (right) P(VP -> V NP PP | VP, dumped) =.67 P(into | PP, dumped)=.22 The issue here is the attachment of the PP. So the affinities we care about are the ones between: dumped and into vs. sacks and into. So count the places where dumped is the head of a constituent that has a PP daughter with into as its head and normalize Vs. the situation where sacks is a constituent with into as the head of a PP daughter 4/13/2019 CPSC503 Winter 2007

Example (wrong) P(VP -> V NP | VP, dumped)=0 P(into | PP, sacks)=? 4/13/2019 CPSC503 Winter 2007

Knowledge-Formalisms Map (including probabilistic formalisms) State Machines (and prob. versions) (Finite State Automata,Finite State Transducers, Markov Models) Morphology Syntax Rule systems (and prob. versions) (e.g., (Prob.) Context-Free Grammars) Semantics 10.5 parsing with cascades of finite state automata noun groups: a noun and the modifiers to the left Pragmatics Discourse and Dialogue Logical formalisms (First-Order Logics) AI planners 4/13/2019 CPSC503 Winter 2007

Next Time (**Tue –Oct 16**) You have to start thinking about the project. Assuming you know First Order Lgics (FOL) Read Chp. 17 (17.5 – 17.6) Read Chp. 18.1-2-3 and 18.5 4/13/2019 CPSC503 Winter 2007

Ambiguity only partially solved by Earley parser “Can you book TWA flights ?” VP -> V NP ; NP -> NP PP VP -> V NP PP 4/13/2019 CPSC503 Winter 2007