比方说,word2vec.model是我训练有素的word2vec模型。当出现单词外单词(oov_word)时,我使用compute_vec(oov_word)方法计算向量vec。现在,我想将oov_word及其对应的向量vec添加/追加到我已经训练的模型word2vec.model。
我已经检查了以下链接。但是他们没有回答我的问题。
from gensim.models.keyedvectors import WordEmbeddingsKeyedVectors
vector_length = 100
kv = WordEmbeddingsKeyedVectors(vector_length)
# wordList - list of words
# vectorList - list of the vector corresponding to the words
kv.add(wordList, vectorList)
kv.most_similar(word1) # gives the list of words similar to word1