<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Model for Sentence Pair Matching with Self-Attention</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Yongkang Liu</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Xiaobo Liang</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Feiliang Ren</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yan Li</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yining Hou</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yi Zhang</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Lingfeng Pan</string-name>
        </contrib>
      </contrib-group>
      <abstract>
        <p>Sentence pair matching is one of the most basic tasks in natural language processing and is receiving extensive research attention. Most of existing models can be categorized into sentence interaction-based models and sentence encoding-based models. Here we propose a new enhanced ESIM model that could take full advantage of both these two kinds of methods. Specifically, our method can obtain the common information of a sentence pair as the sentence interaction-based models do, and can also extract the key information of a sentence pair itself as the sentence encoding-based models do. Besides, our method also uses Siamese networks to learn a unique structure to naturally rank the similarity between two sentences, which reduces both the model complexity and the size of parameters. With the proposed method, we participated in the task-3 of CCKS2018, which is called as WeBank Intelligent Customer Service Question Match. Finally, our method ranks the first among the hugely competitive models.</p>
      </abstract>
      <kwd-group>
        <kwd>Sentence pair matching</kwd>
        <kwd>Neural Network</kwd>
        <kwd>Self-Attention</kwd>
        <kwd>Siamese nets</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p> Equal contribution. Listing order is random.</p>
      <p>Sentence pair matching is a task that aims to determine whether two given sentences
have a specific relationship. The core of this task is to judge whether two given
sentences have equal or similar intent. It usually could be viewed as a binary
classification task with a label set is {1,0}, in which 1 means the two given sentences
have equal or similar intent and 0 means the two given sentences don’t have equal or
similar intent. Table 1 shows a concrete example of the sentence pair matching task.
一般几天能通过审核(Generally, how 一般审核通过要多久(Generally, how 1
long can I pass the review?) long does it take for the review to pass.)
一般会在什么时候来电话(When will 一直在等待电话通知(I have been 0
the phone usually arrive?) waiting for a phone call.)</p>
      <p>Sentence pair matching is one of the most basic tasks in natural language
processing (NLP). A high performance sentence pair matching system would benefit
lots of other NLP tasks such as Q&amp;A, Chatterbot, information retrieval, machine
translation, and so on.</p>
      <p>Recently, due to the dataset released by Stanford, more and more research attention
has been paid to the text entailment task, which is to predict a relation y∈Y for a
given pair of sentences based on their semantic, where Y = {entailment, contradiction,
neutral}. It is very naturally to view the sentence pair matching task as a specific case
of the textual entailment task because both of them determine the relationship
between sentence pairs. Therefore, most of the existing textual entailment models can
be applied to the sentence pair matching task after some necessary but simple
modifications.</p>
      <p>For text entailment task, many excellent models have been proposed and achieved
good experimental results. For example, Gong et al [2017] design DIIN (Densely
Iterative Inference Network) model [1], Wang et al [2017] propose BIMPM (bilateral
multi-perspective matching) model [2], Ling et al propose ESIM model [3], Duan et
al. [2018] present AF-DMN model, etc.</p>
      <p>However, most of these existing methods map two sentences into different vector
spaces. Intuitively, it would make more sense that two sentences should be mapped
into the same vector space in order to extract sentences’ semantic similarity
information.</p>
      <p>Moreover, we find that all of these existing models focus on the interaction
between sentences, but pay little attention to the semantic information of the
sentences themselves.</p>
      <p>To address these issues, we propose an enhanced ESIM Model that uses siamese
nets [5] to map sentences into ONE vector space. By a parameter share mechanism,
our new model reduces the size of parameters. Besides, we also introduce a
self-attention mechanism in our model to tackle the long-term dependency issue in
long sentences and further enhance the extraction of intra-sentence information.</p>
      <p>Based on the proposed method, we participated in the task-3 of CCKS2018 (2018
China Conference on Knowledge Graph and Semantic Computing), which is called as
WeBank Intelligent Customer Service Question Match. And our method ranks the first
among the hugely competitive models.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related work</title>
      <p>Sentence pair matching is of great value for many NLP tasks and has received wide
attention across academia and industry. According to whether there is an interaction
between sentences, we can divide existing sentence pair matching methods into
sentence interaction-based methods and sentence encoding-based methods.</p>
      <p>Sentence interaction-based methods usually focus on the interaction information
between sentence pairs. This kind of methods usually consist of three components: (1)
an encoder layer that converts two sentences into their semantic representations, and
LSTM is widely used in this layer; (2) an interaction layer that is responsible for
linking and fusing information between the two sentences and generate new
representations for the two sentences; (3) a prediction layer that predicts the relation
of the input sentence pair. Lots of sentence pair matching methods belong to this
category. For example, Gong et al [2017] design Densely Iterative Inference Network
[1] that is able to achieve high-level understanding of a sentence pair by hierarchically
extracting semantic features from an interaction space. This method pushes the
multi-head attention to an extreme by building a word-word dimension-wise
alignment tensor. Wang et al [2017] propose a bilateral multi-perspective matching
(BiMPM) model that matches two encoded sentences using BiLSTM. In this method,
a word of one sentence will be matched against all words of the other sentence from
multiple perspectives [2]. Ling et al [2017] propose a sequential model named ESIM,
which enhances the local inference information by computing the difference and the
element-wise product for a sentences pair [3].</p>
      <p>Sentence encoding-based models pay more attention on sentences’ own
information than their interactions information. Usually, this kind of methods also
consists of three components: (1) an encoder layer that converts two sentences into
their semantic representations; (2) a matching layer that aligns the information
between the two sentences at word level and produces new representations for the two
sentences; (3) a prediction layer that predicts the relation of the input sentence pair.
There are many sentence pair matching methods belong to this category. For example,
Liu et al [2016] propose a sentence encoding-based model that encodes a sentence
with a two-stage process [6]. Conneau et al [2016] show how universal sentence
representations trained using the supervised Stanford Natural Language Inference
datasets can consistently outperform unsupervised methods [7].</p>
      <p>In our method, we merge above two kinds of models together and enhance the
ESIM model by introducing a self-attention mechanism. Besides, we also use the
siamese structure in our model.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Model</title>
      <p>We denote two input sentences as wa  (w1, w2 ,...wla ) and wb  (w1, w2 ,...wlb ) , where
wa is the first sentence and wb is the second sentence. The goal of our model is to
predict a label y that indicates whether wa and wb have equal or similar intent. Here
we will introduce data preprocessing first. Then, we will introduce our sentence pair
matching model in detail.</p>
      <sec id="sec-3-1">
        <title>3.1 Data Preprocessing</title>
        <p>In our paper, data preprocessing consists of three parts: wrong words modification,
synonym substitution and word segmentation.</p>
        <p>Due to colloquial expressions in a dataset, there may be lots of wrong words which
will affect the accuracy of the word segmentation. We use a custom vocabulary for
wrong words modification.</p>
        <p>For synonym substitution, we also use a custom synonym vocabulary. Besides,
there are usually lots of unknown words in the test set. Replacing an unknown word
with a synonym that appears in the corpus can reduce the number of unknown words
and could further improve the final matching performance. We also do
traditional-to-simplified Chinese conversion operation and a numeric format
conversion operation.</p>
        <p>Word segmentation is the last step in data processing. We use jieba1, a word
segmentation tool, to performance word segmentation operation. We found that the
effect of HMM pattern segmentation is not ideal due to the small granularity, thus we
use a non-HMM pattern segmentation in practice. Besides, we also use a custom
dictionary for word segmentation.</p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2 Our Model</title>
        <p>Saitt  softMax(Si )
aaitt, j  a j  Saitt, j
a  [a; aatt ]
(1)
(2)
(3)
(4)
(5)
(6)
Input Encoding. For each word in a sentence, we use bidirectional LSTM (BiLSTM1
for short), which runs a forward and backward LSTM on a sequence starting from the
left and the right respectively, to learn its representation. The hidden states generated
by these two LSTMs at each time step are concatenated to represent a word at that
time step. Here we denote ai and bi as the hidden (output) state generated by a
BiLSTM at time i over the input sequences wa and w .</p>
        <p>b
ai  BiLSTM (wa , i), i [1,...la ]
bi  BiLSTM (wb , i), i [1,...lb ]</p>
        <p>We can derive the self-attentive vector for sentence b with the same method. Then
the results of self-attention and BiLSTM are concatenated as the input of next layer.
Local Inference Modeling. Modeling local subsentential inference between two
sentences is a basic component for determining the overall inference between them. It
needs to employ some forms of hard or soft alignment to associate the relevant
subcomponents between two sentences. Here we also use both LSTM and interactive
attention mechanism for local inference modeling. The former technique helps to
collect local inference for words and their contexts, and the latter enhances the
2 We also tried GRUs (Gated Recurrent Units) as encoding method and experiments
showed that they are inferior to BiLSTMs.
information between words and clauses. Here we use the attention mechanism as used
in ESIM model [2], which leverages attention over the bidirectional sequential
encoding of the input. Specially, we compute the attention weights as the similarity of
a hidden state tuple  ai ,bi  between two sentences with Equation (7).</p>
        <p>eij  aiT bj
lb exp(eij )
aˆi  j1 lb exp(eik )</p>
        <p>k 1
la exp(eij )
bˆj  i1 la exp(ekj )
k 1
bj , i [1,...la ]
ai , j [1,...lb ]
ma  [a; aˆ; a  aˆ; a
mb  [b; bˆ; b  bˆ; b
aˆ]
ˆ
b]</p>
        <p>
          Intuitively, the content in bj that is relevant to ai will be selected and represented
as a factor of the representation aˆi , Thus local inference of aˆi is a weighted
summation that is determined by the attention weight eij , which is computed as
following.
(7)
(8)
(9)
(10)
(11)
(
          <xref ref-type="bibr" rid="ref1">12</xref>
          )
(13)
Each word in another sentence is performed for with Equation (9).
        </p>
        <p>The local inference information collected above is further enhanced in our models.
Specially, we compute the difference and element-wise product for the tuple  a, aˆ 
and  b, bˆ  as following.</p>
        <p>
          We expect such operations could help sharpen local inference information between
elements in the tuples and capture inference relationships such as contradiction.
Aggregation Layer. To determine the overall inference relationship between two
sentences, we use an aggregation layer to combine the enhanced local inference
information of two sentences. We sequentially perform the aggregation operation
using BiLSTM with Equation (
          <xref ref-type="bibr" rid="ref1">12-13</xref>
          ).
        </p>
        <p>ma  BiLSTM (ma , i), i [1,...la ]
mb  BiLSTM (mb , i), i [1,...lb ]</p>
        <p>Our aggregation layer further converts the resulting vectors obtained above to a
fixed-length vector by computing both average and max pooling with Equation
(14-15). Then all these vectors are concatenated to form the final fixed length vector
(Equation 16) and feed it to the final classifier to determine the overall inference
relationship between two sentences.</p>
        <p>ma,ave  ila1 mlaa,i ，ma,max  milaa1x ma,i (14)</p>
        <p>lb mb, j
mb,ave  
j1 lb</p>
        <p>lb
，mb,max  max mb,i</p>
        <p>j1
v  [ma,ave ; ma,max ; mb,ave ; mb,max ]
Prediction Layer. The aim of this layer is to evaluate the label probability
distribution of two sentences. To this end, we employ a multi-layer perception (MLP)
classifier. After obtaining the representation V of the two sentences, the distribution
p(.) can be formalized as:</p>
        <p>P( y | wa , wb )  softMax(tanh(W1V  b1))
(15)
(16)
(17)
where W1 and b1 are trainable parameters.
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Experiments</title>
      <sec id="sec-4-1">
        <title>4.1 Dataset</title>
        <p>The task3 of CCKS2018, which is called as intelligent customer service question
matching, aims to match the intent of two sentences. Specially, it is required to
determine whether the intentions of two sentences are equal or similar. The original
corpus contains 100,000 sentence pairs as training set, 10,000 sentence pairs as online
dev set to verify submission, and 110,000 sentence pairs as online test set for final
submission. This task uses precision, recall, F1, and accuracy as evaluation metrics.</p>
      </sec>
      <sec id="sec-4-2">
        <title>4.2 Experimental Setup</title>
        <p>During offline training, we divide the original train set into 10 parts and select one of
them as dev set and the rest as train set.</p>
        <p>In experiment, the statistical results show that 98% of the sentences are less than
20. So we set max sentence length is 20. We initialize word embedding using the
Chinese Word Vectors3. Word embedding dimension is set to 300. The recurrent unit
size is set to 150, and the batch size is set to 64. Adam is used for optimization, and
the learning rate is set to 0.005.</p>
      </sec>
      <sec id="sec-4-3">
        <title>4.3 Results and Discussion</title>
        <p>In our experiments, we first use ESIM as baseline, and we adjust the model to
Siamese structure. Then we add self-attention mechanism in the encoding layer. The
experimental results are shown in Table 2. It shows that our method obtains better
results than the baselines.
Model Precision Recall Accuracy F1</p>
        <p>ESIM 0.90322 0.91502 0.91056 0.90908
+ Siamese 0.90436 0.94123 0.92210 0.92367
+Self-Att(Our model) 0.92349 0.95860 0.93930 0.94072
In the second part of our experiments, we conduct experiments to evaluate the
ensemble method. We train our model several times, and integrate the generated
models together as the ensemble model. Table3 is the experimental results, which
show that a simple ensemble method is effective, and the performance could be
further improved significantly.
In this paper, we propose an enhanced ESIM model for sentence pair matching task.
Our method merges the ability of obtain the common information of two sentence and
the ability of extracting the key information of the sentences themselves. We also use
Siamese nets in our model, which reduces both model complexity and parameter size.
Experimental results show that our method is effective and it ranks the first among the
hugely competitive models in the task3 of CCKS2018.</p>
        <p>In the future, we will further mine the features of data and try to introduce syntactic
structure information in the model. Besides, we will also try to design a new neural
network structure to improve the representation and reasoning ability for the sentence
matching task.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>6. Acknowledgements</title>
      <p>This work is supported by the National Natural Science Foundation of China (NSFC
No. 61572120, 61672138 and 61432013).</p>
      <p>Reference
10.
11.
13.
14.
15.</p>
      <p>Gong Y, Luo H, Zhang J. Natural language inference over interaction space[J]. arXiv
preprint arXiv:1709.04348, 2017.</p>
      <p>Wang Z, Hamza W, Florian R. Bilateral multi-perspective matching for natural language
sentences[J]. arXiv preprint arXiv:1702.03814, 2017.</p>
      <p>Chen Q, Zhu X, Ling Z H, et al. Enhanced LSTM for Natural Language Inference[C]//
Meeting of the Association for Computational Linguistics. 2017:1657-1668.</p>
      <p>Duan C, Cui L, Chen X, et al. Attention-Fused Deep Matching Network for Natural
Language Inference[C]//IJCAI. 2018: 4033-4040.</p>
      <p>Mueller J, Thyagarajan A. Siamese Recurrent Architectures for Learning Sentence
Similarity[C]//AAAI. 2016, 16: 2786-2792.</p>
      <p>Liu Y, Sun C, Lin L, et al. Learning natural language inference using bidirectional LSTM
model and inner-attention[J]. arXiv preprint arXiv:1605.09090, 2016.</p>
      <p>Conneau A, Kiela D, Schwenk H, et al. Supervised learning of universal sentence
representations from natural language inference data[J]. arXiv preprint arXiv:1705.02364,
2017.</p>
      <p>Munkhdalai T, Yu H. Neural semantic encoders[C]//Proceedings of the conference.
Association for Computational Linguistics. Meeting. NIH Public Access, 2017, 1: 397.
Chen Q, Zhu X, Ling Z H, et al. Recurrent Neural Network-Based Sentence Encoder with
Gated Attention for Natural Language Inference[J]. 2017:36-40.</p>
      <p>Munkhdalai T, Yu H. Neural Semantic Encoders[C]// 2017:397-407.</p>
      <p>Almiman A, Ramsay A. A Hybrid System to apply Natural Language Inference over
Dependency Trees[C]// RANLP 2017 - Recent Advances in Natural Language Processing
Meet Deep Learning. 2017:64-70.</p>
      <p>Huang D. Research on attention memory networks as a model for learning natural language
inference[C]//Proceedings of the Workshop on Structured Prediction for NLP. 2016:
18-24.</p>
      <p>Parikh A P, Täckström O, Das D, et al. A decomposable attention model for natural
language inference[J]. arXiv preprint arXiv:1606.01933, 2016.</p>
      <p>Almiman A, Ramsay A. A Hybrid System to apply Natural Language Inference over
Dependency Trees[C]//Proceedings of the International Conference Recent Advances in
Natural Language Processing, RANLP 2017. 2017: 64-70.</p>
      <p>Yang H, Costa-jussàM R, Fonollosa J A R. Character-level Intra Attention Network for
Natural Language Inference[J]. arXiv preprint arXiv:1707.07469, 2017.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>12.</mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>