AI Glossary / Deep learning / Advanced
Recursive Neural Network
Definition
A recursive neural network is a neural model that repeatedly combines representations of smaller components to represent a larger structured object. In a common tree-based form, the same learned composition function combines child-node vectors into a parent-node vector, continuing until a representation of the whole tree is produced. It is often abbreviated RecNN to distinguish it from a recurrent neural network.
What it means
Some information has a natural hierarchy. Words form phrases, phrases form clauses, and clauses form sentences. A recursive model can follow this hierarchy rather than treating the input only as a flat list. The representation of a parent depends on both the child representations and the rule used to combine them.
The structure matters. Grouping three components as ((A, B), C) need not give the same representation as (A, (B, C)). This does not automatically make one grouping correct; the model needs an appropriate structure and a meaningful training objective.
How it works
Start with numerical representations at the leaves of a tree. For a simple binary composition, concatenate two child vectors, apply a learned weight matrix and bias, and pass the result through a nonlinear function such as tanh. The parent vector has a compatible size so that it can be combined again at the next level.
Repeat until the root is computed. A prediction head may classify the root, selected subtrees, or every node with a label. Training adjusts shared parameters using errors propagated through the structure.
The tree may be supplied by a parser or another process; recursive computation alone does not discover the correct structure. Variants change the composition rule. The recursive neural tensor network in Socher and colleagues' 2013 work adds explicit interactions between child representations and should not be treated as identical to every recursive model.
Three practical examples
- A sentiment model combines words into phrase representations, allowing the grouping of a negation with its target to influence a sentence-level prediction. It still needs evaluation on the language and domain in which it will be used.
- A code-analysis prototype combines representations along a program's syntax tree. Its prediction can depend on nested structure, although an incorrect parse or unsupported language construct can undermine the result.
- An educational-content experiment represents a hierarchy of lesson components before predicting a document category. The team checks whether the hierarchy adds useful information compared with a simpler model using the same content.
Think of it this way
Imagine assembling a model from small subassemblies. Each completed subassembly becomes a component in a larger one. The assembly instructions determine which pieces are joined first. A recursive network follows a comparable pattern with vectors, although its learned numerical combination is not a literal account of how people assemble meaning.
Worked example
Use scalar leaf representations A = 1, B = 2, and C = 3. For transparent arithmetic, define the teaching composition g(left, right) = ReLU(2 times left + right). The same weights, two and one, are used at every internal node; the bias is zero.
For the tree ((A, B), C), first combine A and B: ReLU(2 times 1 + 2) = 4. Then combine that result with C: ReLU(2 times 4 + 3) = 11.
For the tree (A, (B, C)), first combine B and C: ReLU(2 times 2 + 3) = 7. The root becomes ReLU(2 times 1 + 7) = 9. The leaves and their order are unchanged, but the grouping changes the result. Neither 11 nor 9 is a sentiment probability. These hand-chosen scalar calculations illustrate shared composition and structural sensitivity, not the trained model or experimental results from the cited paper.
Illustrative case study
Fictional Birch Reviews explores a recursive model for organizing comments about online courses. The team hopes phrase structure will help distinguish criticism of a course from criticism that the reviewer explicitly rejects.
A review of errors reveals that the parser handles short, informal comments inconsistently. The team records parsing failures, compares predictions under alternative trees, and evaluates against a simpler baseline on held-out comments. It reports both classification performance and the additional processing burden. The experiment does not assume that a tree-based design automatically understands negation, sarcasm, or a reviewer's intent. This case is invented to illustrate evaluation choices.
Common misconceptions and mistakes
Recursive and recurrent networks share ideas about repeated computation but usually organize it differently: a recursive tree model combines branches, while a standard sequence RNN updates state along a sequence. Both have sometimes been called RNN, so expand the abbreviation.
A recursive model is not merely ordinary software written with a recursive function. Shared neural composition is the relevant mechanism. A supplied parse tree is not guaranteed semantic truth, and a root vector is not a readable explanation. Do not transfer a historical sentiment benchmark result to a different dataset or to the whole family of recursive architectures.
Business use
Consider this approach when a reliable hierarchy is available and there is a plausible reason for that structure to improve the task. Potential costs include parsing, tree validation, specialized batching, and debugging errors that arise from the structure rather than the classifier alone.
Evaluate the complete pipeline, including how trees are obtained at deployment. Compare like-for-like data splits and include difficult structures in error analysis. Keep performance claims tied to the tested task. A technically elegant hierarchy has business value only when its benefits justify the added effort and operational constraints.
People also ask
Must the tree be binary?
No. Binary composition is a common formulation, but other designs can handle different branching structures.
Does the model learn the tree?
Not necessarily; many formulations receive it as an input.
Is a recursive neural tensor network the same thing?
It is a specific recursive architecture with a richer composition function.
Check your understanding
Why do the two example trees produce different roots?
Answer: The shared composition is applied to different intermediate groupings.
Did the example use new weights at each node?
Answer: No. The same composition parameters were reused.
Would a correct numerical computation prove that a sentence was understood?
Answer: No. Task performance and interpretation require separate evidence.
Related terms
- Parse tree
- Embedding
- Recurrent neural network
- Backpropagation through structure
- Sentiment analysis
- Compositionality
- recursive neural tensor network
- Tree-LSTM
Learn next
Swap the left and right children in the first example combination and recalculate its value. Explain why an ordered composition can distinguish child positions. Then examine the difference between a basic recursive composition and the tensor interaction introduced in the cited research.
More in Deep learning
- Reactive layer - A reactive layer is the part of a robot or agent architecture that produces timely responses to current observations through relatively direct...
- Receptron - A receptron is a proposed nonlinear threshold computing unit that generalizes the perceptron by allowing effective input weights to depend on the input...
- Recurrent Layer - A recurrent layer is a neural-network component that processes a sequence by updating an internal state as it encounters successive inputs.
- Region Based Convolutional Neural Networks - Region-based convolutional neural networks are object-detection approaches that analyze candidate image regions using convolutional features to identify...
- Relation network - A relation network is a neural-network module designed to learn from relationships between pairs of represented objects.
- Reservoir computing - Reservoir computing is an approach to processing time-dependent information in which an input drives a dynamical system, called a reservoir, and a readout...
Sources
Socher and colleagues, Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank, EMNLP 2013; Section 4 distinguishes standard recursive, matrix-vector, and tensor models: https://nlp.stanford.edu/pubs/SocherEtAl_EMNLP2013.pdf
Previous: Recursive least squares Next: Recursive partitioning