overview
play

Overview Last Time Context-Free Grammar Treebanks Probabilistic - PowerPoint PPT Presentation

University of Oslo : Department of Informatics INF4820: Algorithms for Artificial Intelligence and Natural Language Processing Generalized Chart Parsing Stephan Oepen & Erik Velldal Language Technology Group (LTG) November 4, 2015


  1. University of Oslo : Department of Informatics INF4820: Algorithms for Artificial Intelligence and Natural Language Processing Generalized Chart Parsing Stephan Oepen & Erik Velldal Language Technology Group (LTG) November 4, 2015

  2. Overview Last Time ◮ Context-Free Grammar ◮ Treebanks ◮ Probabilistic CFGs ◮ Syntactic Parsing ◮ Na¨ ıve: Recursive-Descent ◮ Dynamic Programming: CKY

  3. Overview Last Time ◮ Context-Free Grammar ◮ Treebanks ◮ Probabilistic CFGs ◮ Syntactic Parsing ◮ Na¨ ıve: Recursive-Descent ◮ Dynamic Programming: CKY Today ◮ Generalized Chart Parsing ◮ Inside the Parse Forest ◮ Viterbi Tree Decoding ◮ Parser Evaluation

  4. CFGs (Formally, this Time) Formally, a CFG is a quadruple: G = � C , Σ , P , S �

  5. CFGs (Formally, this Time) Formally, a CFG is a quadruple: G = � C , Σ , P , S � ◮ C is the set of categories (aka non-terminals ), ◮ { S , NP , VP , V }

  6. CFGs (Formally, this Time) Formally, a CFG is a quadruple: G = � C , Σ , P , S � ◮ C is the set of categories (aka non-terminals ), ◮ { S , NP , VP , V } ◮ Σ is the vocabulary (aka terminals ), ◮ { Kim , snow , adores , in }

  7. CFGs (Formally, this Time) Formally, a CFG is a quadruple: G = � C , Σ , P , S � ◮ C is the set of categories (aka non-terminals ), ◮ { S , NP , VP , V } ◮ Σ is the vocabulary (aka terminals ), ◮ { Kim , snow , adores , in } ◮ P is a set of category rewrite rules (aka productions ) S → NP VP NP → Kim VP → V NP NP → snow V → adores

  8. CFGs (Formally, this Time) Formally, a CFG is a quadruple: G = � C , Σ , P , S � ◮ C is the set of categories (aka non-terminals ), ◮ { S , NP , VP , V } ◮ Σ is the vocabulary (aka terminals ), ◮ { Kim , snow , adores , in } ◮ P is a set of category rewrite rules (aka productions ) S → NP VP NP → Kim VP → V NP NP → snow V → adores ◮ S ∈ C is the start symbol , a filter on complete results;

  9. CFGs (Formally, this Time) Formally, a CFG is a quadruple: G = � C , Σ , P , S � ◮ C is the set of categories (aka non-terminals ), ◮ { S , NP , VP , V } ◮ Σ is the vocabulary (aka terminals ), ◮ { Kim , snow , adores , in } ◮ P is a set of category rewrite rules (aka productions ) S → NP VP NP → Kim VP → V NP NP → snow V → adores ◮ S ∈ C is the start symbol , a filter on complete results; ◮ for each rule α → β 1 , β 2 , ..., β n ∈ P : α ∈ C and β i ∈ C ∪ Σ

  10. A Key Insight: Local Ambiguity • For many substrings, more than one way of deriving the same category; • NPs: 1 | 2 | 3 | 6 | 7 | 9 ; PPs: 4 | 5 | 8 ; 9 ≡ 1 + 8 | 6 + 5 ; • parse forest — a single item represents multiple trees [Billot & Lang, 89]. ✬ ✩ 9 8 6 7 4 5 1 2 3 boys with hats from France 2 3 4 5 6 7 ✫ ✪ inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (3)

  11. The CKY (Cocke, Kasami, & Younger) Algorithm for ( 0 ≤ i < | input | ) do chart [ i,i +1] ← { α | α → input i ∈ P } ; for ( 1 ≤ l < | input | ) do for ( 0 ≤ i < | input | − l ) do for ( 1 ≤ j ≤ l ) do if ( α → β 1 β 2 ∈ P ∧ β 1 ∈ chart [ i,i + j ] ∧ β 2 ∈ chart [ i + j,i + l +1] ) then chart [ i,i + l +1] ← chart [ i,i + l +1] ∪ { α } ; 1 2 3 4 5 0 NP S S ✎ ☞ 1 V VP VP Kim adored snow in Oslo ✍ ✌ 2 NP NP 3 P PP 4 NP inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (4)

  12. Limitations of the CKY Algorithm Built-In Assumptions • Chomsky Normal Form grammars: α → β 1 β 2 or α → γ ( β i ∈ C , γ ∈ Σ ); • breadth-first (aka exhaustive): always compute all values for each cell; • rigid control structure: bottom-up, left-to-right (one diagonal at a time). Generalized Chart Parsing • Liberate order of computation: no assumptions about earlier results; • active edges encode partial rule instantiations, ‘waiting’ for additional (adjacent and passive) constituents to complete: [ 1 , 2 , VP → V • NP ] ; • parser can fill in chart cells in any order and guarantee completeness. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (5)

  13. Limitations of the CKY Algorithm Built-In Assumptions • Chomsky Normal Form grammars: α → β 1 β 2 or α → γ ( β i ∈ C , γ ∈ Σ ); • breadth-first (aka exhaustive): always compute all values for each cell; • rigid control structure: bottom-up, left-to-right (one diagonal at a time). Generalized Chart Parsing • Liberate order of computation: no assumptions about earlier results; • active edges encode partial rule instantiations, ‘waiting’ for additional (adjacent and passive) constituents to complete: [ 1 , 2 , VP → V • NP ] ; • parser can fill in chart cells in any order and guarantee completeness. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (5)

  14. Chart Parsing — Specialized Dynamic Programming Basic Notions • Use chart to record partial analyses, indexing them by string positions; • count inter-word vertices; CKY: chart row is start , column end vertex; • treat multiple ways of deriving the same category for some substring as equivalent ; pursue only once when combining with other constituents. Key Benefits • Dynamic programming (memoization): avoid recomputation of results; • efficient indexing of constituents: no search by start or end positions; • compute parse forest with exponential ‘extension’ in polynomial time. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (6)

  15. Chart Parsing — Specialized Dynamic Programming Basic Notions • Use chart to record partial analyses, indexing them by string positions; • count inter-word vertices; CKY: chart row is start , column end vertex; • treat multiple ways of deriving the same category for some substring as equivalent ; pursue only once when combining with other constituents. Key Benefits • Dynamic programming (memoization): avoid recomputation of results; • efficient indexing of constituents: no search by start or end positions; • compute parse forest with exponential ‘extension’ in polynomial time. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (6)

  16. Chart Parsing: Key Ideas • The parse chart is a two-dimensional matrix of edges (aka chart items); • an edge is a (possibly partial) rule instantiation over a substring of input; • the chart indexes edges by start and end string position (aka vertices); • dot in rule RHS indicates degree of completion: α → β 1 . . . β i − 1 • β i . . . β n ; • active edges (aka incomplete items) — partial RHS: [ 1 , 2 , VP → V • NP ] ; • passive edges (aka complete items) — full RHS: [ 1 , 3 , VP → V NP • ] ; ✬ ✩ The Fundamental Rule [ i, j, α → β 1 ... β i − 1 • β i ... β n ] + [ j, k, β i → γ + • ] �→ [ i, k, α → β 1 ... β i • β i +1 ... β n ] ✫ ✪ inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (7)

  17. An Example of a (Near- and Over-)Complete Chart 1 2 3 4 5 NP → NP • PP S → NP • VP 0 S → NP VP • NP → kim • VP → VP • PP VP → V • NP VP → VP • PP VP → VP PP • 1 V → adores • VP → V NP • VP → V NP • NP → NP • PP NP → NP • PP 2 NP → snow • NP → NP PP • PP → P • NP PP → P NP • 3 P → in • NP → NP • PP 4 NP → oslo • ✗ ✔ 0 Kim 1 adores 2 snow 3 in 4 Oslo 5 ✖ ✕ inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (8)

  18. (Even) More Active (and Passive) Edges 0 1 2 3 S → NP • VP NP → NP • PP S → • NP VP NP → kim • NP → • NP PP 0 S → NP VP • NP → • kim kim VP → V • NP VP → • VP PP V → adores • VP → VP • PP VP → • V NP 1 adores VP → V NP • V → • adores NP → NP • PP NP → snow • NP → • NP PP 2 NP → • snow snow 3 • Include all grammar rules as epsilon edges in each chart [ i,i ] cell. • after initialization, apply fundamental rule until fixpoint is reached. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (9)

  19. Combinatorics: Keeping Track of Remaining Work The Abstract Goal • Any chart parsing algorithm needs to check all pairs of adjacent edges. A Na¨ ıve Strategy • Keep iterating through the complete chart, combining all possible pairs, until no additional edges can be derived (i.e. the fixpoint is reached); • frequent attempts to combine pairs multiple times: deriving ‘duplicates’. An Agenda-Driven Strategy • Combine each pair exactly once, viz. when both elements are available; • maintain agenda of new edges, yet to be checked against chart edges; • new edges go into agenda first, add to chart upon retrieval from agenda. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (10)

  20. Combinatorics: Keeping Track of Remaining Work The Abstract Goal • Any chart parsing algorithm needs to check all pairs of adjacent edges. A Na¨ ıve Strategy • Keep iterating through the complete chart, combining all possible pairs, until no additional edges can be derived (i.e. the fixpoint is reached); • frequent attempts to combine pairs multiple times: deriving ‘duplicates’. An Agenda-Driven Strategy • Combine each pair exactly once, viz. when both elements are available; • maintain agenda of new edges, yet to be checked against chart edges; • new edges go into agenda first, add to chart upon retrieval from agenda. inf4820 —  -nov-  ( oe@ifi.uio.no ) Generalized Chart Parsing (10)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend