Add vectors to nlp model using terms.train-vectors

@damiano The way we do it in terms.train-vectors should work. You can add this to your script:


nlp.vocab.reset_vectors(width=size)
for word in w2v.wv.vocab:
    nlp.vocab.set_vector(word, w2v.wv.word_vec(word))
nlp.to_disk(output_model)

This should save you a spaCy model directory, that you can then load directly. You can use an nlp object with pre-trained models, in which case you’ll get one with pre-trained models and pre-trained vectors. Make sure you’re using an sm model if that’s the case.

1 Like