word2vec中的命令行参数



我想使用word2vec与当前版本的英文维基百科创建我自己的词向量语料库,但我找不到使用该程序的命令行参数的解释。在demp-script中,您可以找到以下内容:
(text8为2006年维基百科语料库)

make
if [ ! -e text8 ]; then
wget http://mattmahoney.net/dc/text8.zip -O text8.gz
gzip -d text8.gz -f
fi
time ./word2vec -train text8 -output vectors.bin -cbow 1 -size 200 -window 8 -negative 25 -hs 0 -sample 1e-4 -threads 20 -binary 1 -iter 15
./distance vectors.bin

命令行参数的含义:
vectors.bin -cbow 1 -size 200 -window 8 -negative 25 -hs 0 -sample 1e-4 -threads 20 -binary 1 -iter 15

当我有一个大约20GB(.txt文件)的维基百科文本语料库时,什么是最合适的值?我读到,对于较大的语料库,向量大小为300或500会更好。

您可以检查word2vec.c的main(),并且可以找到每个选项的解释,如下所示

printf("WORD VECTOR estimation toolkit v 0.1cnn");
printf("Options:n");
printf("Parameters for training:n");
printf("t-train <file>n");
printf("ttUse text data from <file> to train the modeln");...`

关于最合适的值,非常抱歉,我不知道答案,但你可以从源网站(Word2Vec - Google Code)的段落"性能"中找到一些提示。它说,

 - architecture: skip-gram (slower, better for infrequent words) vs CBOW (fast)
 - the training algorithm: hierarchical softmax (better for infrequent words) vs negative sampling (better for frequent words, better with low dimensional vectors)
 - sub-sampling of frequent words: can improve both accuracy and speed for large data sets (useful values are in range 1e-3 to 1e-5)
 - dimensionality of the word vectors: usually more is better, but not always
 - context (window) size: for skip-gram usually around 10, for CBOW around 5 

参数含义:

-train text8:您将在

上训练模型的语料库

-output vectors.bin:学习完模型后将其保存为二进制格式以加载并稍后使用

-cbow 1:激活"连续词袋"选项

-size 200:每个单词的向量将用200个值表示

对于word2vec的新用户,您可以通过gensim使用它在python中的实现

最新更新