BERTopic icon indicating copy to clipboard operation
BERTopic copied to clipboard

KeyError: '_version_'

Open ex808 opened this issue 2 years ago • 1 comments

I get KeyError: 'version' error when running :

topics, probs = topic_model.fit_transform(doc)

I am running in env with no internet. I get this same error with KeyBERT as well.

    283         if embeddings is None:
    284             self.embedding_model = select_backend(self.embedding_model,
--> 285                                                   language=self.language)
    286             embeddings = self._extract_embeddings(documents.Document,
    287                                                   method="document",

     63     if language:
     64         if language.lower() in ["English", "english", "en"]:
---> 65             return SentenceTransformerBackend("all-MiniLM-L6-v2")
     66         elif language.lower() in languages or language == "multilingual":
     67             return SentenceTransformerBackend("paraphrase-multilingual-MiniLM-L12-v2")
     41             self.embedding_model = embedding_model
     42         elif isinstance(embedding_model, str):
---> 43             self.embedding_model = SentenceTransformer(embedding_model)
     44         else:
     45             raise ValueError("Please select a correct SentenceTransformers model: \n"
 
//envs/py3_7n/lib/python3.7/site-packages/sentence_transformers/SentenceTransformer.py in __init__(self, model_name_or_path, modules, device)
    103                     with open(os.path.join(model_path, 'config.json')) as fIn:
    104                         config = json.load(fIn)
--> 105                         if config['__version__'] > __version__:
    106                             logger.warning("You try to use a model that was created with version {}, however, your version is {}. This might cause unexpected behavior or errors. In that case, try to update to the latest version.\n\n\n".format(config['__version__'], __version__))
    107 
 
KeyError: '__version__'

ex808 avatar Sep 02 '22 23:09 ex808

Although I am not familiar with this issue, I believe it stems from your environment. The package wants to load in a specific model from the internet and since you do not have a connection, it seems to be failing. How did you instantiate the model?

MaartenGr avatar Sep 04 '22 07:09 MaartenGr

This issue still persists. Any fix for this?

amikumar-infa avatar Oct 10 '22 14:10 amikumar-infa

@amikumar-infa Did you make sure that the environment in which you are working has ports open such that the model can be downloaded from the huggingface servers? Also, it might be worth starting from a completely fresh environment and installing BERTopic there.

MaartenGr avatar Oct 11 '22 09:10 MaartenGr

@MaartenGr I am facing the same issue, I was able to download the model (download comepleted till 100%) and post that this error poped up.

gandharvsuri avatar Oct 12 '22 04:10 gandharvsuri

@gandharvsuri Did you try starting from a completely fresh environment? That often helps in these kinds of cases. Also, did you try the other tips mentioned above?

MaartenGr avatar Oct 12 '22 12:10 MaartenGr

Due to inactivity, I'll be closing this for now. If you have any questions or want to continue the discussion, I'll make sure to re-open the issue!

MaartenGr avatar Jan 09 '23 12:01 MaartenGr