koaning/whatlies

ImportError: cannot import name 'UniversalSentenceLanguage' from 'whatlies.language'

Rmsharks4 opened this issue · 1 comments

Hi Team! Facing the following error on UniversalSentenceLanguage import:

import pathlib 
import numpy as np
from whatlies.language import CountVectorLanguage, UniversalSentenceLanguage, BytePairLanguage, SentenceTFMLanguage
from whatlies.transformers import Pca, Umap
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-6ecfd2b2c4c1> in <module>
      1 import pathlib
      2 import numpy as np
----> 3 from whatlies.language import CountVectorLanguage, UniversalSentenceLanguage, BytePairLanguage, SentenceTFMLanguage
      4 from whatlies.transformers import Pca, Umap

ImportError: cannot import name 'UniversalSentenceLanguage' from 'whatlies.language' (c:\users\rsiddiqui\anaconda3\envs\newenv\lib\site-packages\whatlies\language\__init__.py)

Edit: above error occurs on whatlies version 0.4.3 - if I upgrade to 0.5.7, this error goes away, but a new one arises, which does not get solved with proposed remedy:

lang_cv  = CountVectorLanguage(10)
lang_use = UniversalSentenceLanguage("large")
lang_bp  = BytePairLanguage("en", dim=300, vs=200_000)
lang_brt = SentenceTFMLanguage('distilbert-base-nli-stsb-mean-tokens')
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-77ddbd9218cf> in <module>
      1 lang_cv  = CountVectorLanguage(10)
----> 2 lang_use = UniversalSentenceLanguage("large")
      3 lang_bp  = BytePairLanguage("en", dim=300, vs=200_000)
      4 lang_brt = SentenceTFMLanguage('distilbert-base-nli-stsb-mean-tokens')

c:\users\rsiddiqui\anaconda3\envs\newenv\lib\site-packages\whatlies\error.py in __call__(self, *args, **kwargs)
     20 
     21     def __call__(self, *args, **kwargs):
---> 22         raise ModuleNotFoundError(self.msg)

ModuleNotFoundError: In order to use UniversalSentenceLanguage you'll need to install via;

pip install whatlies[tfhub]

See installation guide here: https://rasahq.github.io/whatlies/#installation.

Resolved by installing tensorflow==2.4.0 and tensorflow_text along with it. Closing this issue.