Learning sentence embeddings using Recursive Networks

Anson BastosarXiv 2018

Abstract

This study investigates the efficiency of different neural architectures for learning sentence embeddings, specifically comparing sequence-based Long Short-Term Memory (LSTM) networks against structure-based Recursive Neural Networks (RNNs). By training on a "reverse dictionary" task—mapping dictionary definitions to target words—the research demonstrates that Recursive Networks, which utilize explicit grammatical parse trees, can significantly outperform LSTMs on limited datasets while requiring fewer parameters. The paper also introduces a novel Recursive model that uses Part-of-Speech (POS) tags to dynamically determine weights and evaluates the role of pretraining in model regularization.

Introduction

A fundamental challenge in Natural Language Processing (NLP) is learning sentence embeddings that generalize across diverse tasks. While sequence-based models like LSTMs are the industry standard, they typically require vast amounts of data to implicitly learn linguistic structure. This paper explores whether explicitly providing grammatical structure via dependency parsing can improve learning efficiency, particularly in data-constrained environments.

Methodology

The study compares three primary architectures for generating sentence embeddings:

1. Standard LSTM Baseline

The baseline is a uni-directional LSTM with two layers and 256 hidden units. Words are fed into the network in reverse order, a common technique for sequence-to-sequence tasks to improve performance on long-range dependencies.

Figure 1: Architecture of the baseline 2-layer LSTM processing a sentence in reverse order.

2. Recursive Neural Network (RNN) with Shared Weights

Unlike the sequential LSTM, this model uses a SyntaxNet parser to generate a grammatical parse tree. The sentence embedding is constructed from the bottom up, where child nodes are combined into parent nodes using a single, shared weight matrix.

3. Recursive Neural Network with Unique Weights

This novel variation dynamically determines the weights applied to child nodes based on their Part-of-Speech (POS) tags. The hypothesis is that specific grammatical categories, such as negations, should fundamentally alter the processing of a phrase.

Figure 4: Dependency parse trees for positive and negative sentences, illustrating the structural input for Recursive models.

Experimental Setup

Models were evaluated on two primary datasets:

  • Webster’s Dictionary: Used for the "reverse dictionary" task. Due to hardware constraints, the core architectural comparison was conducted on a subset of 144 words.
  • Rotten Tomatoes Dataset: Used to evaluate transfer learning and the impact of pretraining on sentiment analysis.

Key Results and Insights

The experimental results on the 144-word subset highlight the advantages of structural models:

  • Structural Efficiency: The Recursive Net with shared weights achieved a Top-3 accuracy of 72.97%, a massive improvement over the baseline LSTM's 29.73%. Notably, the Recursive model used an embedding dimension of only 32, compared to the LSTM's 256.
  • The Impact of Randomization: Interestingly, randomizing word order in the training data improved the LSTM's Top-1 accuracy to 54.05%, matching the best Recursive model.
  • Pretraining as a Regularizer: In transfer learning tests on the Rotten Tomatoes dataset, pretraining on dictionary definitions acted as a powerful regularizer, preventing the extreme overfitting observed in models trained from scratch (reducing training accuracy from 96% to 70% while maintaining test performance).

Limitations and Future Work

The primary limitation of this study is the small sample size used for architectural comparison, necessitated by compute constraints. Additionally, the LSTM's performance may have been impacted by fixed-length padding, which is not required by the dynamic tree structure of Recursive models. Future work will focus on scaling these models to full-sized dictionaries and further investigating the mathematical properties of POS-weighted Recursive architectures.

Summary updated

BibTeX
@misc{bastos2018learning,
  author = {Anson Bastos},
  title = {{Learning sentence embeddings using Recursive Networks}},
  year = {2018},
  eprint = {1805.08353},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1805.08353},
}
Figure