Skip to content
Discussion options

You must be logged in to vote

I got it working by iterating the gensim model and adding each vector manually to a new spacy vocab.

from gensim.models import Word2Vec
from spacy.vocab import Vocab

gensim_model = Word2Vec.load(my_w2vmodel.model)
vocab = Vocab()

for word in gensim_model.wv.index_to_key:
      vector = gensim_model.wv.get_vector(word)
      vocab.set_vector(word, vector)

nlp.vocab.vectors = vocab.vectors

I would like to know if this could cause problems with other pipeline components and what would be the prefered way to load custom wordvectors in spacy.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@svlandeg
Comment options

Answer selected by svlandeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat / vectors Feature: Word vectors and similarity
2 participants