Fasttext model loaded with gensim won't continue training with new sentences

361 Views Asked by At

I am trying to load a fasttext .bin model in spanish, donwloaded from https://fasttext.cc/docs/en/crawl-vectors.html and continue training it with new sentences from the specific domain I am interested in.

System: Anaconda, Jupyter Notebook, Python 3.6, Upgraded Gensim

My code (toy example):

from gensim.models.fasttext import load_facebook_model
import os
os.chdir('path/to/directory')
model = load_facebook_model('cc.es.300.bin')

'enmadrarse' in model.wv.vocab
>>> False
old_vector = np.copy(model.wv['enmadrarse'])

new_sentences = [['complexidad', 'cataratas', 'enmadrarse'],
['enmadrarse', 'cataratas', 'increibles'], 
['unidad','enmadrarse','complexa']]

model.build_vocab(new_sentences, update = True)
model.train(new_sentences, total_examples = len(new_sentences), epochs=model.epochs)

new_vector = np.copy(model.wv['enmadrarse'])
np.allclose(old_vector, new_vector, atol=1e-4)
>>> True

'enmadrarse' in model.wv.vocab
>>> False (still)

The old and new vectors of the word are equal and it remains out of the vocab so the model learnt nothing. What am I doing wrong?

0

There are 0 best solutions below