比如我已經通過word2vec訓練好了一個向量文件,但是當拿到新的語料,只有重新訓練,耗時耗力。請問向量文件是否有辦法動態增加? 如何實現?


其實word2vec用的是sgd,那典型的做法可以online learning。對於文件的動態增加可能不太現實,但是load到內存之後可以對新的文本繼續做training就可以了。不知道是不是希望做這個問題。
在線 query 的時候load不同的.bin文件去得到結果可能是一種比較可行的方案


Online Word2Vec by rutum · Pull Request #365 · RaRe-Technologies/gensim · GitHubgensim,Word2Vec支持在線更新
@武博文 能再具體說一下所謂load到內存繼續training的方法嗎?
gensim

train(sentences, total_words=None, word_count=0, total_examples=None, queue_factor=2, report_delay=1.0)gensim: models.word2vec a€「 Deep learning with word2vec

Update the model』s neural weights from a sequence of sentences (can be a once-only generator stream). For Word2Vec, each sentence must be a list of unicode strings. (Subclasses may accept other examples.)

To support linear learning-rate decay from (initial) alpha to min_alpha, either total_examples (count of sentences) or total_words (count of raw words in sentences) should be provided, unless the sentences are the same as those that were used to initially build the vocabulary.


gensim 的 word2vec可以實現在線學習,只需要重新構建辭彙再導入模型訓練。

原答案鏈接Update gensim word2vec model。

但是有博文說分批訓練會導致詞向量質量下降,Online Word2Vec for GensimOnline 。

供參考。


目錄路徑設定,定期更新!


推薦閱讀:
相关文章