Dependency Parsing: Representing Sentence Structure
Structure beyond a flat sequence of words
A sentence is more than a bag or even a sequence of words — it has internal structure. "The cat that chased the mouse ran away" tells you that "ran away" happened to "the cat," not to "the mouse," even though "mouse" sits closer to the verb in the raw token sequence. Dependency parsing is the task of recovering this structure: representing a sentence as a tree where each word (except one) has exactly one head — the word it grammatically depends on — connected by a labeled relation describing the nature of that dependency.
Unlike constituency parsing, which groups words into nested phrases (noun phrases, verb phrases), dependency parsing works directly with word-to-word relations. This makes it more directly useful for many downstream NLP tasks, because it answers a very practical question: for any given word, what is it attached to, and how?
Heads, dependents, and relation labels
In a dependency tree, the main verb of a sentence is typically the root of the tree. Every other word depends, directly or indirectly, on the root. Each edge in the tree carries a label describing the grammatical relation: nsubj (nominal subject), dobj (direct object), amod (adjectival modifier), det (determiner), prep (prepositional modifier), and dozens more, standardized across languages by frameworks like Universal Dependencies.
For "The cat chased the mouse," the root is "chased." "cat" is its nsubj (the one doing the chasing), "mouse" is its dobj (the one being chased), and "The" in each case is a det dependent of the noun it precedes. The entire sentence collapses into a tree rooted at the verb, with every other word's role defined relative to its head.
Note
How parsers build the tree
Modern dependency parsers are overwhelmingly transition-based or graph-based. A transition-based parser reads the sentence left to right, maintaining a stack and a buffer, and at each step chooses an action — shift a word onto the stack, or attach the top of the stack to another word with a given relation (an "arc") — using a learned classifier to pick the best action at each step. This is fast (linear in sentence length) and was the dominant approach in production parsers like spaCy's earlier models.
A graph-based parser instead scores every possible head-dependent arc in the sentence using a neural network (often a BiLSTM or transformer encoder feeding into a biaffine scoring layer), then finds the highest-scoring tree over the whole sentence using a maximum spanning tree algorithm. Graph-based parsers are generally more accurate because they consider global tree structure rather than committing to local decisions one at a time, at the cost of being somewhat slower.
Why dependency parses matter downstream
Dependency parses are rarely the end product; they're infrastructure that other NLP components build on. Information extraction systems use dependency paths to find relations between entities ("the subject of the verb 'founded', whose object is a company name, is likely the founder"). Sentiment analysis uses dependency structure to correctly attach negation ("not good" vs. "good") and to find what an adjective is actually modifying in a long sentence. Grammar checkers use dependency relations to spot subject-verb agreement errors. Question answering systems use dependency paths between the question's wh-word and its answer candidates.
Even in the transformer era, where end-to-end neural models often implicitly learn syntax-like structure inside their attention patterns, explicit dependency parses remain useful whenever a task needs an interpretable, auditable grammatical structure rather than a black-box representation.
Transition-based vs. graph-based dependency parsing
| Aspect | Transition-based | Graph-based |
|---|---|---|
| Decision style | Sequential, local actions (shift/attach) | Global: scores all possible arcs at once |
| Speed | Linear time, very fast | Slower (typically quadratic in sentence length) |
| Accuracy | Good, but can propagate early errors | Generally higher, avoids local error compounding |
| Typical use | Real-time pipelines, large-scale processing | Research, offline high-accuracy parsing |
| Classic example | Arc-eager/arc-standard shift-reduce parser | Biaffine neural parser (Dozat & Manning) |
Note
What's next
Dependency parsing tells you how words within a sentence relate to each other. A related but distinct challenge is figuring out how mentions across a whole document relate to each other — specifically, which pronouns and noun phrases refer to the same real-world entity. The next lesson covers coreference resolution.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.