【发布时间】:2021-01-05 04:14:57
【问题描述】:
我有大约 82 个 gzip 文件(每个大约 180MB,总共 14GB),其中每个文件都包含换行符分隔的句子。我正在考虑使用 gensim Word2Vec 中的PathLineSentences 在词汇表上训练 word2vec 模型。这样I do not have to worry about taking all the sentences 就被列进内存了。
现在我还想让嵌入包含多词短语。但是从documentation 看来,我似乎需要一个已经训练好的短语检测器以及我拥有的所有句子,例如
from gensim.models import Phrases
# Train a bigram detector.
bigram_transformer = Phrases(all_sentences)
# Apply the trained MWE detector to a corpus, using the result to train a Word2vec model.
model = Word2Vec(bigram_transformer[all_sentences], min_count=1)
现在,我有两个问题:
- 有什么方法可以在以流式方式在每个单独文件上运行 Word2Vec 时进行短语检测?
- 如果没有,我有什么方法可以像 PathLineSentences 一样进行初始短语检测,就像以流方式进行短语检测一样?
【问题讨论】: