Word2vec:
单词的向量表示,如果不清楚单词的向量表示是什么,可以参考第一篇。
word2vec通过训练一个神经网络,得到神经网络的权重作为单词的vector。
为了得到词的vecto,需要用一种更好的方式来得到,word2vec的方式考虑了该词和上下词之间的关系。所以得到的词向量可以更好的表达词的含义和词之间的关系。
通常训练word2vec的方法分类两大类分别是skip-gram 和 CBOW
如果是用一个词语作为输入,来预测它周围的上下文,那这个模型叫做『Skip-gram 模型』
而如果是拿一个词语的上下文作为输入,来预测这个词语本身,则是 『CBOW 模型』
Word2vec 本质上是一种降维操作——把词语从 one-hot encoder 形式的表示降维到 Word2vec 形式的表示。
1. Skip-gram
Skip-gram 输入词为中间词,输出为周围词。
2.CBOW
CBOW 是用上次文的词预测这一个词
输入和输出。CBOW 和skip-gram.
CBOW对小型数据库比较合适,而Skip-Gram在大型语料中表现更好。
衡量次想了的准确性
CBOW(o-c)给定上下文预测中间
Skip-gram(c-o)给的中间预测上下文
变种
1.hierarchical softmax(加速)
The hierarchical softmax uses a binary tree representation of the output layer with the W words as its leaves and, for each node, explicitly represents the relative probabilities of its child nodes. These define a random walk that assigns probabilities to words.
2.negative sampling
Noise Contrastive Estimation (NCE),NCE posits that a good model should be able to differentiate data from noise by means of logistic regression.
3.Subsampling of Frequent Words
the most frequent words can easily occur hundreds of millions of times (e.g., “in”, “the”, and “a”). Such words usually provide less information value than the rare words.
Skip-gram(c-o)给的中间预测上下文
Reference :
word2vec Parameter Learning Explained