arXiv:1512.05193Computer ScienceDec 2015

Manuscript Offprint

arXiv:1512.05193

ABCNN: Attention-Based Convolutional Neural Network for Modeling Sentence Pairs

Wenpeng Yin, Hinrich Schütze, Bing Xiang, Bowen Zhou

Abstract

How to model a pair of sentences is a critical issue in many NLP tasks such as answer selection (AS), paraphrase identification (PI) and textual entailment (TE). Most prior work (i) deals with one individual task by fine-tuning a specific system; (ii) models each sentence’s representation separately, rarely considering the impact of the other sentence; or (iii) relies fully on manually designed, task-specific linguistic features. This work presents a general Attention Based Convolutional Neural Network (ABCNN) for modeling a pair of sentences. We make three contributions. (i) The ABCNN can be applied to a wide variety of tasks that require modeling of sentence pairs. (ii) We propose three attention schemes that integrate mutual influence between sentences into CNNs; thus, the representation of each sentence takes into consideration its counterpart. These interdependent sentence pair representations are more powerful than isolated sentence representations. (iii) ABCNNs achieve state-of-the-art performance on AS, PI and TE tasks. We release code at: https://github.com/yinwenpeng/Answer_Selection.

1 Introduction

How to model a pair of sentences is a critical issue in many NLP tasks such as answer selection (AS) [Yu et al. (2014, Feng et al. (2015], paraphrase identification (PI) [Madnani et al. (2012, Yin and Schütze (2015a], textual entailment (TE) [Marelli et al. (2014a, Bowman et al. (2015a] etc.

Most prior work derives each sentence’s representation separately, rarely considering the impact of the other sentence. This neglects the mutual influence of the two sentences in the context of the task. It also contradicts what humans do when comparing two sentences. We usually focus on key parts of one sentence by extracting parts from the other sentence that are related by identity, synonymy, antonymy and other relations. Thus, human beings model the two sentences together, using the content of one sentence to guide the representation of the other.

ASs0\mathbf{s_{0}}how much did Waterboy gross?
s1+\mathbf{s}_{1}^{+}the movie earned $161.5 million
s1−\mathbf{s}_{1}^{-}this was Jerry Reed’s final film appearance
PIs0\mathbf{s_{0}}she struck a deal with RH to pen a book today
s1+\mathbf{s}_{1}^{+}she signed a contract with RH to write a book
s1−\mathbf{s}_{1}^{-}she denied today that she struck a deal with RH
TEs0\mathbf{s_{0}}an ice skating rink placed outdoors is full of people
s1+\mathbf{s}_{1}^{+}a lot of people are in an ice skating park
s1−\mathbf{s}_{1}^{-}an ice skating rink placed indoors is full of people

Figure 1: Positive (< ⁣s0,s1+ ⁣><\!s_{0},s_{1}^{+}\!>) and negative (< ⁣s0,s1− ⁣><\!s_{0},s_{1}^{-}\!>) examples for AS, PI and TE tasks. RH = Random House

Figure 1 demonstrates that each sentence of a pair partially determines which parts of the other sentence we must focus on. For AS, correctly answering s0s_{0} requires attention on “gross”: s1+s_{1}^{+} contains a corresponding unit (“earned”) while s1−s_{1}^{-} does not. For PI, focus should be removed from “today” to correctly recognize < ⁣s0,s1+ ⁣><\!s_{0},s_{1}^{+}\!> as paraphrases and < ⁣s0,s1− ⁣><\!s_{0},s_{1}^{-}\!> as non-paraphrases. For TE, we need to focus on “full of people” (to recognize TE for < ⁣s0,s1+ ⁣><\!s_{0},s_{1}^{+}\!>) and on “outdoors” / “indoors” (to recognize non-TE for < ⁣s0,s1− ⁣><\!s_{0},s_{1}^{-}\!>). These examples show the need for an architecture that computes different representations of sis_{i} for different s1−is_{1-i} (i∈{0,1}i\in\{0,1\}).

Convolutional Neural Networks (CNNs) [LeCun et al. (1998] are widely used to model sentences [Kalchbrenner et al. (2014, Kim (2014] and sentence pairs [Socher et al. (2011, Yin and Schütze (2015a], especially in classification tasks. CNNs are supposed to be good at extracting robust and abstract features of input. This work presents the ABCNN, an attention-based convolutional neural network, that has a powerful mechanism for modeling a sentence pair by taking into account the interdependence between the two sentences. The ABCNN is a general architecture that can handle a wide variety of sentence pair modeling tasks.

Some prior work proposes simple mechanisms that can be interpreted as controlling varying attention; e.g., ?) employ word alignment to match related parts of the two sentences. In contrast, our attention scheme based on CNNs models relatedness between two parts fully automatically. Moreover, attention at multiple levels of granularity, not only at word level, is achieved as we stack multiple convolution layers that increase abstraction.

Prior work on attention in deep learning (DL) mostly addresses long short-term memory networks (LSTMs) [Hochreiter and Schmidhuber (1997]. LSTMs achieve attention usually in a word-to-word scheme, and word representations mostly encode the whole context within the sentence [Bahdanau et al. (2015, Rocktäschel et al. (2016]. It is not clear whether this is the best strategy; e.g., in the AS example in Figure 1, it is possible to determine that “how much” in s0s_{0} matches “161.5million”in161.5 million” in s_{1}$ without taking the entire sentence contexts into account. This observation was also investigated by ?) where an information retrieval system retrieves sentences with tokens labeled as DATE by named entity recognition or as CD by POS tagging if there is a “when” question. However, labels or POS tags require extra tools. CNNs benefit from incorporating attention into representations of local phrases detected by filters; in contrast, LSTMs encode the whole context to form attention-based word representations – a strategy that is more complex than the CNN strategy and (as our experiments suggest) performs less well for some tasks.

Apart from these differences, it is clear that attention has as much potential for CNNs as it does for LSTMs. As far as we know, this is the first NLP paper that incorporates attention into CNNs. Our ABCNNs get state-of-the-art in AS and TE tasks, and competitive performance in PI, then obtains further improvements over all three tasks when linguistic features are used.