Pre-trained FastText model not loading - Error "NameError: name 'BaseKeyedVectors' is not defined"

30 views
Skip to first unread message

alessandra stampi-bombelli

unread,
Dec 22, 2021, 4:57:13 AM12/22/21
to fastText library
Hello,

I trained some word vectors and have not been able to load them again, to access the dictionary and perform other operations. 

I get the error:

  File "~/lib/python3.7/site-packages/gensim/models/keyedvectors.py", line 224, in load
    Parameters
 "NameError: name 'BaseKeyedVectors' is not defined"

Here are the modules I have installed:

###################################
#     Modules                   ###
###################################

import matplotlib
matplotlib.use('Agg')
import numpy as np
from scipy.spatial.distance import cosine
from nltk.stem.snowball import SnowballStemmer
stemmer = SnowballStemmer("english")
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import os
import joblib
from gensim.models import Word2Vec
import random
from gensim.models import KeyedVectors
import pandas as pd
from sklearn.metrics.pairwise import cosine_similarity
import sys

And here is how I am trying to load it:
model = KeyedVectors.load('fasttext_1860-1920_100k_preprocessed.kv', mmap='r')

I have done this in the past with another model and it worked. Can someone please help me out with this?

Thank you and best regards,
Sandra
Reply all
Reply to author
Forward
0 new messages