Structured Prediction and Parsing Evaluation › The Structured Prediction Problem

Michael BrenndoerferNovember 17, 20269 min read
Language AI HandbookAll chapters
Part 7 of 67Linguistic Form: Morphology and Syntax
Chapter 49Structured Prediction and Parsing Evaluation › The Structured Prediction Problem
Reading section 2 of 14 · The Structured Prediction Problem · 9 minSection 2 of 14 · 9 min

Section 2 of 14 · 9 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

A structured predictor chooses a legal output yy for input xx, here a sentence of nn tokens. The legal set Y(x)\mathcal{Y}(x) may depend on the input. A maximum-score decoder selects a highest-scoring legal output.

y^=arg⁡max⁡y∈Y(x)s(x,y)\hat{y} = \arg\max_{y \in \mathcal{Y}(x)} s(x, y)

where:

  • xx: the input, a sentence of nn tokens
  • yy: a candidate output structure drawn from Y(x)\mathcal{Y}(x), the set of valid structures for xx
  • Y(x)\mathcal{Y}(x): the legal output set for xx, such as all well-formed dependency trees over the nn tokens
  • s(x,y)s(x, y): the model's scalar score for structure yy given input xx; higher is better
  • y^\hat{y}: the highest-scoring structure, the decoder's output

In ordinary multiclass classification, the candidate labels usually form a fixed finite list. In parsing, sentence length sets the token positions for candidate attachments and the boundaries available for candidate spans. Constituent counts can vary between legal trees for the same sentence, for example through a unary chain. Well-formedness restricts which combinations are legal. A structured task can also have the same legal output set for every input. A decoder must account for output dependencies when they affect which outputs are legal or how those outputs score. The argmax chooses the highest score, with a fixed tie-breaking convention when several structures share that score.

For dependency parsing, yy is a set of arcs (h,m,ℓ)(h, m, \ell) where hh is the head index, mm the modifier index, and ℓ\ell a labeled relation. For constituency parsing, we use half-open token boundaries: (i,j,A)(i,j,A) covers token indices i,…,j−1i,\ldots,j-1 with label AA. Dependency chart intervals below are inclusive; the separate conventions will be stated where they are used. In both cases the parts must form one well-formed tree. Arcs or spans can be legal on their own and still be incompatible in the same tree.

Why the Output Space Is the Hard Part

For n≥2n \ge 2, the number of rooted directed trees on nn fixed word positions is nn−1n^{n-1} when any word may be the root and arcs are directed from heads to dependents. Cayley's count gives nn−2n^{n-2} undirected labeled trees; choosing one of nn roots fixes the outward orientation. Here we count the n−1n-1 lexical arcs and omit an artificial-root edge. At n=1n=1 the count is one by convention. For 20 words the unrestricted count is 2019≈5.24×102420^{19} \approx 5.24 \times 10^{24}. If every lexical arc can independently take any of 40 labels, each unlabeled tree has 4019≈2.75×103040^{19} \approx 2.75 \times 10^{30} labeled versions, giving about 1.44×10551.44 \times 10^{55} possibilities. This deliberately unconstrained label count ignores relation-specific grammatical restrictions.

Even an imaginary decoder examining a billion complete labeled trees each second would need about 1.44×10461.44 \times 10^{46} seconds to enumerate that example's labeled output space. The point is the count, not a hardware benchmark: exhaustive enumeration already fails at a sentence length that appears in ordinary text. Restricting the allowed structures helps, but it does not turn enumeration into a practical general decoder.

Projectivity helps, but not enough. A projective tree is one where every subtree occupies a contiguous span, so no two arcs cross. The projective-tree recurrence below gives an asymptotic exponential growth constant of 27/4=6.7527/4 = 6.75, with a polynomial prefactor; this is much slower than the super-exponential count of unrestricted trees. The exponential factor alone is not a finite-length count. At n=20n = 20, the recurrence gives exactly 47,365,474,641,870 projective trees, approximately 4.7×10134.7 \times 10^{13}, a reduction of eleven orders of magnitude that still leaves too many candidates for a practical exhaustive decoder.

The lesson is that exhaustive search is impractical. Exact maximization over an opaque table of candidate scores has no general shortcut: in the worst case every entry must be examined. The decoders here exploit the specified factorization and legal output structure.

Factorizing the Score

The exact charts below use decomposability of the score. Instead of scoring a tree as an opaque object, score it as a sum over its parts:

s(x,y)=∑p∈parts(y)ϕ(x,p)s(x, y) = \sum_{p \in \text{parts}(y)} \phi(x, p)

where:

  • s(x,y)s(x, y): the score assigned to structure yy given input xx, built as a sum over its parts
  • parts(y)\text{parts}(y): the scored part occurrences in yy, such as arcs, labeled span occurrences, or production uses. A repeated part contributes once per occurrence.
  • ϕ(x,p)\phi(x, p): the local score for one part pp given input xx

If the parts are arcs, the model is called arc-factored or first-order:

s(x,y)=∑(h,m,ℓ)∈yw⊤f(x,h,m,ℓ)s(x, y) = \sum_{(h,m,\ell) \in y} \mathbf{w}^\top \mathbf{f}(x, h, m, \ell)

where:

  • (h,m,ℓ)(h,m,\ell): an arc in yy with head hh, modifier mm, and label ℓ\ell
  • w∈Rd\mathbf{w}\in\mathbb R^d: the model's weight vector, with one entry for each of dd features
  • f(x,h,m,ℓ)∈Rd\mathbf{f}(x, h, m, \ell)\in\mathbb R^d: the feature vector for that arc given the input

An arc score may use the head word, dependent word, their distance, tags, or contextual representations computed from the entire input sentence. Arc factorization restricts dependence on the selected output: the score of one arc does not change according to which other arcs the decoder selects. It does not require a narrow input window. This distinction lets a contextual neural encoder use sentence-wide information while the structural decoder still optimizes a sum of individual arc scores.

Factorization

A factorization is a choice of which subsets of the output get their own score. The score of the whole is the sum of the scores of the parts. Changing the factorization can change the model family, decoding algorithm, and computational cost. Different factorizations need not have different asymptotic costs; the chart states and algorithm also matter.

The factorization and the decoder's state design jointly determine complexity. The examples below exclude the cost of computing neural or hand-built part scores; LL is the number of arc labels and ∣R2∣|\mathcal{R}_2| the number of binary grammar rules.

Example decoder bounds under the listed factorizations. Grammar size, label preparation, and root constraints must be included when they vary.
PartsModel familyExact decoder exampleTime
arc (h,m)(h,m)first-orderEisner, projectiveO(n3)O(n^3)
arc (h,m)(h,m)first-orderoptimized Chu-Liu/Edmonds arborescenceO(n2)O(n^2)
labeled arc (h,m,ℓ)(h,m,\ell), independent labelslabeled first-orderlabel maximization plus EisnerO(n2L+n3)O(n^2 L+n^3)
successive same-side sibling pair (h,m1,m2)(h,m_1,m_2)second-order, two arcssibling chartO(n3)O(n^3)
grandparent chain (g,h,m)(g,h,m)second-order, two arcsgrandparent-augmented chartO(n4)O(n^4)
grand-sibling, three arcsthird-orderKoo and Collins chartO(n4)O(n^4)
labeled spans with binary rule constraintsconstituencyCKY enumerating binary rules$O(n^3
production A→B CA\to B\,Cweighted CFG or PCFGCKY$O(n^3

Order counts arcs in a part, not the number of word indices: a grandparent chain has two arcs and is second-order. Richer parts can require extra state, but each increase in order does not automatically add a power of nn. Koo and Collins (2010) describe cubic parsing with successive modifiers on the same side of their head and quartic grandparent and selected third-order parsers. For non-projective arborescences the table gives an optimized bound; a straightforward recursive Chu-Liu/Edmonds implementation can take cubic time. Enforcing exactly one lexical root child may add work beyond an unconstrained arborescence call. McDonald et al. (2005) explain the edge-factored reduction and its decoder implementations.

Neural scoring can change the information used to assign each part's score without changing that factorization. This makes it useful to report encoder/scorer cost separately from structural decoding cost when comparing complete systems.

The chart below compares illustrative operation counts for candidate lexical arcs, cubic charts, and quartic charts. They are operation-count surrogates with their constants suppressed, not measured timings or a universal mapping from model order to runtime. In particular, adjacent-sibling and first-order projective parsing can both be cubic.

PythonIn [3]
CollapseExpand
import numpy as np

n_values = np.arange(5, 41)
candidate_arc_counts = n_values.astype(float) * (n_values - 1)
cubic_growth = n_values.astype(float) ** 3
quartic_growth = n_values.astype(float) ** 4
VisualizationOut [4]
CollapseExpand
Log-scale curves for quadratic candidate arcs, cubic charts, and quartic charts.
Unit-coefficient growth functions for candidate lexical arcs, cubic charts, and quartic charts. These are asymptotic illustrations, not measured runtimes; factorization order alone does not determine the exponent.

The Price of Richer Parts

Why not score every complete tree with an unrestricted neural network? Without additional exploitable structure, an exact maximization would need to examine candidates that cannot be merged into reusable chart states. Exact enumeration is possible on tiny inputs, but the sentence-length count above makes it impractical in general. A system may instead use a restricted candidate list, beam search, or another approximate method. The appropriate claim is about this unrestricted scorer: it does not itself supply an efficient exact decoder or partition-function computation.

For chart-based parsing, a useful factorization balances the distinctions retained in a state against the cost of combining states. Larger parts can express interactions among selected arcs, but their tractability depends on the interaction pattern and the chosen algorithm. Other structured predictors can exploit graph algorithms, integer programming, or special problem structure instead of a chart. Identifying that structure is a modeling step, not a property guaranteed by the words “structured prediction.”

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy