一、原理
skip-thought模型结构借助了skip-gram的思想。在skip-gram中,是以中心词来预测上下文的词;在skip-thought同样是利用中心句子来预测上下文的句子,其数据的结构可以用一个三元组表示 (st−1,st,st+1) ,输入值 st,输出值 (st−1,st+1),具体模型结构如下图:
二、实践
使用预训练好的Skip-Thought提取文本特征
1)Dependencies
我的电脑环境是Ubuntu 16.04,python2.7,需要在Theano 0.7运行
打开终端
pip install theano
2) Git 作者github上代码
https://github.com/ryankiros/skip-thoughts
3)下载预训练好的模型及word embedding文件(>5G),并放在skip-thoughts文件下
wget http://www.cs.toronto.edu/~rkiros/models/dictionary.txt
wget http://www.cs.toronto.edu/~rkiros/models/utable.npy
wget http://www.cs.toronto.edu/~rkiros/models/btable.npy
wget http://www.cs