# Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks

Tree-structured LSTMs beat sequential LSTMs on sentence meaning tasks

Kai Sheng Tai, Richard Socher, Christopher D. Manning · arXiv · 2015-2-28

- **Problem** Sequential LSTMs read a sentence along one chain, so its syntactic grouping of words is not built in. It was unclear whether tree-shaped composition would give better sentence vectors.
- **Method** Tree-LSTM generalizes the LSTM to trees, so each unit reads several child units instead of one predecessor. It gives each child its own forget gate.
- **Results** The Constituency Tree-LSTM reached 51.0 fine-grained accuracy on Stanford Sentiment Treebank, above the best listed prior system at 49.8.

## Why sentence structure matters for LSTM encoders

Sentence representations are usually built in one of three ways: by averaging word vectors, by running a sequence model over the tokens, or by composing vectors along a syntactic tree. Averaging discards word order, so sentences that differ only in which noun acts on which is invisible to such a model.

Recurrent networks read input of arbitrary length, but a plain recurrent transition struggles with long-distance dependencies because gradients grow or decay exponentially over long sequences. The LSTM addresses this with a memory cell that can keep state over long spans, and it has been applied widely to sequence tasks. A sequence model still propagates information along a single chain, so any phrase structure must be inferred from word order.

The open question, which this work tests directly, is whether a tree-shaped topology gives better sentence vectors than a sequential LSTM.

## Tree-LSTM units with several children

A Tree-LSTM unit j takes an input vector x\_j and the hidden states and memory cells of its children, so its gates depend on the whole set of children rather than on one predecessor. Instead of one forget gate, each child k gets its own forget gate f\_jk, which lets the unit decide how much of each child's memory to keep.

The Child-Sum variant first sums the child hidden states into \\( \\tilde{h}\_j = \\sum\_{k \\in C(j)} h\_k \\), and the input, output and candidate gates are computed from that sum. Each child's forget gate is computed from its own hidden state, and the memory cell is updated as \\( c\_j = i\_j \\odot u\_j + \\sum\_{k \\in C(j)} f\_{jk} \\odot c\_k \\), so the number of children can vary freely.

The N-ary variant suits trees with ordered children and a bounded branching factor N. Each child position has its own weight matrices, so the forget gate for child k combines the states of all N positions through a separate matrix for each pair of positions. This allows finer control, for example a verb phrase child can be kept while a noun phrase child is forgotten, but the off-diagonal matrices become impractical for large N, where the authors suggest tying or fixing them.

The Dependency Tree-LSTM applies the Child-Sum unit to dependency trees, where each node takes the vector of its head word as input. The Constituency Tree-LSTM applies the binary N-ary unit to binarized constituency trees, where only leaf nodes receive word vectors and the left and right children have separate parameters.

## Classifier and relatedness heads

For sentiment, a softmax layer on the hidden state of each labeled node predicts its class, and training minimizes the negative log-likelihood of the gold labels plus an L2 penalty. For relatedness, the two sentence vectors h\_L and h\_R are combined by an elementwise product \\( h\_{\\times} = h\_L \\odot h\_R \\) and an elementwise absolute difference, and a sigmoid layer and softmax then give a distribution over the scores 1 to K.

The predicted score is the expectation \\( \\hat{y} = r^{T}\\hat{p}\_\\theta \\), with \\( r^{T} = \[1\\ 2\\ \\ldots\\ K\] \\). The training target is a sparse distribution whose expectation equals the gold rating: its mass is split between the two integers that bracket the rating, in proportion to how close the rating lies to each. The loss is a regularized KL divergence between that target and the predicted distribution, and the authors report that this objective performed better than a mean squared error objective.

## Data, parameter matching and training

Sentiment experiments use the Stanford Sentiment Treebank, with 6920/872/1821 train/dev/test sentences for the binary subtask and 8544/1101/2210 for the five-class subtask. The binary subtask has fewer examples because neutral sentences are excluded from it.

Relatedness uses SICK, with 9927 sentence pairs split 4500/500/4927 into train, dev and test, and each relatedness score is an average of 10 annotator ratings on a 1 to 5 scale.

To compare structures at similar capacity, the memory dimension of each LSTM variant was set so that its parameter count stays close to the others. For the standard LSTM the memory dimension is 150 with 203,400 parameters on relatedness and 168 with 315,840 parameters on sentiment; the Constituency Tree-LSTM has 142 and 205,190 on relatedness and 150 and 316,800 on sentiment.

Word vectors are 300-dimensional GloVe vectors, updated during sentiment training at a learning rate of 0.1 and held fixed for relatedness, where tuning gave no significant improvement.

## Sentiment results on the Stanford Sentiment Treebank

The Constituency Tree-LSTM with tuned GloVe vectors reached 51.0 fine-grained accuracy, averaged over 5 runs, above the Bidirectional LSTM at 49.1 and the DRNN at 49.8, the highest listed prior system. On the binary subtask the same model reached 88.0, which is comparable to the best listed prior results rather than clearly above them. The plain LSTM reached 46.4 fine-grained and 84.9 binary, below the tree models in the same table.

With randomly initialized vectors the Constituency Tree-LSTM drops to 43.9 fine-grained and 82.0 binary, so its strength depends on the pretrained vectors. With GloVe vectors held fixed it reached 49.7 fine-grained and 87.5 binary.

The Dependency Tree-LSTM scored 48.4 fine-grained and 85.7 binary, below the constituency model on both. The authors attribute part of this gap to training data: about 150K labeled nodes for the dependency model against 319K for the constituency model. They also point to dependency representations having fewer nodes, and to about 9% of dependency nodes that could not be matched to a labeled span in the training data.

Updating the word vectors during training gave a larger boost on fine-grained classification than on the binary subtask. The authors expect this because the GloVe vectors were not trained to capture sentiment.

## Relatedness results on SICK

The strongest sequential model was the Bidirectional LSTM, at 0.8567, 0.7966 and 0.2736 on the same three measures.

The Constituency Tree-LSTM reached Pearson’s r of 0.8582, above every sequential variant on that measure and tied with the Bidirectional LSTM on Spearman’s ρ at 0.7966. The non-LSTM baselines were lower: mean vectors reached 0.7577, while DT-RNN and SDT-RNN reached 0.7923 and 0.7900.

Among the SemEval 2014 systems listed, ECNU reached 0.8414 and the Meaning Factory 0.8268, and the models in the table use no additional feature engineering. The authors note that their ECNU figure is stronger than the team's submitted system, which scored 0.8280 Pearson correlation.

Both tree models receive supervision only at the root in this task, unlike sentiment, where intermediate nodes are also labeled. The authors conjecture that the dependency model benefits from shorter paths between input words and the root, which the compact dependency structure provides.

## Sentence length and tree advantage

The hypothesis is that tree structure eases the problem of preserving state over long word sequences, so the gain over sequential LSTMs should be largest on longer sentences. The length analysis bins sentences for both tasks, and for relatedness each point is the Pearson correlation over pairs whose mean length falls in a window.

The Dependency Tree-LSTM outperforms its sequential counterparts on relatedness for pairs of length 13 to 15, and it also performs consistently well on shorter pairs. The authors read this as evidence that tree structure encodes useful structural information in the representations, not only a remedy for length.

Length is measured as the mean length of the two sentences in a pair, so the analysis does not give a per-sentence comparison.

## What the relatedness rankings show

For the query about a boy waving at runners from the ocean, the word ocean sits at depth 4 in the dependency parse, yet the retrieved sentences are all related to ocean, which the authors read as the tree model keeping information from relatively distant nodes.

## Limits of the evidence

The sentiment gap between the two tree models is confounded by training-node counts, about 150K against 319K, so the authors do not isolate the cause. The node-count explanation is partial, and the authors also cite the unmatched dependency nodes, which they estimate at about 9%.

The experiments use two benchmarks, the Stanford Sentiment Treebank and SICK, and relatedness uses fixed word vectors because tuning gave no significant improvement.

The best sentiment result comes from a constituency tree and the best relatedness result from a dependency tree, so no single tree type is shown to be best on both tasks.

## Paper info

- **Authors**: Kai Sheng Tai, Richard Socher, Christopher D. Manning
- **Venue**: arXiv · Preprint
- **First published**: 2015-2-28
- **Added**: 2026-11-12
- **Updated**: 2015-5-30
- **Version**: v3
- **arXiv**: 1503.00075
- **Category**: cs.CL · cs.AI · cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1503.00075v3) · [PDF ↗](https://arxiv.org/pdf/1503.00075v3)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Kai Sheng Tai, Richard Socher, Christopher D. Manning (2015). Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks. arXiv:1503.00075v3. https://arxiv.org/abs/1503.00075v3

**BibTeX**

```
@misc{tai2015improved,
  title = {{Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks}},
  author = {Kai Sheng Tai and Richard Socher and Christopher D. Manning},
  year = {2015},
  eprint = {1503.00075},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1503.00075v3}
}
```

## Related papers

- [Recent Trends in Deep Learning Based Natural Language Processing](https://refivu.com/en/papers/6cdbf953-5aaa-4de2-9e22-528902a11655-recent-trends-in-deep-learning-based-natural-language.md)
- [A large annotated corpus for learning natural language inference](https://refivu.com/en/papers/7e4b0424-7bbb-49b5-a1e2-69bf72d8d16b-a-large-annotated-corpus-for-learning-natural-language.md)
- [Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results](https://refivu.com/en/papers/db4b57dd-c8b9-4380-b088-3186a676efaf-mean-teachers-are-better-role-models-weight-averaged.md)
- [Bidirectional LSTM-CRF Models for Sequence Tagging](https://refivu.com/en/papers/7f421939-0d02-43b3-b25f-86a13896fd18-bidirectional-lstm-crf-models-for-sequence-tagging.md)
- [A Survey on Deep Learning in Medical Image Analysis](https://refivu.com/en/papers/4d173b56-9ea6-4644-98f2-af1794e63965-a-survey-on-deep-learning-in-medical-image.md)
- [Deep Learning based Recommender System: A Survey and New Perspectives](https://refivu.com/en/papers/a0b4c642-cc6f-408f-8e70-b8aaebc9c4da-deep-learning-based-recommender-system-a-survey-and.md)

## Other paper commentary

- [Selective Kernel Networks](https://refivu.com/en/papers/958e4edd-4fd5-43a9-a954-172b1f630ca0-selective-kernel-networks.md)
- [NetVLAD: CNN architecture for weakly supervised place recognition](https://refivu.com/en/papers/2bcdc73b-8d7c-43d5-bbd7-bdc18c43eeaa-netvlad-cnn-architecture-for-weakly-supervised-place.md)
- [Multi-view Convolutional Neural Networks for 3D Shape Recognition](https://refivu.com/en/papers/80b8aedd-6f52-4a73-bc81-a80322e5e37c-multi-view-convolutional-neural-networks-for-3d-shape.md)
- [A Convolutional Neural Network for Modelling Sentences](https://refivu.com/en/papers/09b470f4-ff62-40ab-9355-2f9413d8271f-a-convolutional-neural-network-for-modelling-sentences.md)
- [In Defense of the Triplet Loss for Person Re-Identification](https://refivu.com/en/papers/9a193d31-bb38-4b07-8752-1bc32882197d-in-defense-of-the-triplet-loss-for-person.md)
- [Accelerating the Super-Resolution Convolutional Neural Network](https://refivu.com/en/papers/36219c92-ee60-4179-a5b4-065fdb8a7ff4-accelerating-the-super-resolution-convolutional-neural.md)
- [The Effectiveness of Data Augmentation in Image Classification using Deep Learning](https://refivu.com/en/papers/dce0e6e2-408a-4750-8e27-0acf7a41b5e6-the-effectiveness-of-data-augmentation-in-image.md)
- [Holistically-Nested Edge Detection](https://refivu.com/en/papers/4e4005ad-53a4-40bd-8c81-abf1f3ea35bf-holistically-nested-edge-detection.md)
- [Using Information Content to Evaluate Semantic Similarity in a Taxonomy](https://refivu.com/en/papers/23ad22de-7daf-406d-8e06-0f53f8035655-using-information-content-to-evaluate-semantic-similarity-in.md)
- [OpenAI o1 System Card](https://refivu.com/en/papers/86efdb99-0408-42d7-9138-ff8f4765106f-openai-o1-system-card.md)
- [HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units](https://refivu.com/en/papers/4fe3f455-0287-4182-b603-63ebb7e4b5fc-hubert-self-supervised-speech-representation-learning-by.md)
- [Multi-View 3D Object Detection Network for Autonomous Driving](https://refivu.com/en/papers/f58134ec-87c8-446c-9cb7-11f607b68051-multi-view-3d-object-detection-network-for-autonomous.md)

## Terms in this paper

- [Accuracy](https://refivu.com/en/terms/1995c0cd6282-accuracy)
- [dropout](https://refivu.com/en/terms/db73f75bbdd3-dropout)
- [LSTM](https://refivu.com/en/terms/ba10547646d9-lstm)
- [mean squared error](https://refivu.com/en/terms/e8df98e6d7b7-mean-squared-error)
- [Bidirectional LSTM](https://refivu.com/en/terms/d29b8fa18f91-bidirectional-lstm)
- [forget gate](https://refivu.com/en/terms/0f084d82dd99-forget-gate)
- [sentiment classification](https://refivu.com/en/terms/73e8de11d42b-sentiment-classification)
- [SICK](https://refivu.com/en/terms/f79ec6f24f3b-sick)
- [memory cell](https://refivu.com/en/terms/2efbf8b313ae-memory-cell)
- [Stanford Sentiment Treebank](https://refivu.com/en/terms/6e494723bd61-stanford-sentiment-treebank)
- [Tree-LSTM](https://refivu.com/en/terms/793645055f46-tree-lstm)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/1c58c569-ccc9-46f2-b934-b34b865af6d4-improved-semantic-representations-from-tree-structured-long)
