Recurrent Neural Network-Based Sentence Encoder with Gated Attention for Natural Language Inference

Qian Chen, Xiaodan Zhu, Zhen-Hua Ling, Si Wei, Hui Jiang, Diana Inkpen

Introduction

Natural Language Inference (NLI), also known as Recognizing Textual Entailment (RTE), is a core challenge in natural language processing. It involves determining whether a hypothesis sentence is entailed by, contradicts, or is neutral with respect to a premise sentence. While many state-of-the-art models rely on complex cross-sentence attention mechanisms that align words between the two sentences, these models fail to produce a standalone semantic representation for a single sentence.

The RepEval 2017 Shared Task specifically addressed this by challenging researchers to develop models that encode sentences into fixed-length vectors. Such representations are highly desirable for large-scale sentence retrieval and efficient downstream processing. This paper introduces a novel sentence encoder that leverages the internal gating mechanisms of a Bidirectional Long Short-Term Memory (BiLSTM) network to perform intra-sentence attention, achieving superior performance without the overhead of cross-sentence alignment.

Model Architecture

The proposed architecture is structured into four primary stages, designed to capture both local character-level nuances and global sentence-level context.

The Gated-Attention BiLSTM architecture, illustrating the flow from word/character embeddings through stacked BiLSTMs to the gated-attention composition layer.
  1. Word Embedding Layer: To ensure robustness against rare words and typos, the model uses a dual-level embedding strategy. It concatenates 300-dimensional pre-trained GloVe vectors with character-level embeddings generated by a Convolutional Neural Network (CNN). This hybrid approach allows the model to capture both semantic meaning and morphological structure.
  2. Sequence Encoder: The core encoding is performed by a 3-layer Stacked BiLSTM. To mitigate the vanishing gradient problem and ensure that low-level features are not lost in deeper layers, the authors implement shortcut connections. These connections concatenate the input of each BiLSTM layer to its output, providing the subsequent layer with a richer set of features.
  3. Gated-Attention Composition Layer: Traditional sentence encoders often use simple max-pooling or average-pooling to collapse a sequence of hidden states into a single vector. This paper proposes a more sophisticated "Gated-Attention" mechanism. It repurposes the BiLSTM's internal gates—specifically the Input, Forget, or Output gates—as attention weights. By doing so, the model "attends" to the most informative words in the sequence based on the logic already learned by the LSTM cells.
  4. Top-layer Classifier: After encoding the premise ($v^p$) and hypothesis ($v^h$), the model constructs a joint representation. Following standard heuristics, it concatenates the two vectors, their absolute difference ($|v^p - v^h|$), and their element-wise product ($v^p \odot v^h$). This comprehensive feature vector is then passed through a Multi-Layer Perceptron (MLP) for final classification.

Gated-Attention Composition

The primary innovation of this work is the efficient use of existing LSTM gates for attention. This intra-sentence gated-attention is computationally efficient because it does not require the calculation of a separate attention matrix. Through ablation studies on the MultiNLI dataset, the researchers found that using the Input Gate as the weighting factor yielded the best results. This suggests that the information the LSTM decides to "let in" to its memory is a strong proxy for word importance in the context of the whole sentence.

Experimental Results

The model was rigorously tested on two major benchmarks: the Stanford Natural Language Inference (SNLI) dataset and the Multi-Genre Natural Language Inference (MultiNLI) dataset.

Comparison of the Gated-Att BiLSTM against other sentence-encoder models on the SNLI test set.

On the SNLI test set, the Gated-Attention BiLSTM achieved an accuracy of 85.5%, setting a new state-of-the-art for sentence-encoder models at the time of publication. It notably outperformed the Neural Semantic Encoder (NSE), which previously held the record at 84.6%.

In the RepEval 2017 Shared Task using MultiNLI, the model's ensemble version reached 74.9% accuracy, placing it at the top of the competition. A key observation was the model's consistency; it achieved identical accuracy on both "in-domain" and "cross-domain" test sets. This indicates that the gated-attention mechanism helps the model learn universal linguistic patterns that generalize well across different genres of text.

Conclusion

While the Gated-Attention BiLSTM significantly narrowed the gap between sentence encoders and cross-sentence attention models, a performance difference remains. Models like ESIM, which use cross-sentence attention, still achieve higher raw accuracy (e.g., 76.8% on MultiNLI). This suggests that the fixed-length vector constraint, while useful for efficiency, still acts as an information bottleneck. Future research directions include the integration of external knowledge bases like WordNet to better handle lexical relationships and the exploration of more specialized embeddings to improve the detection of subtle contradictions.

Summary updated

BibTeX
@inproceedings{chen2017recurrent,
  author = {Qian Chen and Xiaodan Zhu and Zhen-Hua Ling and Si Wei and Hui Jiang and Diana Inkpen},
  title = {{Recurrent Neural Network-Based Sentence Encoder with Gated Attention for Natural Language Inference}},
  booktitle = {RepEval @ EMNLP},
  year = {2017},
  doi = {10.18653/v1/w17-5307},
}
Figure