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

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

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.

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” ins_{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.

Related Work

Non-DL on Sentence Pair Modeling. Sentence pair modeling has attracted lots of attention in the past decades. Many tasks can be reduced to a semantic text matching problem. In this paper, we adopt the arguments by ?) who argue against shallow approaches as well as against semantic text matching approaches that can be computationally expensive:

Due to the variety of word choices and inherent ambiguities in natural language, bag-of-word approaches with simple surface-form word matching tend to produce brittle results with poor prediction accuracy [Bilotti et al., 2007]. As a result, researchers put more emphasis on exploiting syntactic and semantic structure. Representative examples include methods based on deeper semantic analysis [Shen and Lapata, 2007, Moldovan et al., 2007], tree edit-distance [Punyakanok et al., 2004, Heilman and Smith, 2010] and quasi-synchronous grammars [Wang et al., 2007] that match the dependency parse trees of the two sentences.

Instead of focusing on the high-level semantic representation, ?) turn their attention to improving the shallow semantic component, lexical semantics, by performing semantic matching based on a latent word-alignment structure (cf. ?)). ?) explore finer-grained word overlap and alignment between two sentences using negation, hypernym, synonym and antonym relations. ?) extend word-to-word alignment to phrase-to-phrase alignment by a semi-Markov CRF. However, such approaches often require more computational resources. In addition, employing syntactic or semantic parsers – which produce errors on many sentences – to find the best match between the structured representations of two sentences is not trivial.

DL on Sentence Pair Modeling. To address some of the challenges of non-DL work, much recent work uses neural networks to model sentence pairs for AS, PI and TE.

For AS, ?) present a bigram CNN to model question and answer candidates. ?) extend this method and get state-of-the-art performance on the WikiQA dataset (Section 5.1). ?) test various setups of a bi-CNN architecture on an insurance domain QA dataset. ?) explore bidirectional LSTMs on the same dataset. Our approach is different because we do not model the sentences by two independent neural networks in parallel, but instead as an interdependent sentence pair, using attention.

For PI, ?) form sentence representations by summing up word embeddings. ?) use recursive autoencoders (RAEs) to model representations of local phrases in sentences, then pool similarity values of phrases from the two sentences as features for binary classification. ?) similarly replace an RAE with a CNN. In all three papers, the representation of one sentence is not influenced by the other – in contrast to our attention-based model.

For TE, ?) use recursive neural networks to encode entailment on SICK [Marelli et al., 2014b]. ?) present an attention-based LSTM for the Stanford natural language inference corpus [Bowman et al., 2015a]. Our system is the first CNN-based work on TE.

Some prior work aims to solve a general sentence matching problem. ?) present two CNN architectures, ARC-I and ARC-II, for sentence matching. ARC-I focuses on sentence representation learning while ARC-II focuses on matching features on phrase level. Both systems were tested on PI, sentence completion (SC) and tweet-response matching. ?) propose the MultiGranCNN architecture to model general sentence matching based on phrase matching on multiple levels of granularity and get promising results for PI and SC. ?) try to match two sentences in AS and SC by multiple sentence representations, each coming from the local representations of two LSTMs. Our work is the first one to investigate attention for the general sentence matching task.

Attention-Based DL in Non-NLP Domains. Even though there is little if any work on attention mechanisms in CNNs for NLP, attention-based CNNs have been used in computer vision for visual question answering [Chen et al., 2015], image classification [Xiao et al., 2015], caption generation [Xu et al., 2015], image segmentation [Hong et al., 2016] and object localization [Cao et al., 2015].

?) apply attention in recurrent neural networks (RNNs) to extract “information from an image or video by adaptively selecting a sequence of regions or locations and only processing the selected regions at high resolution.” ?) combine a spatial attention mechanism with RNNs for image generation. ?) investigate attention-based RNNs for recognizing multiple objects in images. ?) and ?) use attention in RNNs for speech recognition.

Attention-Based DL in NLP. Attention-based DL systems have been applied to NLP after their success in computer vision and speech recognition. They mainly rely on RNNs and end-to-end encoder-decoders for tasks such as machine translation [Bahdanau et al., 2015, Luong et al., 2015] and text reconstruction [Li et al., 2015, Rush et al., 2015]. Our work takes the lead in exploring attention mechanisms in CNNs for NLP tasks.

BCNN: Basic Bi-CNN

We now introduce our basic (non-attention) CNN that is based on the Siamese architecture [Bromley et al., 1993], i.e., it consists of two weight-sharing CNNs, each processing one of the two sentences, and a final layer that solves the sentence pair task. See Figure 2. We refer to this architecture as the BCNN. The next section will then introduce the ABCNN, an attention architecture that extends the BCNN. Table 1 gives our notational conventions.

In our implementation and also in the mathematical formalization of the model given below, we pad the two sentences to have the same length s=max⁡(s0,s1)s=\max(s_{0},s_{1}). However, in the figures we show different lengths because this gives a better intuition of how the model works.

We now describe the BCNN’s four types of layers: input, convolution, average pooling and output.

Input layer. In the example in the figure, the two input sentences have 5 and 7 words, respectively. Each word is represented as a d0d_{0}-dimensional precomputed word2vec [Mikolov et al., 2013] embedding, d0=300d_{0}=300. As a result, each sentence is represented as a feature map of dimension d0×sd_{0}\times s.

Average pooling layer. Pooling (including min, max, average pooling) is commonly used to extract robust features from convolution. In this paper, we introduce attention weighting as an alternative, but use average pooling as a baseline as follows.

For the output feature map of the last convolution layer, we do column-wise averaging over all columns, denoted as all-ap. This generates a representation vector for each of the two sentences, shown as the top “Average pooling (all-ap)” layer below “Logistic regression” in Figure 2. These two vectors are the basis for the sentence pair decision.

For the output feature map of non-final convolution layers, we do column-wise averaging over windows of ww consecutive columns, denoted as ww-ap; shown as the lower “Average pooling (ww-ap)” layer in Figure 2. For filter width ww, a convolution layer transforms an input feature map of ss columns into a new feature map of s+w−1s+w-1 columns; average pooling transforms this back to ss columns. This architecture supports stacking an arbitrary number of convolution-pooling blocks to extract increasingly abstract features. Input features to the bottom layer are words, input features to the next layer are short phrases and so on. Each level generates more abstract features of higher granularity.

The last layer is an output layer, chosen according to the task; e.g., for binary classification tasks, this layer is logistic regression (see Figure 2). Other types of output layers are introduced below.

We found that in most cases, performance is boosted if we provide the output of all pooling layers as input to the output layer. For each non-final average pooling layer, we perform ww-ap (pooling over windows of ww columns) as described above, but we also perform all-ap (pooling over all columns) and forward the result to the output layer. This improves performance because representations from different layers cover the properties of the sentences at different levels of abstraction and all of these levels can be important for a particular sentence pair.

ABCNN: Attention-Based BCNN

We now describe three architectures based on the BCNN, the ABCNN-1, the ABCNN-2 and the ABCNN-3, that each introduces an attention mechanism for modeling sentence pairs; see Figure 3.

ABCNN-1. The ABCNN-1 (Figure 3(a)) employs an attention feature matrix A\mathbf{A} to influence convolution. Attention features are intended to weight those units of sis_{i} more highly in convolution that are relevant to a unit of s1−is_{1-i} (i∈{0,1}i\in\{0,1\}); we use the term “unit” here to refer to words on the lowest level and to phrases on higher levels of the network. Figure 3(a) shows two unit representation feature maps in red: this part of the ABCNN-1 is the same as in the BCNN (see Figure 2). Each column is the representation of a unit, a word on the lowest level and a phrase on higher levels. We first describe the attention feature matrix A\mathbf{A} informally (layer “Conv input”, middle column, in Figure 3(a)). A\mathbf{A} is generated by matching units of the left representation feature map with units of the right representation feature map such that the attention values of row ii in A\mathbf{A} denote the attention distribution of the ii-th unit of s0s_{0} with respect to s1s_{1}, and the attention values of column jj in A\mathbf{A} denote the attention distribution of the jj-th unit of s1s_{1} with respect to s0s_{0}. A\mathbf{A} can be viewed as a new feature map of s0s_{0} (resp. s1s_{1}) in row (resp. column) direction because each row (resp. column) is a new feature vector of a unit in s0s_{0} (resp. s1s_{1}). Thus, it makes sense to combine this new feature map with the representation feature maps and use both as input to the convolution operation. We achieve this by transforming A\mathbf{A} into the two blue matrices in Figure 3(a) that have the same format as the representation feature maps. As a result, the new input of convolution has two feature maps for each sentence (shown in red and blue). Our motivation is that the attention feature map will guide the convolution to learn “counterpart-biased” sentence representations.

More formally, let Fi,r∈Rd×s\mathbf{F}_{i,r}\in\mathbf{R}^{d\times s} be the representation feature map of sentence ii (i∈{0,1}i\in\{0,1\}). Then we define the attention matrix A∈Rs×s\mathbf{A}\in\mathbf{R}^{s\times s} as follows:

The function match-score can be defined in a variety of ways. We found that 1/(1+∣x−y∣)1/(1+|x-y|) works well where ∣⋅∣|\cdot| is Euclidean distance.

Given attention matrix A\mathbf{A}, we generate the attention feature map Fi,a\mathbf{F}_{i,a} for sis_{i} as follows:

The weight matrices W0∈Rd×s\mathbf{W}_{0}\in\mathbf{R}^{d\times s}, W1∈Rd×s\mathbf{W}_{1}\in\mathbf{R}^{d\times s} are parameters of the model to be learned in training.The weights of the two matrices are shared in our implementation to reduce the number of parameters of the model.

We stack the representation feature map Fi,r\mathbf{F}_{i,r} and the attention feature map Fi,a\mathbf{F}_{i,a} as an order 3 tensor and feed it into convolution to generate a higher-level representation feature map for sis_{i} (i∈{0,1}i\in\{0,1\}). In Figure 3(a), s0s_{0} has 5 units, s1s_{1} has 7. The output of convolution (shown in the top layer, filter width w=3w=3) is a higher-level representation feature map with 7 columns for s0s_{0} and 9 columns for s1s_{1}.

ABCNN-2. The ABCNN-1 computes attention weights directly on the input representation with the aim of improving the features computed by convolution. The ABCNN-2 (Figure 3(b)) instead computes attention weights on the output of convolution with the aim of reweighting this convolution output. In the example shown in Figure 3(b), the feature maps output by convolution for s0s_{0} and s1s_{1} (layer marked “Convolution” in Figure 3(b)) have 7 and 9 columns, respectively; each column is the representation of a unit. The attention matrix A\mathbf{A} compares all units in s0s_{0} with all units of s1s_{1}. We sum all attention values for a unit to derive a single attention weight for that unit. This corresponds to summing all values in a row of A\mathbf{A} for s0s_{0} (“col-wise sum”, resulting in the column vector of size 7 shown) and summing all values in a column for s1s_{1} (“row-wise sum”, resulting in the row vector of size 9 shown).

More formally, let A∈Rs×s\mathbf{A}\in\mathbf{R}^{s\times s} be the attention matrix, a0,j=∑A[j,:]a_{0,j}=\sum\mathbf{A}[j,:] the attention weight of unit jj in s0s_{0}, a1,j=∑A[:,j]a_{1,j}=\sum\mathbf{A}[:,j] the attention weight of unit jj in s1s_{1} and Fi,rc∈Rd×(si+w−1)\mathbf{F}^{c}_{i,r}\in\mathbf{R}^{d\times(s_{i}+w-1)} the output of convolution for sis_{i}. Then the jj-th column of the new feature map Fi,rp\mathbf{F}^{p}_{i,r} generated by ww-ap is derived by:

Note that Fi,rp∈Rd×si\mathbf{F}^{p}_{i,r}\in\mathbf{R}^{d\times s_{i}}, i.e., ABCNN-2 pooling generates an output feature map of the same size as the input feature map of convolution. This allows us to stack multiple convolution-pooling blocks to extract features of increasing abstraction.

There are three main differences between the ABCNN-1 and the ABCNN-2. (i) Attention in the ABCNN-1 impacts convolution indirectly while attention in the ABCNN-2 influences pooling through direct attention weighting. (ii) The ABCNN-1 requires the two matrices Wi\mathbf{W}_{i} to convert the attention matrix into attention feature maps; and the input to convolution has two times as many feature maps. Thus, the ABCNN-1 has more parameters than the ABCNN-2 and is more vulnerable to overfitting. (iii) As pooling is performed after convolution, pooling handles larger-granularity units than convolution; e.g., if the input to convolution has word level granularity, then the input to pooling has phrase level granularity, the phrase size being equal to filter size ww. Thus, the ABCNN-1 and the ABCNN-2 implement attention mechanisms for linguistic units of different granularity. The complementarity of the ABCNN-1 and the ABCNN-2 motivates us to propose the ABCNN-3, a third architecture that combines elements of the two.

ABCNN-3 (Figure 3(c)) combines the ABCNN-1 and the ABCNN-2 by stacking them; it combines the strengths of the ABCNN-1 and -2 by allowing the attention mechanism to operate (i) both on the convolution and on the pooling parts of a convolution-pooling block and (ii) both on the input granularity and on the more abstract output granularity.

Experiments

We test the proposed architectures on three tasks: answer selection (AS), paraphrase identification (PI) and textual entailment (TE).

Common Training Setup. Words are initialized by 300-dimensional word2vec embeddings and not changed during training. A single randomly initialized embedding is created for all unknown words by uniform sampling from [-.01,.01]. We employ Adagrad [Duchi et al., 2011] and L2L_{2} regularization.

Network Configuration. Each network in the experiments below consists of (i) an initialization block b1b_{1} that initializes words by word2vec embeddings, (ii) a stack of k−1k-1 convolution-pooling blocks b2,…,bkb_{2},\ldots,b_{k}, computing increasingly abstract features, and (iii) one final LR layer (logistic regression layer) as shown in Figure 2.

The input to the LR layer consists of knkn features – each block provides nn similarity scores, e.g., nn cosine similarity scores. Figure 2 shows the two sentence vectors output by the final block bkb_{k} of the stack (“sentence representation 0”, “sentence representation 1”); this is the basis of the last nn similarity scores. As we explained in the final paragraph of Section 3, we perform all-ap pooling for all blocks, not just for bkb_{k}. Thus we get one sentence representation each for s0s_{0} and s1s_{1} for each block b1,…,bkb_{1},\ldots,b_{k}. We compute nn similarity scores for each block (based on the block’s two sentence representations). Thus, we compute a total of knkn similarity scores and these scores are input to the LR layer.

Depending on the task, we use different methods for computing the similarity score: see below.

Layerwise Training. In our training regime, we first train a network consisting of just one convolution-pooling block b2b_{2}. We then create a new network by adding a block b3b_{3}, initialize its b2b_{2} block with the previously learned weights for b2b_{2} and train b3b_{3} keeping the previously learned weights for b2b_{2} fixed. We repeat this procedure until all k−1k-1 convolution-pooling blocks are trained. We found that this training regime gives us good performance and shortens training times considerably. Since similarity scores of lower blocks are kept unchanged once they have been learned, this also has the nice effect that “simple” similarity scores (those based on surface features) are learned first and subsequent training phases can focus on complementary scores derived from more complex abstract features.

Classifier. We found that performance increases if we do not use the output of the LR layer as the final decision, but instead train a linear SVM or a logistic regression with default parameters http://scikit-learn.org/stable/ for both. directly on the input to the LR layer (i.e., on the knkn similarity scores that are generated by the kk-block stack after network training is completed). Direct training of SVMs/LR seems to get closer to the global optimum than gradient descent training of CNNs.

Table 2 shows hyperparameters, tuned on dev.

We use addition and LSTMs as two shared baselines for all three tasks, i.e., for AS, PI and TE. We now describe these two shared baselines.

(i) Addition. We sum up word embeddings element-wise to form each sentence representation. The classifier input is then the concatenation of the two sentence representations. (ii) A-LSTM. Before this work, most attention mechanisms in NLP were implemented in recurrent neural networks for text generation tasks such as machine translation (e.g., ?), ?)). ?) present an attention-LSTM for natural language inference. Since this model is the pioneering attention based RNN system for sentence pair classification, we consider it as a baseline system (“A-LSTM”) for all our three tasks. The A-LSTM has the same configuration as our ABCNNs in terms of word initialization (300-dimensional word2vec embeddings) and the dimensionality of all hidden layers (50).

We use WikiQA,http://aka.ms/WikiQA [Yang et al., 2015] an open domain question-answer dataset. We use the subtask that assumes that there is at least one correct answer for a question. The corresponding dataset consists of 20,360 question-candidate pairs in train, 1,130 pairs in dev and 2,352 pairs in test where we adopt the standard setup of only considering questions with correct answers in test. Following ?), we truncate answers to 40 tokens.

The task is to rank the candidate answers based on their relatedness to the question. Evaluation measures are mean average precision (MAP) and mean reciprocal rank (MRR).

Task-Specific Setup. We use cosine similarity as the similarity score for AS. In addition, we use sentence lengths, WordCnt (count of the number of non-stopwords in the question that also occur in the answer) and WgtWordCnt (reweight the counts by the IDF values of the question words). Thus, the final input to the LR layer has size k+4k+4: one cosine for each of the kk blocks and the four additional features.

We compare with seven baselines. The first three are considered by ?): (i) WordCnt; (ii) WgtWordCnt; (iii) CNN-Cnt (the state-of-the-art system): combine CNN with (i) and (ii). Apart from the baselines considered by ?), we compare with two Addition baselines and two LSTM baselines. Addition and A-LSTM are the shared baselines described before. We also combine both with the four extra features; this gives us two additional baselines that we refer to as Addition(+) and A-LSTM(+).

Results. Table 3 shows performance of the baselines, of the BCNN and of the three ABCNNs. For CNNs, we test one (one-conv) and two (two-conv) convolution-pooling blocks.

The non-attention network BCNN already performs better than the baselines. If we add attention mechanisms, then the performance further improves by several points. Comparing the ABCNN-2 with the ABCNN-1, we find the ABCNN-2 is slightly better even though the ABCNN-2 is the simpler architecture. If we combine the ABCNN-1 and the ABCNN-2 to form the ABCNN-3, we get further improvement.If we limit the input to the LR layer to the kk similarity scores in the ABCNN-3 (two-conv), results are .660 (MAP) / .677 (MRR).

This can be explained by the ABCNN-3’s ability to take attention of finer-grained granularity into consideration in each convolution-pooling block while the ABCNN-1 and the ABCNN-2 consider attention only at convolution input or only at pooling input, respectively. We also find that stacking two convolution-pooling blocks does not bring consistent improvement and therefore do not test deeper architectures.

2 Paraphrase Identification

We use the Microsoft Research Paraphrase (MSRP) corpus [Dolan et al., 2004]. The training set contains 2753 true / 1323 false and the test set 1147 true / 578 false paraphrase pairs. We randomly select 400 pairs from train and use them as dev; but we still report results for training on the entire training set. For each triple (label, s0s_{0}, s1s_{1}) in the training set, we also add (label, s1s_{1}, s0s_{0}) to the training set to make best use of the training data. Systems are evaluated by accuracy and F1F_{1}.

Task-Specific Setup. In this task, we add the 15 MT features from [Madnani et al., 2012] and the lengths of the two sentences. In addition, we compute ROUGE-1, ROUGE-2 and ROUGE-SU4 [Lin, 2004], which are scores measuring the match between the two sentences on (i) unigrams, (ii) bigrams and (iii) unigrams and skip-bigrams (maximum skip distance of four), respectively. In this task, we found transforming Euclidean distance into similarity score by 1/(1+∣x−y∣)1/(1+|x-y|) performs better than cosine similarity. Additionally, we use dynamic pooling [Yin and Schütze, 2015a] of the attention matrix A\mathbf{A} in Equation (1) and forward pooled values of all blocks to the classifier. This gives us better performance than only forwarding sentence-level matching features.

We compare our system with representative DL approaches: (i) A-LSTM; (ii) A-LSTM(+): A-LSTM plus handcrafted features; (iii) RAE [Socher et al., 2011], recursive autoencoder; (iv) Bi-CNN-MI [Yin and Schütze, 2015a], a bi-CNN architecture; and (v) MPSSM-CNN [He et al., 2015], the state-of-the-art NN system for PI, and the following four non-DL systems: (vi) Addition; (vii) Addition(+): Addition plus handcrafted features; (viii) MT [Madnani et al., 2012], a system that combines machine translation metrics;For better comparability of approaches in our experiments, we use a simple SVM classifier, which performs slightly worse than ?)’s more complex meta-classifier. (ix) MF-TF-KLD [Ji and Eisenstein, 2013], the state-of-the-art non-NN system.

Results. Table 4 shows that the BCNN is slightly worse than the state-of-the-art whereas the ABCNN-1 roughly matches it. The ABCNN-2 is slightly above the state-of-the-art. The ABCNN-3 outperforms the state-of-the-art in accuracy and F1F_{1}.Improvement of .3 (acc) and .1 (F1F_{1}) over state-of-the-art is not significant. The ABCNN-3 (two-conv) without “linguistic” features (i.e., MT and ROUGE) achieves 75.1/82.7. Two convolution layers only bring small improvements over one.

3 Textual Entailment

SemEval 2014 Task 1 [Marelli et al., 2014a] evaluates system predictions of textual entailment (TE) relations on sentence pairs from the SICK dataset [Marelli et al., 2014b]. The three classes are entailment, contradiction and neutral. The sizes of SICK train, dev and test sets are 4439, 495 and 4906 pairs, respectively. We call this dataset ORIG.

We also create NONOVER, a copy of ORIG in which words occurring in both sentences are removed. A sentence in NONOVER is denoted by the special token <<empty>> if all words are removed. Table 5 shows three pairs from ORIG and their transformation in NONOVER. We observe that focusing on the non-overlapping parts provides clearer hints for TE than ORIG. In this task, we run two copies of each network, one for ORIG, one for NONOVER; these two networks have a single common LR layer.

Like ?), we train our final system (after fixing hyperparameters) on train and dev (4934 pairs). Eval measure is accuracy.

Task-Specific Setup. We found that for this task forwarding two similarity scores from each block (instead of just one) is helpful. We use cosine similarity and Euclidean distance. As we did for paraphrase identification, we add the 15 MT features for each sentence pair for this task as well; our motivation is that entailed sentences resemble paraphrases more than contradictory sentences do.

We use the following linguistic features. Negation is important for detecting contradiction. Feature neg is set to 11 if either sentence contains “no”, “not”, “nobody”, “isn’t” and to otherwise. Following ?), we use WordNet [Miller, 1995] to detect nyms: synonyms, hypernyms and antonyms in the pairs. But we do this on NONOVER (not on ORIG) to focus on what is critical for TE. Specifically, feature syn is the number of word pairs in s0s_{0} and s1s_{1} that are synonyms. hyp0 (resp. hyp1) is the number of words in s0s_{0} (resp. s1s_{1}) that have a hypernym in s1s_{1} (resp. s0s_{0}). In addition, we collect all potential antonym pairs (PAP) in NONOVER. We identify the matched chunks that occur in contradictory and neutral, but not in entailed pairs. We exclude synonyms and hypernyms and apply a frequency filter of n=2n=2. In contrast to ?), we constrain the PAP pairs to cosine similarity above 0.4 in word2vec embedding space as this discards many noise pairs. Feature ant is the number of matched PAP antonyms in a sentence pair. As before we use sentence lengths, both for ORIG (len0o: length s0s_{0}, len1o: length s1s_{1}) and for NONOVER (len0n: length s0s_{0}, len1n: length s1s_{1}).

On the whole, we have 24 extra features: 15 MT metrics, neg, syn, hyp0, hyp1, ant, len0o, len1o, len0n and len1n.

Apart from the Addition and LSTM baselines, we further compare with the top-3 systems in SemEval and TrRNTN [Bowman et al., 2015b], a recursive neural network developed for this SICK task.

Results. Table 6 shows that our CNNs outperform A-LSTM (with or without linguistic features added) and the top three SemEval systems. Comparing ABCNNs with the BCNN, attention mechanisms consistently improve performance. The ABCNN-1 has performance comparable to the ABCNN-2 while the ABCNN-3 is better still: a boost of 1.6 points compared to the previous state of the art.If we run the ABCNN-3 (two-conv) without the 24 linguistic features, performance is 84.6.

Visual Analysis. Figure 4 visualizes the attention matrices for one TE sentence pair in the ABCNN-2 for blocks b1b_{1} (unigrams), b2b_{2} (first convolutional layer) and b3b_{3} (second convolutional layer). Darker shades of blue indicate stronger attention values.

In Figure 4 (top), each word corresponds to exactly one row or column. We can see that words in sis_{i} with semantic equivalents in s1−is_{1-i} get high attention while words without semantic equivalents get low attention, e.g., “walking” and “murals” in s0s_{0} and “front” and “colorful” in s1s_{1}. This behavior seems reasonable for the unigram level.

Rows/columns of the attention matrix in Figure 4 (middle) correspond to phrases of length three since filter width w=3w=3. High attention values generally correlate with close semantic correspondence: the phrase “people are” in s0s_{0} matches “several people are” in s1s_{1}; both “are walking outside” and “walking outside the” in s0s_{0} match “are in front” in s1s_{1}; “the building that” in s0s_{0} matches “a colorful building” in s1s_{1}. More interestingly, looking at the bottom right corner, both “on it” and “it” in s0s_{0} match “building” in s1s_{1}; this indicates that ABCNNs are able to detect some coreference across sentences. “building” in s1s_{1} has two places in which higher attentions appear, one is with “it” in s0s_{0}, the other is with “the building that” in s0s_{0}. This may indicate that ABCNNs recognize that “building” in s1s_{1} and “the building that” / “it” in s0s_{0} refer to the same object. Hence, coreference resolution across sentences as well as within a sentence both are detected. For the attention vectors on the left and the top, we can see that attention has focused on the key parts: “people are walking outside the building that” in s0s_{0}, “several people are in” and “of a colorful building” in s1s_{1}.

Rows/columns of the attention matrix in Figure 4 (bottom, second layer of convolution) correspond to phrases of length 5 since filter width w=3w=3 in both convolution layers (5=1+2∗(3−1)5=1+2*(3-1)). We use “…\ldots” to denote words in the middle if a phrase like “several…front” has more than two words. We can see that attention distribution in the matrix has focused on some local regions. As granularity of phrases is larger, it makes sense that the attention values are smoother. But we still can find some interesting clues: at the two ends of the main diagonal, higher attentions hint that the first part of s0s_{0} matches well with the first part of s1s_{1}; “several murals on it” in s0s_{0} matches well with “of a colorful building” in s1s_{1}, which satisfies the intuition that these two phrases are crucial for making a decision on TE in this case. This again shows the potential strength of our system in figuring out which parts of the two sentences refer to the same object. In addition, in the central part of the matrix, we can see that the long phrase “people are walking outside the building” in s0s_{0} matches well with the long phrase “are in front of a colorful building” in s1s_{1}.

Summary

We presented three mechanisms to integrate attention into CNNs for general sentence pair modeling tasks.

Our experiments on AS, PI and TE show that attention-based CNNs perform better than CNNs without attention mechanisms. The ABCNN-2 generally outperforms the ABCNN-1 and the ABCNN-3 surpasses both.

In all tasks, we did not find any big improvement of two layers of convolution over one layer. This is probably due to the limited size of training data. We expect that, as larger training sets become available, deep ABCNNs will show even better performance.

In addition, linguistic features contribute in all three tasks: improvements by 0.0321 (MAP) and 0.0338 (MRR) for AS, improvements by 3.8 (acc) and 2.1 (F1F_{1}) for PI and an improvement by 1.6 (acc) for TE. But our ABCNNs can still reach or surpass state-of-the-art even without those features in AS and TE tasks. This indicates that ABCNNs are generally strong NN systems.

Attention-based LSTMs are especially successful in tasks with a strong generation component like machine translation (discussed in Sec. 2). CNNs have not been used for this type of task. This is an interesting area of future work for attention-based CNNs.

We gratefully acknowledge the support of Deutsche Forschungsgemeinschaft (DFG): grant SCHU 2246/8-2.

We would like to thank the anonymous reviewers for their helpful comments.

References