Skip-Thought Vectors | AGIDaily
AGI Daily
资讯日报词条论文人物新创
返回论文列表
1 引言2 方法2.1 诱导 skip-thought 向量2.2 词表扩展3 实验3.1 训练细节3.2 语义相关度3.3 释义识别3.4 图像–句子排序3.5 分类基准3.6 可视化 skip-thoughts4 结论
返回论文列表
目录

Skip-Thought Vectors

收录于 NIPS 2015 会议论文被引 2,157 次
打开论文来源

Skip-Thought Vectors

Ryan Kiros^{1}, Yukun Zhu^{1}, Ruslan Salakhutdinov^{1},^{2}, Richard S. Zemel^{1},^{2}
Antonio Torralba^{3}, Raquel Urtasun^{1}, Sanja Fidler^{1}

University of Toronto^{1}
Canadian Institute for Advanced Research^{2}
Massachusetts Institute of Technology^{3}

Abstract

摘要

We describe an approach for unsupervised learning of a generic, distributed sentence encoder. Using the continuity of text from books, we train an encoder-decoder model that tries to reconstruct the surrounding sentences of an encoded passage. Sentences that share semantic and syntactic properties are thus mapped to similar vector representations. We next introduce a simple vocabulary expansion method to encode words that were not seen as part of training, allowing us to expand our vocabulary to a million words. After training our model, we extract and evaluate our vectors with linear models on 8 tasks: semantic relatedness, paraphrase detection, image-sentence ranking, question-type classification and 4 benchmark sentiment and subjectivity datasets. The end result is an off-the-shelf encoder that can produce highly generic sentence representations that are robust and perform well in practice.

我们描述一种无监督学习通用分布式句子编码器的方法。利用书籍文本的连续性,我们训练一个编码器–解码器模型,让它尝试重建被编码段落的前后相邻句子。由此,共享语义和句法性质的句子会被映射到相近的向量表示。接着,我们引入一种简单的词表扩展方法,用来编码训练中未见过的词,从而把词表扩到一百万词。模型训练完成后,我们提取这些向量,并用线性模型在 8 项任务上评估:语义相关度、释义识别、图像–句子排序、问句类型分类,以及 4 个基准情感与主观性数据集。最终得到的是一个现成可用的编码器,能够生成高度通用的句子表示,在实践中稳健且表现良好。

1 Introduction

1 引言

Developing learning algorithms for distributed compositional semantics of words has been a long-standing open problem at the intersection of language understanding and machine learning. In recent years, several approaches have been developed for learning composition operators that map word vectors to sentence vectors including recursive networks [1], recurrent networks [2], convolutional networks [3, 4] and recursive-convolutional methods [5, 6] among others. All of these methods produce sentence representations that are passed to a supervised task and depend on a class label in order to backpropagate through the composition weights. Consequently, these methods learn high-quality sentence representations but are tuned only for their respective task. The paragraph vector of [7] is an alternative to the above models in that it can learn unsupervised sentence representations by introducing a distributed sentence indicator as part of a neural language model. The downside is at test time, inference needs to be performed to compute a new vector.

为词的分布式组合语义设计学习算法,长期以来一直是语言理解与机器学习交叉处的开放问题。近年来,已有若干方法学习把词向量映射到句向量的组合算子,其中包括递归网络 [1]、循环网络 [2]、卷积网络 [3, 4] 以及递归–卷积方法 [5, 6] 等。这些方法都会把句子表示送进某个监督任务,并依赖类别标签才能通过组合权重反传。因此,它们能学到高质量的句子表示,却只为各自的任务调过参。[7] 的段落向量是上述模型之外的另一种选择:它在神经语言模型中引入一个分布式的句子指示变量,从而可以无监督地学习句子表示。缺点是测试时必须做推断,才能算出一个新向量。

In this paper we abstract away from the composition methods themselves and consider an alternative loss function that can be applied with any composition operator. We consider the following question: is there a task and a corresponding loss that will allow us to learn highly generic sentence representations? We give evidence for this by proposing a model for learning high-quality sentence vectors without a particular supervised task in mind. Using word vector learning as inspiration, we propose an objective function that abstracts the skip-gram model of [8] to the sentence level. That is, instead of using a word to predict its surrounding context, we instead encode a sentence to predict the sentences around it. Thus, any composition operator can be substituted as a sentence encoder and only the objective function becomes modified. Figure 1 illustrates the model. We call our model skip-thoughts and vectors induced by our model are called skip-thought vectors.

本文不再纠缠于组合方法本身,而是考虑一种可以配合任意组合算子使用的替代损失函数。我们要问的是:有没有一种任务和对应的损失,能让我们学到高度通用的句子表示?我们给出这方面的证据:提出一种不以某个特定监督任务为目标、用来学习高质量句向量的模型。受词向量学习启发,我们提出一个把 [8] 的 skip-gram 模型抽象到句子层的目标函数。也就是说,不再用一个词去预测它周围的上下文,而是把一个句子编码后,去预测它前后的句子。这样一来,任意组合算子都可以替换为句子编码器,被改动的只是目标函数。图 1 给出了模型示意。我们把这个模型称作 skip-thoughts,由它得到的向量称作 skip-thought 向量。

Skip-thoughts encoder-decoder diagram reconstructing previous and next sentences

Figure 1: The skip-thoughts model. Given a tuple (si−1,si,si+1)(s_{i-1}, s_i, s_{i+1})(si−1​,si​,si+1​) of contiguous sentences, with sis_isi​ the iii-th sentence of a book, the sentence sis_isi​ is encoded and tries to reconstruct the previous sentence si−1s_{i-1}si−1​ and next sentence si+1s_{i+1}si+1​. In this example, the input is the sentence triplet I got back home. I could see the cat on the steps. This was strange. Unattached arrows are connected to the encoder output. Colors indicate which components share parameters. ⟨\langle⟨eos⟩\rangle⟩ is the end of sentence token.

图 1:skip-thoughts 模型。给定连续句子三元组 (si−1,si,si+1)(s_{i-1}, s_i, s_{i+1})(si−1​,si​,si+1​),其中 sis_isi​ 是一本书的第 iii 句,句子 sis_isi​ 被编码后,尝试重建前一句 si−1s_{i-1}si−1​ 和后一句 si+1s_{i+1}si+1​。本例中,输入是句子三元组 I got back home. I could see the cat on the steps. This was strange. 未连接的箭头接到编码器输出。颜色表示哪些部分共享参数。⟨\langle⟨eos⟩\rangle⟩ 是句末标记。

Our model depends on having a training corpus of contiguous text. We chose to use a large collection of novels, namely the BookCorpus dataset [9] for training our models. These are free books written by yet unpublished authors. The dataset has books in 16 different genres, e.g., Romance (2,865 books), Fantasy (1,479), Science fiction (786), Teen (430), etc. Table 1 highlights the summary statistics of the book corpus. Along with narratives, books contain dialogue, emotion and a wide range of interaction between characters. Furthermore, with a large enough collection the training set is not biased towards any particular domain or application. Table 2 shows nearest neighbours of sentences from a model trained on the BookCorpus dataset. These results show that skip-thought vectors learn to accurately capture semantics and syntax of the sentences they encode.

我们的模型依赖于一份连续文本的训练语料。我们选用一大批小说,即 BookCorpus 数据集 [9],来训练模型。这些是尚未正式出版的作者写的免费图书。数据集覆盖 16 种体裁,例如 Romance(2,865 本)、Fantasy(1,479 本)、Science fiction(786 本)、Teen(430 本)等。表 1 给出了该语料的汇总统计。除了叙述,书里还有对话、情感以及人物之间多种多样的互动。而且,只要规模足够大,训练集就不会偏向某一个领域或应用。表 2 给出了在 BookCorpus 上训练的模型所得到的句子近邻。这些结果表明,skip-thought 向量能够准确抓住所编码句子的语义和句法。

# of books # of sentences # of words # of unique words mean # of words per sentence
11,038 74,004,228 984,846,357 1,316,420 13

Table 1: Summary statistics of the BookCorpus dataset [9]. We use this corpus to training our model.

# of books # of sentences # of words # of unique words mean # of words per sentence
11,038 74,004,228 984,846,357 1,316,420 13

表 1:BookCorpus 数据集 [9] 的汇总统计。我们用这份语料来训练模型。原文表注为 “We use this corpus to training our model”,此处按原文保留这一用词。

We evaluate our vectors in a newly proposed setting: after learning skip-thoughts, freeze the model and use the encoder as a generic feature extractor for arbitrary tasks. In our experiments we consider 8 tasks: semantic-relatedness, paraphrase detection, image-sentence ranking and 5 standard classification benchmarks. In these experiments, we extract skip-thought vectors and train linear models to evaluate the representations directly, without any additional fine-tuning. As it turns out, skip-thoughts yield generic representations that perform robustly across all tasks considered.

我们在一种新提出的设定下评估这些向量:学完 skip-thoughts 之后,冻结模型,把编码器当作适用于任意任务的通用特征提取器。实验中我们考虑 8 项任务:语义相关度、释义识别、图像–句子排序,以及 5 个标准分类基准。在这些实验里,我们提取 skip-thought 向量并训练线性模型,直接评估表示本身,不再做额外微调。结果表明,skip-thoughts 能给出通用表示,在所考虑的全部任务上都表现稳健。

One difficulty that arises with such an experimental setup is being able to construct a large enough word vocabulary to encode arbitrary sentences. For example, a sentence from a Wikipedia article might contain nouns that are highly unlikely to appear in our book vocabulary. We solve this problem by learning a mapping that transfers word representations from one model to another. Using pre-trained word2vec representations learned with a continuous bag-of-words model [8], we learn a linear mapping from a word in word2vec space to a word in the encoder’s vocabulary space. The mapping is learned using all words that are shared between vocabularies. After training, any word that appears in word2vec can then get a vector in the encoder word embedding space.

这种实验设定会带来一个困难:要构造足够大的词表,才能编码任意句子。例如,维基百科文章里的句子可能含有极不可能出现在我们的书籍词表里的名词。我们的解决办法是学习一个把词表示从一种模型迁移到另一种模型的映射。利用用连续词袋模型 [8] 学到的预训练 word2vec 表示,我们学习一个从 word2vec 空间中的词到编码器词表空间中的词的线性映射。映射用两边词表的全部共享词来学习。训练之后,任何出现在 word2vec 里的词都可以在编码器的词嵌入空间里得到一个向量。

2 Approach

2 方法

2.1 Inducing skip-thought vectors

2.1 诱导 skip-thought 向量

We treat skip-thoughts in the framework of encoder-decoder models^{1}. That is, an encoder maps words to a sentence vector and a decoder is used to generate the surrounding sentences. Encoder-decoder models have gained a lot of traction for neural machine translation. In this setting, an encoder is used to map e.g. an English sentence into a vector. The decoder then conditions on this vector to generate a translation for the source English sentence. Several choices of encoder-decoder pairs have been explored, including ConvNet-RNN [10], RNN-RNN [11] and LSTM-LSTM [12]. The source sentence representation can also dynamically change through the use of an attention mechanism [13] to take into account only the relevant words for translation at any given time. In our model, we use an RNN encoder with GRU [14] activations and an RNN decoder with a conditional GRU. This model combination is nearly identical to the RNN encoder-decoder of [11] used in neural machine translation. GRU has been shown to perform as well as LSTM [2] on sequence modelling tasks [14] while being conceptually simpler. GRU units have only 2 gates and do not require the use of a cell. While we use RNNs for our model, any encoder and decoder can be used so long as we can backpropagate through it.

我们把 skip-thoughts 放在编码器–解码器模型的框架里来处理^{1}。也就是说,编码器把词映射成句向量,解码器用来生成周围的句子。编码器–解码器模型在神经机器翻译中已经得到大量采用。在那种设定里,编码器例如把一个英文句子映射成向量,解码器再以该向量为条件,为源英文句子生成译文。人们已经探索过若干种编码器–解码器组合,包括 ConvNet-RNN [10]、RNN-RNN [11] 和 LSTM-LSTM [12]。通过注意力机制 [13],源句表示也可以动态变化,从而在任一时刻只考虑对翻译有关的词。在我们的模型里,编码器是带 GRU [14] 激活的 RNN,解码器是带条件 GRU 的 RNN。这一组合与神经机器翻译中 [11] 的 RNN 编码器–解码器几乎相同。已有结果表明,GRU 在序列建模任务上的表现与 LSTM [2] 相当 [14],而概念上更简单。GRU 单元只有 2 个门,也不需要细胞状态。虽然我们用的是 RNN,但只要能对它反传,任意编码器和解码器都可以使用。

^{1}A preliminary version of our model was developed in the context of a computer vision application [9].

Assume we are given a sentence tuple (si−1,si,si+1)(s_{i-1}, s_i, s_{i+1})(si−1​,si​,si+1​). Let witw_i^twit​ denote the ttt-th word for sentence sis_isi​ and let xitx_i^txit​ denote its word embedding. We describe the model in three parts: the encoder, decoder and objective function.

假定给定句子三元组 (si−1,si,si+1)(s_{i-1}, s_i, s_{i+1})(si−1​,si​,si+1​)。令 witw_i^twit​ 表示句子 sis_isi​ 的第 ttt 个词,令 xitx_i^txit​ 表示它的词嵌入。我们分三部分描述模型:编码器、解码器和目标函数。

Encoder. Let wi1,…,wiNw_i^1, \ldots, w_i^Nwi1​,…,wiN​ be the words in sentence sis_isi​ where NNN is the number of words in the sentence. At each time step, the encoder produces a hidden state hith_i^thit​ which can be interpreted as the representation of the sequence wi1,…,witw_i^1, \ldots, w_i^twi1​,…,wit​. The hidden state hiNh_i^NhiN​ thus represents the full sentence. To encode a sentence, we iterate the following sequence of equations (dropping the subscript iii):

编码器。 令 wi1,…,wiNw_i^1, \ldots, w_i^Nwi1​,…,wiN​ 为句子 sis_isi​ 中的词,其中 NNN 是句中词数。在每一步,编码器产生隐状态 hith_i^thit​,它可以理解为序列 wi1,…,witw_i^1, \ldots, w_i^twi1​,…,wit​ 的表示。因此隐状态 hiNh_i^NhiN​ 表示整句。为了编码一个句子,我们迭代下面这组方程(略去下标 iii):

rt=σ(Wrxt+Urht−1)zt=σ(Wzxt+Uzht−1)hˉt=tanh⁡(Wxt+U(rt⊙ht−1))ht=(1−zt)⊙ht−1+zt⊙hˉt(1–4)\begin{aligned} r^t &= \sigma(W_r x^t + U_r h^{t-1}) \\ z^t &= \sigma(W_z x^t + U_z h^{t-1}) \\ \bar{h}^t &= \tanh(W x^t + U(r^t \odot h^{t-1})) \\ h^t &= (1 - z^t) \odot h^{t-1} + z^t \odot \bar{h}^t \end{aligned} \tag{1--4}rtzthˉtht​=σ(Wr​xt+Ur​ht−1)=σ(Wz​xt+Uz​ht−1)=tanh(Wxt+U(rt⊙ht−1))=(1−zt)⊙ht−1+zt⊙hˉt​(1–4)

where hˉt\bar{h}^thˉt is the proposed state update at time ttt, ztz^tzt is the update gate, rtr^trt is the reset gate. (⊙)(\odot)(⊙) denotes a component-wise product. Both update gates takes values between zero and one.

rt=σ(Wrxt+Urht−1)zt=σ(Wzxt+Uzht−1)hˉt=tanh⁡(Wxt+U(rt⊙ht−1))ht=(1−zt)⊙ht−1+zt⊙hˉt(1–4)\begin{aligned} r^t &= \sigma(W_r x^t + U_r h^{t-1}) \\ z^t &= \sigma(W_z x^t + U_z h^{t-1}) \\ \bar{h}^t &= \tanh(W x^t + U(r^t \odot h^{t-1})) \\ h^t &= (1 - z^t) \odot h^{t-1} + z^t \odot \bar{h}^t \end{aligned} \tag{1--4}rtzthˉtht​=σ(Wr​xt+Ur​ht−1)=σ(Wz​xt+Uz​ht−1)=tanh(Wxt+U(rt⊙ht−1))=(1−zt)⊙ht−1+zt⊙hˉt​(1–4)

其中 hˉt\bar{h}^thˉt 是时刻 ttt 提出的状态更新,ztz^tzt 是更新门,rtr^trt 是重置门。(⊙)(\odot)(⊙) 表示逐维乘积。原文写的是 “Both update gates takes values between zero and one”,此处按原文保留这一主谓形式:两个更新门的取值都在 0 与 1 之间。

Decoder. The decoder is a neural language model which conditions on the encoder output hih_ihi​. The computation is similar to that of the encoder except we introduce matrices CzC_zCz​, CrC_rCr​ and CCC that are used to bias the update gate, reset gate and hidden state computation by the sentence vector. One decoder is used for the next sentence si+1s_{i+1}si+1​ while a second decoder is used for the previous sentence si−1s_{i-1}si−1​. Separate parameters are used for each decoder with the exception of the vocabulary matrix VVV, which is the weight matrix connecting the decoder’s hidden state for computing a distribution over words. In what follows we describe the decoder for the next sentence si+1s_{i+1}si+1​ although an analogous computation is used for the previous sentence si−1s_{i-1}si−1​. Let hi+1th_{i+1}^thi+1t​ denote the hidden state of the decoder at time ttt. Decoding involves iterating through the following sequence of equations (dropping the subscript i+1i+1i+1):

解码器。 解码器是以编码器输出 hih_ihi​ 为条件的神经语言模型。计算过程与编码器类似,不同之处是我们引入矩阵 CzC_zCz​、CrC_rCr​ 和 CCC,用来让句向量分别偏置更新门、重置门和隐状态的计算。一个解码器用于后一句 si+1s_{i+1}si+1​,另一个解码器用于前一句 si−1s_{i-1}si−1​。两个解码器使用各自的参数,唯一例外是词表矩阵 VVV,它是把解码器隐状态连接到词分布计算的权重矩阵。下面描述用于后一句 si+1s_{i+1}si+1​ 的解码器,前一句 si−1s_{i-1}si−1​ 使用类似的计算。令 hi+1th_{i+1}^thi+1t​ 表示解码器在时刻 ttt 的隐状态。解码需要迭代下面这组方程(略去下标 i+1i+1i+1):

rt=σ(Wrdxt−1+Urdht−1+Crhi)zt=σ(Wzdxt−1+Uzdht−1+Czhi)hˉt=tanh⁡(Wdxt−1+Ud(rt⊙ht−1)+Chi)hi+1t=(1−zt)⊙ht−1+zt⊙hˉt(5–8)\begin{aligned} r^t &= \sigma(W_r^d x^{t-1} + U_r^d h^{t-1} + C_r h_i) \\ z^t &= \sigma(W_z^d x^{t-1} + U_z^d h^{t-1} + C_z h_i) \\ \bar{h}^t &= \tanh(W^d x^{t-1} + U^d(r^t \odot h^{t-1}) + C h_i) \\ h_{i+1}^t &= (1 - z^t) \odot h^{t-1} + z^t \odot \bar{h}^t \end{aligned} \tag{5--8}rtzthˉthi+1t​​=σ(Wrd​xt−1+Urd​ht−1+Cr​hi​)=σ(Wzd​xt−1+Uzd​ht−1+Cz​hi​)=tanh(Wdxt−1+Ud(rt⊙ht−1)+Chi​)=(1−zt)⊙ht−1+zt⊙hˉt​(5–8)

Given hi+1th_{i+1}^thi+1t​, the probability of word wi+1tw_{i+1}^twi+1t​ given the previous t−1t-1t−1 words and the encoder vector is

P(wi+1t∣wi+1<t,hi)∝exp⁡(vwi+1thi+1t)(9)P(w_{i+1}^t \mid w_{i+1}^{<t}, h_i) \propto \exp(v_{w_{i+1}^t} h_{i+1}^t) \tag{9}P(wi+1t​∣wi+1<t​,hi​)∝exp(vwi+1t​​hi+1t​)(9)

where vwi+1tv_{w_{i+1}^t}vwi+1t​​ denotes the row of VVV corresponding to the word of wi+1tw_{i+1}^twi+1t​. An analogous computation is performed for the previous sentence si−1s_{i-1}si−1​.

给定 hi+1th_{i+1}^thi+1t​,在前面 t−1t-1t−1 个词和编码器向量的条件下,词 wi+1tw_{i+1}^twi+1t​ 的概率为

P(wi+1t∣wi+1<t,hi)∝exp⁡(vwi+1thi+1t)(9)P(w_{i+1}^t \mid w_{i+1}^{<t}, h_i) \propto \exp(v_{w_{i+1}^t} h_{i+1}^t) \tag{9}P(wi+1t​∣wi+1<t​,hi​)∝exp(vwi+1t​​hi+1t​)(9)

其中 vwi+1tv_{w_{i+1}^t}vwi+1t​​ 表示 VVV 中与词 wi+1tw_{i+1}^twi+1t​ 相对应的那一行。对前一句 si−1s_{i-1}si−1​ 做类似计算。

Objective. Given a tuple (si−1,si,si+1)(s_{i-1}, s_i, s_{i+1})(si−1​,si​,si+1​), the objective optimized is the sum of the log-probabilities for the forward and backward sentences conditioned on the encoder representation:

∑tlog⁡P(wi+1t∣wi+1<t,hi)+∑tlog⁡P(wi−1t∣wi−1<t,hi)(10)\sum_t \log P(w_{i+1}^t \mid w_{i+1}^{<t}, h_i) + \sum_t \log P(w_{i-1}^t \mid w_{i-1}^{<t}, h_i) \tag{10}t∑​logP(wi+1t​∣wi+1<t​,hi​)+t∑​logP(wi−1t​∣wi−1<t​,hi​)(10)

The total objective is the above summed over all such training tuples.

目标函数。 给定三元组 (si−1,si,si+1)(s_{i-1}, s_i, s_{i+1})(si−1​,si​,si+1​),优化的目标是以前后句在编码器表示条件下的对数概率之和:

∑tlog⁡P(wi+1t∣wi+1<t,hi)+∑tlog⁡P(wi−1t∣wi−1<t,hi)(10)\sum_t \log P(w_{i+1}^t \mid w_{i+1}^{<t}, h_i) + \sum_t \log P(w_{i-1}^t \mid w_{i-1}^{<t}, h_i) \tag{10}t∑​logP(wi+1t​∣wi+1<t​,hi​)+t∑​logP(wi−1t​∣wi−1<t​,hi​)(10)

总目标是把上式对所有此类训练三元组求和。

Query and nearest sentence
he ran his hand inside his coat , double-checking that the unopened letter was still there .
he slipped his hand between his coat and his shirt , where the folded copies lay in a brown envelope .
im sure youll have a glamorous evening , she said , giving an exaggerated wink .
im really glad you came to the party tonight , he said , turning to her .
although she could tell he had n’t been too invested in any of their other chitchat , he seemed genuinely curious about this .
although he had n’t been following her career with a microscope , he ’d definitely taken notice of her appearances .
an annoying buzz started to ring in my ears , becoming louder and louder as my vision began to swim .
a weighty pressure landed on my lungs and my vision blurred at the edges , threatening my consciousness altogether .
if he had a weapon , he could maybe take out their last imp , and then beat up errol and vanessa .
if he could ram them from behind , send them sailing over the far side of the levee , he had a chance of stopping them .
then , with a stroke of luck , they saw the pair head together towards the portaloos .
then , from out back of the house , they heard a horse scream probably in answer to a pair of sharp spurs digging deep into its flanks .
“ i ’ll take care of it , ” goodman said , taking the phonebook .
“ i ’ll do that , ” julia said , coming in .
he finished rolling up scrolls and , placing them to one side , began the more urgent task of finding ale and tankards .
he righted the table , set the candle on a piece of broken plate , and reached for his flint , steel , and tinder .

Table 2: In each example, the first sentence is a query while the second sentence is its nearest neighbour. Nearest neighbours were scored by cosine similarity from a random sample of 500,000 sentences from our corpus.

查询句与最近邻
he ran his hand inside his coat , double-checking that the unopened letter was still there .
he slipped his hand between his coat and his shirt , where the folded copies lay in a brown envelope .
im sure youll have a glamorous evening , she said , giving an exaggerated wink .
im really glad you came to the party tonight , he said , turning to her .
although she could tell he had n’t been too invested in any of their other chitchat , he seemed genuinely curious about this .
although he had n’t been following her career with a microscope , he ’d definitely taken notice of her appearances .
an annoying buzz started to ring in my ears , becoming louder and louder as my vision began to swim .
a weighty pressure landed on my lungs and my vision blurred at the edges , threatening my consciousness altogether .
if he had a weapon , he could maybe take out their last imp , and then beat up errol and vanessa .
if he could ram them from behind , send them sailing over the far side of the levee , he had a chance of stopping them .
then , with a stroke of luck , they saw the pair head together towards the portaloos .
then , from out back of the house , they heard a horse scream probably in answer to a pair of sharp spurs digging deep into its flanks .
“ i ’ll take care of it , ” goodman said , taking the phonebook .
“ i ’ll do that , ” julia said , coming in .
he finished rolling up scrolls and , placing them to one side , began the more urgent task of finding ale and tankards .
he righted the table , set the candle on a piece of broken plate , and reached for his flint , steel , and tinder .

表 2:每个例子中,第一句是查询句,第二句是它的最近邻。最近邻按余弦相似度,从我们语料中随机抽取的 500,000 个句子里打分得到。例句按官方 PDF 原文保留,不另行译出。

2.2 Vocabulary expansion

2.2 词表扩展

We now describe how to expand our encoder’s vocabulary to words it has not seen during training. Suppose we have a model that was trained to induce word representations, such as word2vec. Let Vw2vV_{w2v}Vw2v​ denote the word embedding space of these word representations and let VrnnV_{rnn}Vrnn​ denote the RNN word embedding space. We assume the vocabulary of Vw2vV_{w2v}Vw2v​ is much larger than that of VrnnV_{rnn}Vrnn​. Our goal is to construct a mapping f:Vw2v→Vrnnf: V_{w2v} \to V_{rnn}f:Vw2v​→Vrnn​ parameterized by a matrix WWW such that v′=Wvv' = Wvv′=Wv for v∈Vw2vv \in V_{w2v}v∈Vw2v​ and v′∈Vrnnv' \in V_{rnn}v′∈Vrnn​. Inspired by [15], which learned linear mappings between translation word spaces, we solve an un-regularized L2L2L2 linear regression loss for the matrix WWW. Thus, any word from Vw2vV_{w2v}Vw2v​ can now be mapped into VrnnV_{rnn}Vrnn​ for encoding sentences.

下面说明如何把编码器的词表扩展到训练时未见过的词。假定已有一个被训练来诱导词表示的模型,例如 word2vec。令 Vw2vV_{w2v}Vw2v​ 表示这些词表示的词嵌入空间,令 VrnnV_{rnn}Vrnn​ 表示 RNN 的词嵌入空间。我们假定 Vw2vV_{w2v}Vw2v​ 的词表远大于 VrnnV_{rnn}Vrnn​。目标是构造一个由矩阵 WWW 参数化的映射 f:Vw2v→Vrnnf: V_{w2v} \to V_{rnn}f:Vw2v​→Vrnn​,使得对 v∈Vw2vv \in V_{w2v}v∈Vw2v​、v′∈Vrnnv' \in V_{rnn}v′∈Vrnn​ 有 v′=Wvv' = Wvv′=Wv。受 [15] 在翻译词空间之间学习线性映射的启发,我们对矩阵 WWW 求解不加正则的 L2L2L2 线性回归损失。这样,Vw2vV_{w2v}Vw2v​ 中的任意词都可以映射到 VrnnV_{rnn}Vrnn​,用来编码句子。

3 Experiments

3 实验

In our experiments, we evaluate the capability of our encoder as a generic feature extractor after training on the BookCorpus dataset. Our experimentation setup on each task is as follows:

在实验中,我们评估编码器在 BookCorpus 上训练之后作为通用特征提取器的能力。每项任务上的实验设置如下:

  • Using the learned encoder as a feature extractor, extract skip-thought vectors for all sentences.
  • 把学到的编码器当作特征提取器,为所有句子提取 skip-thought 向量。
  • If the task involves computing scores between pairs of sentences, compute component-wise features between pairs. This is described in more detail specifically for each experiment.
  • 如果任务需要计算句子对之间的分数,则在成对句子上计算逐维特征。各实验中会再给出更具体的说明。
  • Train a linear classifier on top of the extracted features, with no additional fine-tuning or backpropagation through the skip-thoughts model.
  • 在提取出的特征之上训练线性分类器,不再对 skip-thoughts 模型做额外微调或反传。

We restrict ourselves to linear classifiers for two reasons. The first is to directly evaluate the representation quality of the computed vectors. It is possible that additional performance gains can be made throughout our experiments with non-linear models but this falls out of scope of our goal. Furthermore, it allows us to better analyze the strengths and weaknesses of the learned representations. The second reason is that reproducibility now becomes very straightforward.

我们只用线性分类器,有两个原因。第一是为了直接评估所计算向量的表示质量。实验中若改用非线性模型,有可能再提高表现,但这超出了我们的目标范围。此外,这也便于更好地分析所学表示的长处和短处。第二个原因是:这样一来,可复现性就变得非常直接。

3.1 Details of training

3.1 训练细节

To induce skip-thought vectors, we train two separate models on our book corpus. One is a unidirectional encoder with 2400 dimensions, which we subsequently refer to as uni-skip. The other is a bidirectional model with forward and backward encoders of 1200 dimensions each. This model contains two encoders with different parameters: one encoder is given the sentence in correct order, while the other is given the sentence in reverse. The outputs are then concatenated to form a 2400 dimensional vector. We refer to this model as bi-skip. For training, we initialize all recurrent matricies with orthogonal initialization [16]. Non-recurrent weights are initialized from a uniform distribution in [-0.1,0.1]. Mini-batches of size 128 are used and gradients are clipped if the norm of the parameter vector exceeds 10. We used the Adam algorithm [17] for optimization. Both models were trained for roughly two weeks. As an additional experiment, we also report experimental results using a combined model, consisting of the concatenation of the vectors from uni-skip and bi-skip, resulting in a 4800 dimensional vector. We refer to this model throughout as combine-skip.

为了诱导 skip-thought 向量,我们在书籍语料上分别训练两个模型。一个是 2400 维的单向编码器,后文称作 uni-skip。另一个是双向模型,前向和后向编码器各 1200 维。该模型包含两个参数不同的编码器:一个按正确顺序读入句子,另一个按反向读入句子。输出再拼接成 2400 维向量。我们把这个模型称作 bi-skip。训练时,所有循环矩阵用正交初始化 [16](原文作 recurrent matricies)。非循环权重从 [-0.1, 0.1] 上的均匀分布初始化。小批量大小为 128,若参数向量的范数超过 10 则裁剪梯度。优化使用 Adam 算法 [17]。两个模型大约各训练了两周。作为附加实验,我们还报告一个组合模型的结果:把 uni-skip 与 bi-skip 的向量拼接起来,得到 4800 维向量。后文把这个模型称作 combine-skip。

After our models are trained, we then employ vocabulary expansion to map word embeddings into the RNN encoder space. The publically available CBOW word vectors are used for this purpose^{2}. The skip-thought models are trained with a vocabulary size of 20,000 words. After removing multiple word examples from the CBOW model, this results in a vocabulary size of 930,911 words. Thus even though our skip-thoughts model was trained with only 20,000 words, after vocabulary expansion we can now successfully encode 930,911 possible words.

模型训练完成后,我们再用词表扩展,把词嵌入映射到 RNN 编码器空间。为此使用公开可得的 CBOW 词向量^{2}(原文作 publically available)。skip-thought 模型训练时的词表大小为 20,000 词。从 CBOW 模型中去掉多词条目后,词表大小为 930,911 词。因此,尽管我们的 skip-thoughts 模型只用 20,000 词训练,词表扩展之后已能成功编码 930,911 个可能的词。

^{2}http://code.google.com/p/word2vec/

Since our goal is to evaluate skip-thoughts as a general feature extractor, we keep text pre-processing to a minimum. When encoding new sentences, no additional preprocessing is done other than basic tokenization. This is done to test the robustness of our vectors. As an additional baseline, we also consider the mean of the word vectors learned from the uni-skip model. We refer to this baseline as bow. This is to determine the effectiveness of a standard baseline trained on the BookCorpus.

由于目标是把 skip-thoughts 当作通用特征提取器来评估,文本预处理尽量保持最少。编码新句子时,除基本分词外不再做额外预处理,以此检验向量的稳健性。作为附加基线,我们还考虑 uni-skip 模型所学词向量的均值,称作 bow。这是为了衡量在 BookCorpus 上训练的标准基线效果如何。

3.2 Semantic relatedness

3.2 语义相关度

Our first experiment is on the SemEval 2014 Task 1: semantic relatedness SICK dataset [30]. Given two sentences, our goal is to produce a score of how semantically related these sentences are, based on human generated scores. Each score is the average of 10 different human annotators. Scores take values between 1 and 5. A score of 1 indicates that the sentence pair is not at all related, while a score of 5 indicates they are highly related. The dataset comes with a predefined split of 4500 training pairs, 500 development pairs and 4927 testing pairs. All sentences are derived from existing image and video annotation datasets. The evaluation metrics are Pearson’s rrr, Spearman’s ρ\rhoρ, and mean squared error.

第一个实验是 SemEval 2014 任务 1:语义相关度 SICK 数据集 [30]。给定两个句子,目标是根据人工打分,给出这两个句子在语义上有多相关。每个分数是 10 位不同标注者的平均,取值在 1 到 5 之间。1 表示该句对完全不相关,5 表示高度相关。数据预先划分为 4500 对训练、500 对开发和 4927 对测试。所有句子都来自已有的图像和视频标注数据集。评价指标是 Pearson 相关系数 rrr、Spearman 相关系数 ρ\rhoρ 和均方误差。

Given the difficulty of this task, many existing systems employ a large amount of feature engineering and additional resources. Thus, we test how well our learned representations fair against heavily engineered pipelines. Recently, [22] showed that learning representations with LSTM or Tree-LSTM for the task at hand is able to outperform these existing systems. We take this one step further and see how well our vectors learned from a completely different task are able to capture semantic relatedness when only a linear model is used on top to predict scores.

由于这项任务很难,许多已有系统使用了大量特征工程和额外资源。因此,我们检验所学表示在与高度工程化的流水线相比较时表现如何(原文作 “how well our learned representations fair against”)。最近,[22] 表明,用 LSTM 或 Tree-LSTM 为当前任务学习表示,能够超过这些已有系统。我们再往前走一步,看从一项完全不同的任务上学到的向量,在上面只接线性模型来预测分数时,能在多大程度上抓住语义相关度。

To represent a sentence pair, we use two features. Given two skip-thought vectors uuu and vvv, we compute their component-wise product u⋅vu \cdot vu⋅v and their absolute difference ∣u−v∣|u - v|∣u−v∣ and concatenate them together. These two features were also used by [22]. To predict a score, we use the same setup as [22]. Let r⊤=[1,…,5]r^\top = [1, \ldots, 5]r⊤=[1,…,5] be an integer vector from 1 to 5. We compute a distribution ppp as a function of prediction scores yyy given by pi=y−⌊y⌋p_i = y - \lfloor y \rfloorpi​=y−⌊y⌋ if i=⌊y⌋+1i = \lfloor y \rfloor + 1i=⌊y⌋+1, pi=⌊y⌋−y+1p_i = \lfloor y \rfloor - y + 1pi​=⌊y⌋−y+1 if i=⌊y⌋i = \lfloor y \rfloori=⌊y⌋ and 0 otherwise. These then become our targets for a logistic regression classifier. At test time, given new sentence pairs we first compute targets p^\hat{p}p^​ and then compute the related score as r⊤p^r^\top \hat{p}r⊤p^​. As an additional comparison, we also explored appending features derived from an image-sentence embedding model trained on COCO (see section 3.4). Given vectors uuu and vvv, we obtain vectors u′u'u′ and v′v'v′ from the learned linear embedding model and compute features u′⋅v′u' \cdot v'u′⋅v′ and ∣u′−v′∣|u' - v'|∣u′−v′∣. These are then concatenated to the existing features.

为了表示一个句子对,我们使用两种特征。给定两个 skip-thought 向量 uuu 和 vvv,计算它们的逐维乘积 u⋅vu \cdot vu⋅v 和绝对差 ∣u−v∣|u - v|∣u−v∣,再拼接在一起。这两种特征 [22] 也使用过。预测分数时,我们采用与 [22] 相同的设定。令 r⊤=[1,…,5]r^\top = [1, \ldots, 5]r⊤=[1,…,5] 为从 1 到 5 的整数向量。由预测分数 yyy 定义分布 ppp:pi=y−⌊y⌋p_i = y - \lfloor y \rfloorpi​=y−⌊y⌋ 当 i=⌊y⌋+1i = \lfloor y \rfloor + 1i=⌊y⌋+1;pi=⌊y⌋−y+1p_i = \lfloor y \rfloor - y + 1pi​=⌊y⌋−y+1 当 i=⌊y⌋i = \lfloor y \rfloori=⌊y⌋;否则为 0。这些随后作为逻辑回归分类器的目标。测试时,对新的句子对先计算目标 p^\hat{p}p^​,再把相关分数算成 r⊤p^r^\top \hat{p}r⊤p^​。作为附加比较,我们还尝试拼接一个在 COCO 上训练的图像–句子嵌入模型所得到的特征(见第 3.4 节)。给定向量 uuu 和 vvv,从学到的线性嵌入模型得到 u′u'u′ 和 v′v'v′,再计算特征 u′⋅v′u' \cdot v'u′⋅v′ 和 ∣u′−v′∣|u' - v'|∣u′−v′∣,并拼到已有特征上。

Table 3 (left) presents our results. First, we observe that our models are able to outperform all previous systems from the SemEval 2014 competition. It highlights that skip-thought vectors learn representations that are well suited for semantic relatedness. Our results are comparable to LSTMs whose representations are trained from scratch on this task. Only the dependency tree-LSTM of [22] performs better than our results. We note that the dependency tree-LSTM relies on parsers whose training data is very expensive to collect and does not exist for all languages. We also observe using features learned from an image-sentence embedding model on COCO gives an additional performance boost, resulting in a model that performs on par with the dependency tree-LSTM. To get a feel for the model outputs, Table 4 shows example cases of test set pairs. Our model is able to accurately predict relatedness on many challenging cases. On some examples, it fails to pick up on small distinctions that drastically change a sentence meaning, such as tricks on a motorcycle versus tricking a person on a motorcycle.

表 3(左)给出了我们的结果。首先可以看到,我们的模型超过了 SemEval 2014 竞赛中此前的全部系统。这说明 skip-thought 向量学到的表示很适合语义相关度。我们的结果与在该任务上从零训练表示的 LSTM 相当。只有 [22] 的依存树 LSTM 比我们更好。需要指出的是,依存树 LSTM 依赖句法分析器,其训练数据收集成本很高,而且并非所有语言都有。我们还看到,使用在 COCO 上由图像–句子嵌入模型学到的特征会再带来提升,得到的模型与依存树 LSTM 表现相当。为了直观感受模型输出,表 4 给出了测试集句对的例子。在许多有挑战性的例子上,模型能准确预测相关度。在有些例子上,它未能抓住会大幅改变句义的细微差别,例如在摩托车上做特技(tricks on a motorcycle)与欺骗摩托车上的人(tricking a person on a motorcycle)。

Method rrr ρ\rhoρ MSE Method Acc F1
Illinois-LH [18] 0.7993 0.7538 0.3692 feats [24] 73.2
UNAL-NLP [19] 0.8070 0.7489 0.3550 RAE+DP [24] 72.6
Meaning Factory [20] 0.8268 0.7721 0.3224 RAE+feats [24] 74.2
ECNU [21] 0.8414 – – RAE+DP+feats [24] 76.8 83.6
Mean vectors [22] 0.7577 0.6738 0.4557 FHS [25] 75.0 82.7
DT-RNN [23] 0.7923 0.7319 0.3822 PE [26] 76.1 82.7
SDT-RNN [23] 0.7900 0.7304 0.3848 WDDP [27] 75.6 83.0
LSTM [22] 0.8528 0.7911 0.2831 MTMETRICS [28] 77.4 84.1
Bidirectional LSTM [22] 0.8567 0.7966 0.2736 TF-KLD [29] 80.4 86.0
Dependency Tree-LSTM [22] 0.8676 0.8083 0.2532 bow 67.8 80.3
bow 0.7823 0.7235 0.3975 uni-skip 73.0 81.9
uni-skip 0.8477 0.7780 0.2872 bi-skip 71.2 81.2
bi-skip 0.8405 0.7696 0.2995 combine-skip 73.0 82.0
combine-skip 0.8584 0.7916 0.2687 combine-skip + feats 75.8 83.0
combine-skip+COCO 0.8655 0.7995 0.2561

Table 3: Left: Test set results on the SICK semantic relatedness subtask. The evaluation metrics are Pearson’s rrr, Spearman’s ρ\rhoρ, and mean squared error. The first group of results are SemEval 2014 submissions, while the second group are results reported by [22]. Right: Test set results on the Microsoft Paraphrase Corpus. The evaluation metrics are classification accuracy and F1 score. Top: recursive autoencoder variants. Middle: the best published results on this dataset.

Method rrr ρ\rhoρ MSE Method Acc F1
Illinois-LH [18] 0.7993 0.7538 0.3692 feats [24] 73.2
UNAL-NLP [19] 0.8070 0.7489 0.3550 RAE+DP [24] 72.6
Meaning Factory [20] 0.8268 0.7721 0.3224 RAE+feats [24] 74.2
ECNU [21] 0.8414 – – RAE+DP+feats [24] 76.8 83.6
Mean vectors [22] 0.7577 0.6738 0.4557 FHS [25] 75.0 82.7
DT-RNN [23] 0.7923 0.7319 0.3822 PE [26] 76.1 82.7
SDT-RNN [23] 0.7900 0.7304 0.3848 WDDP [27] 75.6 83.0
LSTM [22] 0.8528 0.7911 0.2831 MTMETRICS [28] 77.4 84.1
Bidirectional LSTM [22] 0.8567 0.7966 0.2736 TF-KLD [29] 80.4 86.0
Dependency Tree-LSTM [22] 0.8676 0.8083 0.2532 bow 67.8 80.3
bow 0.7823 0.7235 0.3975 uni-skip 73.0 81.9
uni-skip 0.8477 0.7780 0.2872 bi-skip 71.2 81.2
bi-skip 0.8405 0.7696 0.2995 combine-skip 73.0 82.0
combine-skip 0.8584 0.7916 0.2687 combine-skip + feats 75.8 83.0
combine-skip+COCO 0.8655 0.7995 0.2561

表 3:左:SICK 语义相关度子任务的测试集结果。评价指标是 Pearson 相关系数 rrr、Spearman 相关系数 ρ\rhoρ 和均方误差。第一组是 SemEval 2014 提交系统,第二组是 [22] 报告的结果。右:Microsoft 释义语料的测试集结果。评价指标是分类准确率和 F1。上:递归自编码器变体。中:该数据集上当时最好的已发表结果。

Sentence 1 Sentence 2 GT pred
A little girl is looking at a woman in costume A young girl is looking at a woman in costume 4.7 4.5
A little girl is looking at a woman in costume The little girl is looking at a man in costume 3.8 4.0
A little girl is looking at a woman in costume A little girl in costume looks like a woman 2.9 3.5
A sea turtle is hunting for fish A sea turtle is hunting for food 4.5 4.5
A sea turtle is not hunting for fish A sea turtle is hunting for fish 3.4 3.8
A man is driving a car The car is being driven by a man 5 4.9
There is no man driving the car A man is driving a car 3.6 3.5
A large duck is flying over a rocky stream A duck, which is large, is flying over a rocky stream 4.8 4.9
A large duck is flying over a rocky stream A large stream is full of rocks, ducks and flies 2.7 3.1
A person is performing acrobatics on a motorcycle A person is performing tricks on a motorcycle 4.3 4.4
A person is performing tricks on a motorcycle The performer is tricking a person on a motorcycle 2.6 4.4
Someone is pouring ingredients into a pot Someone is adding ingredients to a pot 4.4 4.0
Nobody is pouring ingredients into a pot Someone is pouring ingredients into a pot 3.5 4.2
Someone is pouring ingredients into a pot A man is removing vegetables from a pot 2.4 3.6

Table 4: Example predictions from the SICK test set. GT is the ground truth relatedness, scored between 1 and 5. The last few results show examples where slight changes in sentence structure result in large changes in relatedness which our model was unable to score correctly.

Sentence 1 Sentence 2 GT pred
A little girl is looking at a woman in costume A young girl is looking at a woman in costume 4.7 4.5
A little girl is looking at a woman in costume The little girl is looking at a man in costume 3.8 4.0
A little girl is looking at a woman in costume A little girl in costume looks like a woman 2.9 3.5
A sea turtle is hunting for fish A sea turtle is hunting for food 4.5 4.5
A sea turtle is not hunting for fish A sea turtle is hunting for fish 3.4 3.8
A man is driving a car The car is being driven by a man 5 4.9
There is no man driving the car A man is driving a car 3.6 3.5
A large duck is flying over a rocky stream A duck, which is large, is flying over a rocky stream 4.8 4.9
A large duck is flying over a rocky stream A large stream is full of rocks, ducks and flies 2.7 3.1
A person is performing acrobatics on a motorcycle A person is performing tricks on a motorcycle 4.3 4.4
A person is performing tricks on a motorcycle The performer is tricking a person on a motorcycle 2.6 4.4
Someone is pouring ingredients into a pot Someone is adding ingredients to a pot 4.4 4.0
Nobody is pouring ingredients into a pot Someone is pouring ingredients into a pot 3.5 4.2
Someone is pouring ingredients into a pot A man is removing vegetables from a pot 2.4 3.6

表 4:SICK 测试集上的预测例子。GT 是介于 1 到 5 的真实相关度。最后几行给出了句子结构的细微变化会带来相关度大幅变化、而模型未能正确打分的例子。句对按官方 PDF 原文列出,不另行译出。

3.3 Paraphrase detection

3.3 释义识别

The next task we consider is paraphrase detection on the Microsoft Research Paraphrase Corpus [31]. On this task, two sentences are given and one must predict whether or not they are paraphrases. The training set consists of 4076 sentence pairs (2753 which are positive) and the test set has 1725 pairs (1147 are positive). We compute a vector representing the pair of sentences in the same way as on the SICK dataset, using the component-wise product u⋅vu \cdot vu⋅v and their absolute difference ∣u−v∣|u - v|∣u−v∣ which are then concatenated together. We then train logistic regression on top to predict whether the sentences are paraphrases. Cross-validation is used for tuning the L2L2L2 penalty.

下一项任务是 Microsoft Research Paraphrase Corpus [31] 上的释义识别。该任务给定两个句子,需要预测它们是否构成释义。训练集有 4076 对句子(其中 2753 对为正例),测试集有 1725 对(其中 1147 对为正例)。我们用与 SICK 数据集相同的方式计算句对向量:把逐维乘积 u⋅vu \cdot vu⋅v 和绝对差 ∣u−v∣|u - v|∣u−v∣ 拼接起来。然后在上面训练逻辑回归,预测两个句子是否为释义。用交叉验证来调节 L2L2L2 惩罚。

As in the semantic relatedness task, paraphrase detection has largely been dominated by extensive feature engineering, or a combination of feature engineering with semantic spaces. We report experiments in two settings: one using the features as above and the other incorporating basic statistics between sentence pairs, the same features used by [24]. These are referred to as feats in our results. We isolate the results and baselines used in [24] as well as the top published results on this task.

与语义相关度任务类似,释义识别在很大程度上也被大量特征工程、或特征工程与语义空间的组合所主导。我们报告两种设定下的实验:一种只用上面的特征,另一种再纳入句子对之间的基本统计量,也就是 [24] 使用的那些特征。结果中把后者称作 feats。我们单独列出 [24] 所用的结果与基线,以及该任务上当时最好的已发表结果。

Table 3 (right) presents our results, from which we can observe the following: (1) skip-thoughts alone outperform recursive nets with dynamic pooling when no hand-crafted features are used, (2) when other features are used, recursive nets with dynamic pooling works better, and (3) when skip-thoughts are combined with basic pairwise statistics, it becomes competitive with the state-of-the-art which incorporate much more complicated features and hand-engineering. This is a promising result as many of the sentence pairs have very fine-grained details that signal if they are paraphrases.

表 3(右)给出了我们的结果,从中可以看到:(1) 在不使用手工特征时,仅用 skip-thoughts 就超过了带动态池化的递归网络;(2) 在使用其他特征时,带动态池化的递归网络更好;(3) 当 skip-thoughts 与基本的成对统计量结合时,可以与采用更复杂特征和手工设计的当时最好方法相竞争。这是一个有希望的结果,因为许多句对都有非常细的细节,用来指示它们是否构成释义。

3.4 Image-sentence ranking

3.4 图像–句子排序

We next consider the task of retrieving images and their sentence descriptions. For this experiment, we use the Microsoft COCO dataset [35] which is the largest publicly available dataset of images with high-quality sentence descriptions. Each image is annotated with 5 captions, each from different annotators. Following previous work, we consider two tasks: image annotation and image search. For image annotation, an image is presented and sentences are ranked based on how well they describe the query image. The image search task is the reverse: given a caption, we retrieve images that are a good fit to the query. The training set comes with over 80,000 images each with 5 captions. For development and testing we use the same splits as [32]. The development and test sets each contain 1000 images and 5000 captions. Evaluation is performed using Recall@KKK, namely the mean number of images for which the correct caption is ranked within the top-KKK retrieved results (and vice-versa for sentences). We also report the median rank of the closest ground truth result from the ranked list.

接下来考虑检索图像及其句子描述的任务。本实验使用 Microsoft COCO 数据集 [35],这是当时公开可得、带高质量句子描述的最大图像数据集。每张图像配有 5 条由不同标注者写下的说明。沿用已有工作,我们考虑两项任务:图像标注和图像检索。图像标注是给出一张图像,按句子对查询图像的描述好坏排序。图像检索则相反:给定一条说明,检索与查询相配的图像。训练集有超过 80,000 张图像,每张配 5 条说明。开发和测试使用与 [32] 相同的划分。开发集和测试集各含 1000 张图像和 5000 条说明。评价使用 Recall@KKK,即正确说明排在检索结果前 KKK 名的图像所占比例(句子检索则对调)。我们还报告排序列表中最近真实结果的中位名次。

The best performing results on image-sentence ranking have all used RNNs for encoding sentences, where the sentence representation is learned jointly. Recently, [33] showed that by using Fisher vectors for representing sentences, linear CCA can be applied to obtain performance that is as strong as using RNNs for this task. Thus the method of [33] is a strong baseline to compare our sentence representations with. For our experiments, we represent images using 4096-dimensional OxfordNet features from their 19-layer model [36]. For sentences, we simply extract skip-thought vectors for each caption. The training objective we use is a pairwise ranking loss that has been previously used by many other methods. The only difference is the scores are computed using only linear transformations of image and sentence inputs. The loss is given by:

图像–句子排序上当时最好的结果都用 RNN 编码句子,并且句子表示是联合学习的。最近,[33] 表明,用 Fisher 向量表示句子后,再使用线性 CCA,就可以得到与该任务上使用 RNN 相当的表现。因此 [33] 的方法是比较我们句子表示的强基线。实验中,图像用其 19 层模型 [36] 的 4096 维 OxfordNet 特征表示。句子则直接为每条说明提取 skip-thought 向量。训练目标是许多方法都用过的成对排序损失。唯一的不同是,分数只通过对图像和句子输入做线性变换来计算。损失为:

∑x∑kmax⁡{0,α−s(Ux,Vy)+s(Ux,Vyk)}+∑y∑kmax⁡{0,α−s(Vy,Ux)+s(Vy,Uxk)},\sum_x \sum_k \max\{0, \alpha - s(Ux, Vy) + s(Ux, Vy_k)\} + \sum_y \sum_k \max\{0, \alpha - s(Vy, Ux) + s(Vy, Ux_k)\},x∑​k∑​max{0,α−s(Ux,Vy)+s(Ux,Vyk​)}+y∑​k∑​max{0,α−s(Vy,Ux)+s(Vy,Uxk​)},

where xxx is an image vector, yyy is the skip-thought vector for the groundtruth sentence, yky_kyk​ are vectors for constrastive (incorrect) sentences and s(⋅,⋅)s(\cdot, \cdot)s(⋅,⋅) is the image-sentence score. Cosine similarity is used for scoring. The model parameters are {U,V}\{U, V\}{U,V} where UUU is the image embedding matrix and VVV is the sentence embedding matrix. In our experiments, we use a 1000 dimensional embedding, margin α=0.2\alpha = 0.2α=0.2 and k=50k = 50k=50 contrastive terms. We trained for 15 epochs and saved our model anytime the performance improved on the development set.

∑x∑kmax⁡{0,α−s(Ux,Vy)+s(Ux,Vyk)}+∑y∑kmax⁡{0,α−s(Vy,Ux)+s(Vy,Uxk)},\sum_x \sum_k \max\{0, \alpha - s(Ux, Vy) + s(Ux, Vy_k)\} + \sum_y \sum_k \max\{0, \alpha - s(Vy, Ux) + s(Vy, Ux_k)\},x∑​k∑​max{0,α−s(Ux,Vy)+s(Ux,Vyk​)}+y∑​k∑​max{0,α−s(Vy,Ux)+s(Vy,Uxk​)},

其中 xxx 是图像向量,yyy 是真实句子的 skip-thought 向量,yky_kyk​ 是对比(不正确)句子的向量,s(⋅,⋅)s(\cdot, \cdot)s(⋅,⋅) 是图像–句子分数。原文作 constrastive。打分使用余弦相似度。模型参数为 {U,V}\{U, V\}{U,V},其中 UUU 是图像嵌入矩阵,VVV 是句子嵌入矩阵。实验中使用 1000 维嵌入,间隔 α=0.2\alpha = 0.2α=0.2,对比项 k=50k = 50k=50。训练 15 个周期,每当开发集表现提升就保存模型。

Table 5 illustrates our results on this task. Using skip-thought vectors for sentences, we get performance that is on par with both [32] and [33] except for R@1 on image annotation, where other methods perform much better. Our results indicate that skip-thought vectors are representative enough to capture image descriptions without having to learn their representations from scratch. Combined with the results of [33], it also highlights that simple, scalable embedding techniques perform very well provided that high-quality image and sentence vectors are available.

表 5 给出了这项任务上的结果。用 skip-thought 向量表示句子时,除图像标注的 R@1 上其他方法明显更好之外,整体表现与 [32] 和 [33] 相当。结果表明,skip-thought 向量已经有足够的代表性来抓住图像描述,而不必从零学习它们的表示。结合 [33] 的结果也可以看出:只要有高质量的图像向量和句向量,简单、可扩展的嵌入方法就能表现得很好。

| | Image Annotation | | | | Image Search | | | |
| Method | R@1 | R@5 | R@10 | Med rrr | R@1 | R@5 | R@10 | Med rrr |
| Random Ranking | 0.1 | 0.6 | 1.1 | 631 | 0.1 | 0.5 | 1.0 | 500 |
| DVSA [32] | 38.4 | 69.6 | 80.5 | 1 | 27.4 | 60.2 | 74.8 | 3 |
| GMM+HGLMM [33] | 39.4 | 67.9 | 80.9 | 2 | 25.1 | 59.8 | 76.6 | 4 |
| m-RNN [34] | 41.0 | 73.0 | 83.5 | 2 | 29.0 | 42.2 | 77.0 | 3 |
| bow | 33.6 | 65.8 | 79.7 | 3 | 24.4 | 57.1 | 73.5 | 4 |
| uni-skip | 30.6 | 64.5 | 79.8 | 3 | 22.7 | 56.4 | 71.7 | 4 |
| bi-skip | 32.7 | 67.3 | 79.6 | 3 | 24.2 | 57.1 | 73.2 | 4 |
| combine-skip | 33.8 | 67.7 | 82.1 | 3 | 25.9 | 60.0 | 74.6 | 4 |

Table 5: COCO test-set results for image-sentence retrieval experiments. R@KKK is Recall@KKK (high is good). Med rrr is the median rank (low is good). Official table header also reads “COCO Retrieval”.

| | Image Annotation | | | | Image Search | | | |
| Method | R@1 | R@5 | R@10 | Med rrr | R@1 | R@5 | R@10 | Med rrr |
| Random Ranking | 0.1 | 0.6 | 1.1 | 631 | 0.1 | 0.5 | 1.0 | 500 |
| DVSA [32] | 38.4 | 69.6 | 80.5 | 1 | 27.4 | 60.2 | 74.8 | 3 |
| GMM+HGLMM [33] | 39.4 | 67.9 | 80.9 | 2 | 25.1 | 59.8 | 76.6 | 4 |
| m-RNN [34] | 41.0 | 73.0 | 83.5 | 2 | 29.0 | 42.2 | 77.0 | 3 |
| bow | 33.6 | 65.8 | 79.7 | 3 | 24.4 | 57.1 | 73.5 | 4 |
| uni-skip | 30.6 | 64.5 | 79.8 | 3 | 22.7 | 56.4 | 71.7 | 4 |
| bi-skip | 32.7 | 67.3 | 79.6 | 3 | 24.2 | 57.1 | 73.2 | 4 |
| combine-skip | 33.8 | 67.7 | 82.1 | 3 | 25.9 | 60.0 | 74.6 | 4 |

表 5:COCO 测试集上的图像–句子检索实验结果。R@KKK 是 Recall@KKK(越高越好)。Med rrr 是中位名次(越低越好)。官方表头还写有 “COCO Retrieval”。

3.5 Classification benchmarks

3.5 分类基准

For our final quantitative experiments, we report results on several classification benchmarks which are commonly used for evaluating sentence representation learning methods. We use 5 datasets: movie review sentiment (MR), customer product reviews (CR), subjectivity/objectivity classification (SUBJ), opinion polarity (MPQA) and question-type classification (TREC). On all datasets, we simply extract skip-thought vectors and train a logistic regression classifier on top. 10-fold cross-validation is used for evaluation on the first 4 datasets, while TREC has a pre-defined train/test split. We tune the L2L2L2 penality using cross-validation (and thus use a nested cross-validation for the first 4 datasets).

作为最后的定量实验,我们在若干常用于评估句子表示学习方法的分类基准上报告结果。使用 5 个数据集:电影评论情感(MR)、客户产品评论(CR)、主观/客观分类(SUBJ)、观点极性(MPQA)和问句类型分类(TREC)。在所有数据集上,我们只提取 skip-thought 向量,再在上面训练逻辑回归分类器。前 4 个数据集用 10 折交叉验证评估,TREC 则有预先划好的训练/测试划分。用交叉验证调节 L2L2L2 惩罚(原文作 L2L2L2 penality),因此前 4 个数据集使用嵌套交叉验证。

On these tasks, properly tuned bag-of-words models have been shown to perform exceptionally well. In particular, the NB-SVM of [37] is a fast and robust performer on these tasks. Skip-thought vectors potentially give an alternative to these baselines being just as fast and easy to use. For an additional comparison, we also see to what effect augmenting skip-thoughts with bigram Naive Bayes (NB) features improves performance^{3}.

在这些任务上,调好的词袋模型已被证明表现非常出色。尤其是 [37] 的 NB-SVM,在这些任务上又快又稳健。skip-thought 向量有可能成为这些基线的替代,同样快、同样好用。作为附加比较,我们还考察把 skip-thoughts 与 bigram 朴素贝叶斯(NB)特征结合,能在多大程度上提高表现^{3}。

^{3}We use the code available at https://github.com/mesnilgr/nbsvm

Table 6 presents our results. On most tasks, skip-thoughts performs about as well as the bag-of-words baselines but fails to improve over methods whose sentence representations are learned directly for the task at hand. This indicates that for tasks like sentiment classification, tuning the representations, even on small datasets, are likely to perform better than learning a generic unsupervised sentence vector on much bigger datasets. Finally, we observe that the skip-thoughts-NB combination is effective, particularly on MR. This results in a very strong new baseline for text classification: combine skip-thoughts with bag-of-words and train a linear model.

表 6 给出了我们的结果。在多数任务上,skip-thoughts 与词袋基线大致相当,但未能超过那些直接为当前任务学习句子表示的方法。这说明,对于情感分类这类任务,即使在小数据集上调节表示,也可能比在大得多的数据集上学习通用的无监督句向量更好。最后我们看到,skip-thoughts 与 NB 的组合是有效的,在 MR 上尤其明显。由此得到一个很强的文本分类新基线:把 skip-thoughts 与词袋结合,再训练线性模型。

Method MR CR SUBJ MPQA TREC
NB-SVM [37] 79.4 81.8 93.2 86.3
MNB [37] 79.0 80.0 93.6 86.3
cBoW [6] 77.2 79.9 91.3 86.4 87.3
GrConv [6] 76.3 81.3 89.5 84.5 88.4
RNN [6] 77.2 82.3 93.7 90.1 90.2
BRNN [6] 82.3 82.6 94.2 90.3 91.0
CNN [4] 81.5 85.0 93.4 89.6 93.6
AdaSent [6] 83.1 86.3 95.5 93.3 92.4
Paragraph-vector [7] 74.8 78.1 90.5 74.2 91.8
bow 75.0 80.4 91.2 87.0 84.8
uni-skip 75.5 79.3 92.1 86.9 91.4
bi-skip 73.9 77.9 92.5 83.3 89.4
combine-skip 76.5 80.1 93.6 87.1 92.2
combine-skip + NB 80.4 81.3 93.6 87.5

Table 6: Classification accuracies on several standard benchmarks. Results are grouped as follows: (a): bag-of-words models; (b): supervised compositional models; (c) Paragraph Vector (unsupervised learning of sentence representations); (d) ours. Best results overall are bold while best results outside of group (b) are underlined.

Method MR CR SUBJ MPQA TREC
NB-SVM [37] 79.4 81.8 93.2 86.3
MNB [37] 79.0 80.0 93.6 86.3
cBoW [6] 77.2 79.9 91.3 86.4 87.3
GrConv [6] 76.3 81.3 89.5 84.5 88.4
RNN [6] 77.2 82.3 93.7 90.1 90.2
BRNN [6] 82.3 82.6 94.2 90.3 91.0
CNN [4] 81.5 85.0 93.4 89.6 93.6
AdaSent [6] 83.1 86.3 95.5 93.3 92.4
Paragraph-vector [7] 74.8 78.1 90.5 74.2 91.8
bow 75.0 80.4 91.2 87.0 84.8
uni-skip 75.5 79.3 92.1 86.9 91.4
bi-skip 73.9 77.9 92.5 83.3 89.4
combine-skip 76.5 80.1 93.6 87.1 92.2
combine-skip + NB 80.4 81.3 93.6 87.5

表 6:若干标准基准上的分类准确率。结果分组如下:(a) 词袋模型;(b) 监督组合模型;(c) 段落向量(无监督句子表示学习);(d) 我们的方法。总体最好结果加粗,(b) 组以外的最好结果加下划线。combine-skip 与 combine-skip + NB 在 SUBJ 上的 93.6 与 MNB 持平,官方表中仅对 MNB 加下划线;combine-skip + NB 的 TREC 一栏为空白。

3.6 Visualizing skip-thoughts

3.6 可视化 skip-thoughts

As a final experiment, we applied t-SNE [38] to skip-thought vectors extracted from TREC, SUBJ and SICK datasets and the visualizations are shown in Figure 2. For the SICK visualization, each point represents a sentence pair, computed using the concatenation of component-wise and absolute difference of features. Even without the use of relatedness labels, skip-thought vectors learn to accurately capture this property.

作为最后一个实验,我们把 t-SNE [38] 用到从 TREC、SUBJ 和 SICK 数据集提取的 skip-thought 向量上,可视化见图 2。在 SICK 的可视化里,每个点表示一个句子对,由逐维乘积与绝对差特征拼接得到。即使不使用相关度标签,skip-thought 向量也能准确抓住这一性质。

t-SNE embeddings of skip-thought vectors on TREC, SUBJ and SICK datasets

Figure 2: t-SNE embeddings of skip-thought vectors on different datasets. Points are colored based on their labels (question type for TREC, subjectivity/objectivity for SUBJ). On the SICK dataset, each point represents a sentence pair and points are colored on a gradient based on their relatedness labels. Results best seen in electronic form.

图 2:不同数据集上 skip-thought 向量的 t-SNE 嵌入。点按标签着色(TREC 为问句类型,SUBJ 为主观/客观)。在 SICK 数据集上,每个点表示一个句子对,并按相关度标签用渐变着色。结果最好在电子版中查看。

4 Conclusion

4 结论

We evaluated the effectiveness of skip-thought vectors as an off-the-shelf sentence representation with linear classifiers across 8 tasks. Many of the methods we compare against were only evaluated on 1 task. The fact that skip-thought vectors perform well on all tasks considered highlight the robustness of our representations.

我们评估了 skip-thought 向量作为现成句子表示、再接线性分类器,在 8 项任务上的效果。我们比较的许多方法只在 1 项任务上评估过。skip-thought 向量在所考虑的全部任务上都表现良好,这突出了这些表示的稳健性。

We believe our model for learning skip-thought vectors only scratches the surface of possible objectives. Many variations have yet to be explored, including (a) deep encoders and decoders, (b) larger context windows, (c) encoding and decoding paragraphs, (d) other encoders, such as convnets. It is likely the case that more exploration of this space will result in even higher quality representations.

我们认为,用于学习 skip-thought 向量的这一模型,只是刚开始触及可能的目标函数。还有许多变体尚未探索,包括 (a) 更深的编码器和解码器,(b) 更大的上下文窗口,(c) 对段落进行编码和解码,(d) 其他编码器,例如卷积网络。继续探索这一空间,很可能会得到质量更高的表示。

Acknowledgments

致谢

We thank Geoffrey Hinton for suggesting the name skip-thoughts. We also thank Felix Hill, Kelvin Xu, Kyunghyun Cho and Ilya Sutskever for valuable comments and discussion. This work was supported by NSERC, Samsung, CIFAR, Google and ONR Grant N00014-14-1-0232.

我们感谢 Geoffrey Hinton 提出 skip-thoughts 这一名称。也感谢 Felix Hill、Kelvin Xu、Kyunghyun Cho 和 Ilya Sutskever 提供的宝贵意见和讨论。本工作得到 NSERC、Samsung、CIFAR、Google 以及 ONR Grant N00014-14-1-0232 的资助。

References

参考文献

[1] Richard Socher, Alex Perelygin, Jean Y Wu, Jason Chuang, Christopher D Manning, Andrew Y Ng, and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In EMNLP, 2013.

[2] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997.

[3] Nal Kalchbrenner, Edward Grefenstette, and Phil Blunsom. A convolutional neural network for modelling sentences. ACL, 2014.

[4] Yoon Kim. Convolutional neural networks for sentence classification. EMNLP, 2014.

[5] Kyunghyun Cho, Bart van Merriënboer, Dzmitry Bahdanau, and Yoshua Bengio. On the properties of neural machine translation: Encoder-decoder approaches. SSST-8, 2014.

[6] Han Zhao, Zhengdong Lu, and Pascal Poupart. Self-adaptive hierarchical sentence model. IJCAI, 2015.

[7] Quoc V Le and Tomas Mikolov. Distributed representations of sentences and documents. ICML, 2014.

[8] Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean. Efficient estimation of word representations in vector space. ICLR, 2013.

[9] Yukun Zhu, Ryan Kiros, Richard S. Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In ICCV, 2015.

[10] Nal Kalchbrenner and Phil Blunsom. Recurrent continuous translation models. In EMNLP, pages 1700–1709, 2013.

[11] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. EMNLP, 2014.

[12] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural networks. In NIPS, 2014.

[13] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. ICLR, 2015.

[14] Junyoung Chung, Caglar Gulcehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. NIPS Deep Learning Workshop, 2014.

[15] Tomas Mikolov, Quoc V Le, and Ilya Sutskever. Exploiting similarities among languages for machine translation. arXiv preprint arXiv:1309.4168, 2013.

[16] Andrew M Saxe, James L McClelland, and Surya Ganguli. Exact solutions to the nonlinear dynamics of learning in deep linear neural networks. ICLR, 2014.

[17] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. ICLR, 2015.

[18] Alice Lai and Julia Hockenmaier. Illinois-lh: A denotational and distributional approach to semantics. SemEval 2014, 2014.

[19] Sergio Jimenez, George Duenas, Julia Baquero, Alexander Gelbukh, Av Juan Dios Bátiz, and Av Mendizábal. Unal-nlp: Combining soft cardinality features for semantic textual similarity, relatedness and entailment. SemEval 2014, 2014.

[20] Johannes Bjerva, Johan Bos, Rob van der Goot, and Malvina Nissim. The meaning factory: Formal semantics for recognizing textual entailment and determining semantic similarity. SemEval 2014, page 642, 2014.

[21] Jiang Zhao, Tian Tian Zhu, and Man Lan. Ecnu: One stone two birds: Ensemble of heterogenous measures for semantic relatedness and textual entailment. SemEval 2014, 2014.

[22] Kai Sheng Tai, Richard Socher, and Christopher D Manning. Improved semantic representations from tree-structured long short-term memory networks. ACL, 2015.

[23] Richard Socher, Andrej Karpathy, Quoc V Le, Christopher D Manning, and Andrew Y Ng. Grounded compositional semantics for finding and describing images with sentences. TACL, 2014.

[24] Richard Socher, Eric H Huang, Jeffrey Pennin, Christopher D Manning, and Andrew Y Ng. Dynamic pooling and unfolding recursive autoencoders for paraphrase detection. In NIPS, 2011.

[25] Andrew Finch, Young-Sook Hwang, and Eiichiro Sumita. Using machine translation evaluation techniques to determine sentence-level semantic equivalence. In IWP, 2005.

[26] Dipanjan Das and Noah A Smith. Paraphrase identification as probabilistic quasi-synchronous recognition. In ACL, 2009.

[27] Stephen Wan, Mark Dras, Robert Dale, and Cécile Paris. Using dependency-based features to take the "para-farce" out of paraphrase. In Proceedings of the Australasian Language Technology Workshop, 2006.

[28] Nitin Madnani, Joel Tetreault, and Martin Chodorow. Re-examining machine translation metrics for paraphrase identification. In NAACL, 2012.

[29] Yangfeng Ji and Jacob Eisenstein. Discriminative improvements to distributional sentence similarity. In EMNLP, pages 891–896, 2013.

[30] Marco Marelli, Luisa Bentivogli, Marco Baroni, Raffaella Bernardi, Stefano Menini, and Roberto Zamparelli. Semeval-2014 task 1: Evaluation of compositional distributional semantic models on full sentences through semantic relatedness and textual entailment. SemEval-2014, 2014.

[31] Bill Dolan, Chris Quirk, and Chris Brockett. Unsupervised construction of large paraphrase corpora: Exploiting massively parallel news sources. In Proceedings of the 20th international conference on Computational Linguistics, 2004.

[32] A. Karpathy and L. Fei-Fei. Deep visual-semantic alignments for generating image descriptions. In CVPR, 2015.

[33] Benjamin Klein, Guy Lev, Gil Sadeh, and Lior Wolf. Associating neural word embeddings with deep image representations using fisher vectors. In CVPR, 2015.

[34] Junhua Mao, Wei Xu, Yi Yang, Jiang Wang, and Alan Yuille. Deep captioning with multimodal recurrent neural networks (m-rnn). ICLR, 2015.

[35] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, pages 740–755. 2014.

[36] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. ICLR, 2015.

[37] Sida Wang and Christopher D Manning. Baselines and bigrams: Simple, good sentiment and topic classification. In ACL, 2012.

[38] Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. JMLR, 2008.