Probabilistic Constituency Parsing #
A grammar can give one sentence several valid trees. A probabilistic context-free grammar (PCFG) scores candidate trees so the parser can rank them. In “I saw the guide with binoculars”, the prepositional phrase can attach to the verb phrase or to the noun phrase. The preferred attachment changes who had the binoculars.
1. Scoring a tree with a PCFG ☆ #
For each non-terminal, the probabilities of all rules that expand it sum to 1. A tree gets the product of the probabilities of every rule occurrence used in its derivation. If a sentence has several parses, its total probability under the grammar is the sum of their probabilities.
From a treebank, count how often a rule occurs and divide by the total number of expansions of its left-hand side.
\[ P(A\to\beta)=\frac{\operatorname{count}(A\to\beta)} {\sum_{\gamma}\operatorname{count}(A\to\gamma)} \]If 80 of 100 noun-phrase expansions use NP → Det N, its maximum-likelihood estimate is 0.8.
2. CKY and Chomsky normal form ☆ #
Standard CKY builds larger constituents from smaller spans. It uses a grammar in Chomsky normal form (CNF), where rules for non-empty inputs have the form A → B C or A → word. Preparing a grammar can involve replacing terminals in longer rules with preterminals, binarising long rules, and handling unit and empty productions. For a PCFG, the transformation must preserve the derivation scores the parser needs.
The chart starts with lexical categories for individual words. For each longer span, try each split, combine the left and right cells using compatible binary rules, and keep the best score and backpointer for each category.
\[ V[A,i,j]=\max_{iHere the span starts at boundary \( i \) and ends just before boundary \( j \) . The start symbol in the full-span cell identifies a complete parse. Follow the backpointers to rebuild the best tree. Replacing the maximum with a sum yields the inside probability across parses. The basic CKY loops over spans and split points, giving cubic time in sentence length for a fixed grammar.
Worked chart #
Use the following rules. The final alternative keeps the NP probabilities normalised.
| Rule | Probability |
|---|---|
S → NP VP | 1.0 |
NP → Det N | 0.8 |
NP → guides | 0.2 |
VP → wait | 1.0 |
Det → the | 1.0 |
N → guides | 1.0 |
For “the guides wait”, place Det, N and VP in the one-word cells. The chart also stores NP with score 0.2 for guides. Combining the and guides yields NP with score 0.8. Combining that span with wait gives a full-span S with score 0.8.
3. Improving and evaluating a PCFG #
Basic PCFGs expand a category the same way wherever it occurs. Parent annotation can distinguish a subject NP under an S from an object NP under a VP. Lexicalisation attaches a head word to a phrase, so the model can learn that a verb such as saw often takes an instrument phrase like with binoculars.
Compare predicted constituents with a reference tree using their start, end and category. Labelled precision measures how many predicted constituents match. Labelled recall measures how many reference constituents were recovered. F1 combines the two.