Skip to content Skip to sidebar Skip to footer

Gensim Word2vec Freeze Some Wordvectors And Update Others

Regarding word2vec with gensim, Suppose you already trained a model on a big corpus, and you want to update it with new words from new sentences, but not update the words which alr

Solution 1:

There is! But it's an experimental feature with little documentation – you'd need to read the source to fully understand it, and directly mutate your model to make use of it.

Look through the word2vec.py source for properties ending _lockf – specifically in the latest code, one named vectors_lockf. It's a sort of mask which either allows, weakens, or stops training of certain words. For each word, if it's value is 1.0, normal full backpropagated updates are applied. Any lower value weakens the update – so 0.0 freezes a word against updates. (The potential update is still calculated – so there's no net speedup – it's just multiplied-by-0.0 before final application to particular frozen words.)

Post a Comment for "Gensim Word2vec Freeze Some Wordvectors And Update Others"