Learning Text Pair Similarity with Context-sensitive Autoencoders

Hadi Amiri, Philip Resnik, Jordan L. Boyd-Graber, Hal Daumé Iii

Abstract

Standard autoencoders often suffer from "tunnel vision," focusing exclusively on local word patterns while ignoring broader sentential or document-level context. This paper introduces Context-sensitive Autoencoders (CSAE), a novel framework that injects global context directly into the learning process. By forcing the model to reconstruct both the input text and its surrounding context, the resulting hidden representations are more semantically robust. CSAE achieves state-of-the-art results in word sense similarity and question-answering tasks, demonstrating significant improvements in both supervised and unsupervised settings.

Introduction

In natural language processing, the meaning of a word or phrase is rarely self-contained. For example, the word "bank" carries distinct meanings depending on whether the context involves finance or a river. While recurrent or recursive neural networks capture some sequence history, they often struggle with long-range dependencies or global thematic information. The challenge lies in effectively "injecting" this external context into a deep learning architecture so that the resulting vector representations are semantically rich and context-aware.

The Context-sensitive Autoencoder (CSAE)

The core innovation of this work is the CSAE architecture, which moves beyond the limitations of basic autoencoders by incorporating a context vector $c_x$ alongside the primary input $x$.

Comparison between a basic autoencoder and the proposed context-sensitive autoencoder.

As shown in the figure above, a standard autoencoder (a) maps an input $x$ to a hidden layer $h$ and attempts to reconstruct $x$. In contrast, the CSAE (b) takes two inputs: the text $x$ and a context vector $c_x$ (derived from neighboring sentences or topic models). The hidden layer $h$ is calculated using both $x$ and a learned representation of the context $h_c$. Crucially, the decoder is tasked with reconstructing both the original text ($\hat{x}$) and the context representation ($\hat{h}_c$). This dual reconstruction objective ensures that the "bottleneck" layer $h$ captures the essential interactions between the text and its environment.

Deep Stacking and Pairwise Similarity

To capture higher-order semantic features, the authors stack these layers as Denoising Autoencoders (DAEs).

The deep stacked CSAE architecture showing the unrolled encoder and decoder layers.

The model utilizes greedy layer-wise pre-training to initialize a deep network, which is then "unrolled" and fine-tuned. To compute similarity between two pieces of text, a Siamese-style architecture is used. Two inputs are fed through identical CSAEs, and the resulting hidden vectors—along with their absolute difference and element-wise product—are used to predict a similarity score.

Experimental Evaluation

The model was evaluated across three distinct semantic tasks:

  • SCWS (Stanford Contextual Word Similarity): Measuring word similarity within sentential contexts.
  • qAns (TREC QA): Ranking single-sentence answers for a given question.
  • qSim (Stack Exchange): Retrieving semantically equivalent questions.

Key Results

The CSAE model consistently outperformed competitive baselines, including specialized Convolutional Neural Networks (CNNs):

  • Contextual Word Similarity: On the SCWS dataset, CSAE achieved a Spearman’s $\rho$ of 70.9, surpassing the previous state-of-the-art of 69.8.
  • Answer Ranking: In the supervised "Train-All" setting for qAns, CSAE reached a Mean Average Precision (MAP) of 72.29, significantly higher than the PCNN baseline of 67.09.
  • Question Ranking: On qSim, the model achieved a P@1 (Precision at Rank 1) of 24.6, beating the PBOW-PCNN joint model (22.3).

Insights and Conclusion

A key finding of this research is that "global" context (e.g., paragraph-level topics) often provides a more significant performance boost than "local" context (e.g., immediate neighboring words). Furthermore, context injection is particularly beneficial for rare topics, where external information acts as a vital guide for the model.

Perhaps most notably, the unsupervised version of the CSAE—which ranks pairs by the cosine similarity of their hidden layers—often performed as well as complex supervised models. This suggests that the CSAE framework is highly effective at learning intrinsic semantic structures by leveraging the natural relationship between text and its context.

Summary updated

BibTeX
@inproceedings{amiri2016learning,
  author = {Hadi Amiri and Philip Resnik and Jordan L. Boyd-Graber and Hal Daumé III},
  title = {{Learning Text Pair Similarity with Context-sensitive Autoencoders}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2016},
  doi = {10.18653/v1/p16-1177},
}
Figure