[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data

论文原文:Supervised Learning of Universal Sentence Representations from Natural Language Inference Data
Github:facebookresearch/InferSent

引言

这篇文章感觉上我上一篇博客中阅读的论文在想法上有相似的地方,想法都是你要达到目标,你必须先会点别的。不同的是,之前那篇是你要会点简单的才能去干点难的,而这篇是你要掌握了一门绝世神功,其他的武功就触类旁通了。

摘要

很多NLP系统都将word embedding作为base feature,word embedding通常是以无监督方式在大型语料库中训练得到的。但是,对于更长的文本(例如句子)的编码仍然存在很多困难。在这篇文章中,作者展示了在Standford Natural Language Inference dataset上训练得到通用sentence representation可以取得比一些非监督方法(例如SkipThought)学习得到的sentence representation在很多任务上更好的效果。作者认为,经过NLI task 训练过的模型之所以能表现出优越的性能,是因为NLI is a high-level understanding task that involves reasoning about the semantic relationships within sentences.(大概意思就是这么难的NLI你都能会,其他的不是小菜一碟吗?)

The Natural Language Inference task

SNLI dataset是由570,000人工标注的英语句子对组成,每个句子对都有对应的标签。标签一共有三种,分别是entailment,contradiction和neutral。下面是官网提供的几个例子:
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
可以看到标签是综合了5个专家的意见,根据少数服从多数的原则得到的。

训练方案

[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
作者给出了在SNLI上训练encoder的两种方法:
i. encoder对输入句子单独编码得到representation,句子之间没有交互;
ii. encoder对输入句子对联合编码(可以用到cross-features或者注意力机制)。
在文中,作者采取了第一种做法。

在方案图中,SNLI数据集中的premise和hypothesis经过sentence encoder后对应的向量表示分别为u和v,然后作者用3中方法来抽取u和v的关系:
i. concatenation: 将u和v的表示首尾相连得到(u, v)
ii. element-wise product: 将u和v对应维度上的值相乘得到新的表示u*v
iii. absolute element-wise difference: 将u和v对应维度上的值相减得到新的表示 |uv|

最后将得到的表示送入一个3分类的分类器,分类器由多个全连接层和一个softmax层组成,最终得到输入premise和hypothesis的标签的概率分布。

Sentence encoder architectures

目前,有多种多样的神经网络能将句子编码成固定大小的向量表示,并且也没有明确的研究支出哪一种编码方法最好。因此,作者选择了7种不同的architectures:
1. standard recurrent encoders with LSTM
2. standard recurrent encoders with GRU
上述两种是基础的recurrent encoder,在句子建模中通常将网络中的最后一个隐藏状态作为sentence representation;
3. conncatenation of last hidden states of forward and backward GRU
这种方法是将单向的网络变成了双向的网络,然后用将前向和后向的最后一个状态进行连接,得到句子向量;
4. Bi-directional LSTMs (BiLSTM) with mean pooling
5. Bi-directional LSTMs (BiLSTM) with max pooling
这两种方法使用了双向LSTM结合一个pooling层的方法来获取句子表示,具体公式如下:
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
按照上述公式得到每个时刻t的隐藏状态ht后,经过一个max/mean pooling得到最终的句子表示。其中,max/mean pooling的意思是将每个时刻t下ht对应维度上的值进行比较,max表示去对应维度上最大的值,mean表示将该维度上所有值进行加和平均。网络模型如下:
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
6. self-attentive network
这个网络在双向LSTM的基础上加入了attention机制,具体网络结构如下:
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
BiLSTM的输出首先经过一次线性变换和一次非线性tanh变换,变成想要的形状,然后计算每个隐藏状态对应的注意力权重,最后加权求和得到最终表示。
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
7. hierarchical convolutional networks
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
通过多层卷积神经网络可以对输入句子进行不同层级的抽象,在每一层作者通过max-pooling得到一个表示ui,最终将这些表示连接得到u=[u1,u2,...,un]

训练细节

数据集:Standford Natural Language Inference dataset
参数更新方法:SGD随机梯度下降
学习率:0.1
学习率衰减:0.99,即每个epoch的学习率是上一个epoch的0.99
mini-batches大小:64
训练停止条件:学习率小于105
分类器:多层感知机,隐藏层节点数为512
词向量:300D Glove vectors trained on Common Crawl 840B

对句子表示的评估

主要涉及了如下任务:
Binary and multi-class classification
Entailment and semantic relatedness
STS14 - Semantic Textual Similarity
Paraphrase detection
Caption-Image retrieval

实验结果

[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data
[NLP论文阅读] Supervised Learning of Universal Sentence Representations from NLI data

结论

这篇文章在12个不同的任务上对从有标签数据集(SNLI)训练得到的句子向量进行研究。结果表明,在自然语言推理(NLI)任务中训练得到的模型的性能要优于一些从其他有监督任务或者无监督条件下学习得到的模型。并且通过对不同编码器的比较,作者发现BiLSTM with max pooling是其中最优秀的生成句子表示的方法,胜过了SkipThought vectors。

20170915 上海。