简体   繁体   中英

Upload a pre-trained spanish language word vectors and then retrain it with custom sentences? (GENSIM -FASTTEXT)

I am trying to upload a pre-trained spanish language word vectors and then retrain it with custom sentences:

!pip install fasttext
import fasttext
import fasttext.util
#download pre-trained spanish language word vectors c
fasttext.util.download_model('es', if_exists='ignore')  # Spanish
ft = fasttext.load_model('cc.es.300.bin')

but once I try to update the vocabulary it gives me this AttributeError:

ft.build_vocab(sentences, update=True)
AttributeError: '_FastText' object has no attribute 'build_vocab'

Any advices?

The build_vocab() method supports a step in the Gensim library implementation of the FastText algorithm - not the original fastttext package from Facebook that you seem to be loading. (You're mixing code meant for two different libraries.)

If you switch to using Gensim code, rather than Facebook's implementation, you won't get that same error when trying to use build_vocab() .

Note, though, that what you're attempting, incremental retraining of an existing model, is an advanced/experimental technique that can easily backfire. So it's usually a bad idea to attempt without expertise & rigorous checks as to whether the extra complications are helping.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM