概述

目前, 句子匹配相关任务attention机制基本成了模型标配, 并且效果不错. 但是作者认为之前的attention机制只进行了求和, 不能保留原始特征.

针对以上问题, 作者从DenseNet获得灵感, 提出densely-connected co-attentive recurrent neural network(DRCN). 它能够保存从最底部的词嵌入层到最顶部的recurrent层的原始和共同关注的特征信息.

模型

模型分为三部分:

  1. word representation layer
  2. attentively connected RNN
  3. interaction and prediction layer

1. Word Representation Layer

与很多网络只使用word embedding不同, 作者使用了word embedding, character representation和exact matched flag三种作为模型输入.

  • word embedding
    使用Word2vec或者Glove等预训练词向量
  • character representation
    随机初始化后利用CNN+maxpooling进行训练
  • exact matched flag
    如果一句话中某个词在另一句话中出现则该位置置1

最终的输入向量:

2. Densely connected Recurrent Networks

传统的多层RNN

过深的网络会导致梯度消失或梯度爆炸.
为了解决这一问题, 作者借鉴DenseNet,

3. Densely-connected Co-attentive networks

基于上一部分的Densely-connected RNN, 作者又加入attention机制.

attention权重的计算:

和常见的attention有点区别, 作者不是用向量相乘而是用 c o s cos cos来计算权重.

RNN加上attention机制之后:

4. Bottleneck component

层数加深之后, 参数量会非常庞大.

为了减少参数量, 作者实现了一种autoencoder作为bottleneck component.
Autoencoder减少特征数量同时能够维持原有信息.

5. Interaction and Prediction Layer

对RNN的输出先做max-pooling.

然后分别做加减等运算, 最终的特征向量为:

之后接全连接和softmax输出结果.

实验

数据集

  1. SNLI和MultiNLI
  2. Quora Question Pair
  3. TrecQA和SelQA

实现细节

  • word embedding: 300d GloVe
  • densely-connected RNN: 5层, hidden layer都是100维
  • dropout: 0.5(加在word和char embedding之后)
  • bottleneck component: 200 hidden units(dropout设置为0.2)
  • optimizer: RMSProp(lr初始化0.001)
  • L2正则化: 1 0 6 10^{-6} 106
  • 句子长度设置: SNLI(35), MultiNLI(55), Quora(25), TrecQA(50)

实验结果