我试图从这里的Fasttext模型加载fastText预训练模型。我正在使用wiki.simple.en
from gensim.models.keyedvectors import KeyedVectors
word_vectors = KeyedVectors.load_word2vec_format('wiki.simple.bin', binary=True)
但是,它显示以下错误
Traceback (most recent call last):
File "nltk_check.py", line 28, in <module>
word_vectors = KeyedVectors.load_word2vec_format('wiki.simple.bin', binary=True)
File "P:\major_project\venv\lib\sitepackages\gensim\models\keyedvectors.py",line 206, in load_word2vec_format
header = utils.to_unicode(fin.readline(), encoding=encoding)
File "P:\major_project\venv\lib\site-packages\gensim\utils.py", line 235, in any2unicode
return unicode(text, encoding, errors=errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte
问题1如何在Gensim中加载fasttext模型?
问题2另外,加载模型后,我想找到两个词之间的相似性
model.find_similarity('teacher', 'teaches')
# Something like this
Output : 0.99
我该怎么做呢?
DeprecationWarning: Call to deprecated `load_fasttext_format` (use load_facebook_vectors
。所以我正在使用from gensim.models.fasttext import load_facebook_model