98892 個のドキュメントでトレーニングされた gensim の word2vec モデルがあります。文の配列 (つまり、モデルをトレーニングしたセット) に存在しない特定の文については、その文でモデルを更新して、次回のクエリで何らかの結果が得られるようにする必要があります。私はこのようにやっています:
new_sentence = ['moscow', 'weather', 'cold']
model.train(new_sentence)
そして、これをログとして出力します:
2014-03-01 16:46:58,061 : INFO : training model with 1 workers on 98892 vocabulary and 100 features
2014-03-01 16:46:58,211 : INFO : reached the end of input; waiting to finish 1 outstanding jobs
2014-03-01 16:46:58,235 : INFO : training on 10 words took 0.1s, 174 words/s
さて、ほとんどのポジティブ( as )に対して同様の new_sentence を使用してクエリを実行すると、model.most_similar(positive=new_sentence)
エラーが発生します。
Traceback (most recent call last):
File "<pyshell#220>", line 1, in <module>
model.most_similar(positive=['moscow', 'weather', 'cold'])
File "/Library/Python/2.7/site-packages/gensim/models/word2vec.py", line 405, in most_similar
raise KeyError("word '%s' not in vocabulary" % word)
KeyError: "word 'cold' not in vocabulary"
「寒い」という言葉は、私がそのことを訓練した語彙の一部ではないことを示しています (私は正しいですか)?
問題は次のとおりです: モデルを更新して、指定された新しい文のすべての可能な類似点を与えるにはどうすればよいでしょうか?