对于Gensim 4.0,如何使用预先训练好的模型,并用我自己的语料库进一步训练?

时间:2021-04-16 02:06:28

标签: nlp gensim word2vec word-embedding pre-trained-model

对于 Gensim 3.8,我可以使用以下脚本用预训练权重初始化模型,然后在我自己的语料库上训练它。如何在 Gensim 4.0 中做到这一点?

mod = Word2Vec(size=300, min_count=5, workers=1, sg=1, seed=1)
mod.build_vocab(my_corpus)
mod.min_count = 0
pret_mod = KeyedVectors.load_word2vec_format("GoogleNews-vectors-negative300.bin", binary=True)
mod.build_vocab([list(pret_mod.vocab.keys())], update=True)
mod.intersect_word2vec_format("GoogleNews-vectors-negative300.bin", binary=True, lockf=1.0)
mod.train(my_corpus, total_examples=mod.corpus_count, epochs=mod.iter)

0 个答案:

没有答案