You now know what each word is. But do you know what each word does?
In the previous post, we covered Part of Speech Tagging: the process of labelling each word as a noun, verb, adjective, and so on. That tells you the category of every word in a sentence. But it doesn't tell you how those words connect to each other.
Take this sentence: "The dog bit the man."
POS tagging tells you that "dog" is a noun and "bit" is a verb. But it doesn't tell you that "dog" is the one doing the biting, or that "man" is the one receiving it. For a lot of NLP tasks, that distinction matters enormously.
Dependency parsing is how NLP systems figure out those relationships. It maps the grammatical connections between words, revealing who did what to whom and how every part of a sentence fits together.
What is dependency parsing?
Before we get into how computers do this, it helps to understand the underlying idea.
Dependency grammar is a theory of language structure that describes sentences as networks of relationships between words. Instead of breaking a sentence into nested phrases (like traditional grammar diagrams), dependency grammar draws direct links between individual words.
Every word in a sentence (except one) depends on another word. The word it depends on is called its head. The relationship between them is called a dependency relation, and these relations have names that describe the grammatical role: subject, object, modifier, determiner, and so on. The one word that depends on nothing is the root of the sentence, usually the main verb.
In "The dog bit the man," the structure looks like this:
- "bit" is the root (nothing governs it)
- "dog" depends on "bit" as the subject (`nsubj`)
- "man" depends on "bit" as the object (`obj`)
- "The" (first one) depends on "dog" as a determiner (`det`)
- "the" (second one) depends on "man" as a determiner (`det`)
Every word is accounted for. Every relationship is named. The sentence has been turned into a map.
When you draw out all those relationships visually, you get what's called a dependency tree. It's called a tree because the structure branches outward from a single root, just like a real tree. The main verb sits at the top. Subjects, objects, and modifiers hang below it. Determiners and other function words hang below those. Every node is a word, every edge is a labelled relationship, and every word appears exactly once with no circular chains.
Here's what the dependency tree for "The quick brown fox jumped over the fence" looks like conceptually:
- "jumped" is the root
- "fox" is the subject of "jumped" (`nsubj`)
- "quick" and "brown" are adjective modifiers of "fox" (`amod`)
- "The" is a determiner of "fox" (`det`)
- "fence" is the object of the preposition "over" (`pobj`)
- "over" is a prepositional modifier of "jumped" (`prep`)
- "the" is a determiner of "fence" (`det`)
The tree makes the structure of the sentence explicit and machine-readable. A system can now navigate it programmatically: find the subject of the main verb, find all modifiers of a given noun, find the object of any action.
Parse Trees: Two Flavours
You'll often hear the term parse tree used when people talk about dependency parsing, and it's worth understanding what it means and how it relates to what we've just described.
A dependency parse tree (what we've been describing) connects individual words to each other with typed relationship labels. The structure is flat in the sense that it connects words directly, without grouping them into phrases.
A constituency parse tree (also called a phrase structure tree) takes a different approach. Instead of connecting words to words, it groups words into nested phrases. A noun phrase contains a determiner and a noun. A verb phrase contains a verb and its noun phrase. Those phrases nest inside a sentence node at the top. The two approaches reveal the same underlying sentence structure but from different angles.
In practice the choice between them comes down to the task:
- Dependency trees are word-to-word. Better for tasks that need to know relationships between specific words: who did what to whom.
- Constituency trees are phrase-based. Better for tasks that need to understand the hierarchical structure of a sentence: how clauses nest inside each other.
In modern NLP, dependency parsing is more widely used in production systems. It's faster to compute, easier to work with programmatically, and sufficient for most downstream tasks.
Both dependency parsing and constituency parsing are forms of syntactic analysis: the broader process of examining the grammatical structure of a sentence. POS tagging is also a form of syntactic analysis. They're all part of the same family of techniques, each revealing a different layer of grammatical structure. In NLP pipelines, syntactic analysis typically sits between basic text processing (tokenization, POS tagging) and higher-level understanding (semantic analysis, information extraction). It provides the structural backbone that makes deeper analysis possible.
How Dependency Parsing Works
Modern dependency parsers use neural networks, but the core task is always the same: for each word in a sentence, find its head and label the relationship.
There are two main algorithmic approaches. Transition-based parsing works through the sentence from left to right, maintaining a stack of words currently being processed. At each step, a classifier decides between a small set of actions: shift the next word onto the stack, create a dependency between two words, or move on. Because decisions are made one step at a time, this approach runs in linear time and is fast enough for production use.
Graph-based parsing takes a different route. Instead of building the tree step by step, it scores all possible edges between all pairs of words and then finds the tree that maximises the total score. This is slower but tends to be more accurate, especially for longer sentences with complex structure. Most state-of-the-art parsers today combine neural networks with graph-based approaches, using Transformer-based representations to score edges with rich contextual information.
Why It Matters in Practice
Like POS tagging, dependency parsing is rarely the end goal. It's a layer in a pipeline that makes other things possible.
Information extraction uses dependency trees to find subject-verb-object triples at scale. Given a corpus of news articles, you can extract every event of the form "company acquired company" or "person said statement" by querying the parse tree structure. This is faster and more precise than hoping a language model happens to extract the right thing.
Question answering systems use dependency parsing to understand what a question is actually asking. "Who did the dog bite?" and "Who bit the dog?" have identical words but opposite meanings. The dependency tree makes that difference explicit.
Machine translation relies on syntactic structure to produce grammatically correct output in the target language. Word order differs between languages, and dependency relations provide language-agnostic structure that translation systems can map across.
Clinical NLP uses dependency parsing to extract medication dosages, symptoms, and diagnoses from clinical notes. A rule like "find the noun that is the object of the verb 'prescribed'" is far more reliable than keyword matching when clinical language is ambiguous and variable.
Coreference resolution (figuring out that "he" in one sentence refers to "John" in a previous one) uses dependency structure to track entities across sentences. The grammatical role of a pronoun is a strong signal for what it refers to.
The honest take on modern NLP: large language models have reduced how much explicit dependency parsing is done in cutting-edge research. But in production systems where interpretability, speed, and precision matter, dependency parsing remains a practical and widely used tool. spaCy runs a dependency parser by default on every document you process. You might not use the output directly, but it's there, and the components that do use it quietly improve everything downstream.
The structure of a sentence is not decoration. It is the scaffolding that holds meaning together.
Dependency Parsing in Python with spaCy
spaCy makes dependency parsing straightforward. It runs automatically when you process text:
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("The dog bit the man.")
for token in doc:
print(f"{token.text} --[{token.dep_}]--> {token.head.text}")
Output:
The --[det]--> dog
dog --[nsubj]--> bit
bit --[ROOT]--> bit
the --[det]--> man
man --[dobj]--> bit
. --[punct]--> bit
Every token shows its dependency label and the head it points to. The root points to itself. From this output, a downstream system can immediately answer: what is the subject of "bit"? Dog. What is the object? Man.
You can also visualise the tree directly in spaCy using its built-in displaCy renderer, which produces a clean arc diagram in the browser.
Is Dependency Parsing Still Relevant?
Short answer: yes, especially in production.
Large language models are impressive at understanding language holistically, but they're opaque. You can't inspect why they interpreted a sentence a certain way. Dependency parsing gives you an explicit, interpretable representation of sentence structure that you can query, validate, and debug.
For teams building NLP pipelines in healthcare, legal tech, or finance, where decisions need to be explainable and auditable, dependency parsing is not a relic of the past. It's a practical engineering choice that trades some accuracy for a lot of transparency and control.
Even in LLM-powered systems, dependency parsing often runs in the preprocessing layer: cleaning up the input, extracting structured signals, or filtering out irrelevant sentences before the expensive model ever sees them. It earns its place not by being the most powerful tool, but by being fast, reliable, and interpretable in a world where those qualities are often more valuable than raw performance.
What Comes Next
Dependency parsing gives you the grammatical structure of a sentence. You now know what each word is (POS tags) and how each word connects to the others (dependency relations).
The next step is moving from structure to meaning. That's where Word Sense Disambiguation comes in: the process of figuring out which meaning a word carries when it could mean several different things. It's where NLP starts crossing from grammar into genuine language understanding.
Learn This at Fondra Labs
This post is part of our NLP Foundations series, where we build up practical AI knowledge one concept at a time, from tokenization and POS tagging all the way to retrieval systems and production pipelines.
At Fondra Labs, we teach AI from production reality, not hype. Every topic in this series is here because it genuinely matters when you sit down to build something real.
If this was useful, explore the rest of the blog. We cover machine learning, deep learning, NLP, and the practical skills that turn understanding into building.
Frequently Asked Questions
Build your AI Foundations
Get the free checklist that production engineers use to avoid these common RAG pitfalls.
Get the Free Guide