Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No loop matching the specified signature and casting was found for ufunc add #202

Closed
YuanyuanLi96 opened this issue Aug 13, 2021 · 23 comments

Comments

@YuanyuanLi96
Copy link

Hi @MaartenGr, Thanks for releasing the new version of BERTopic with Guided Topic Modeling. However, I got an error message for my code

seed_topic_list = [["flight", "air", "norwegian", "aircanada", "air canada", "sas", "stopover", "air france", "airline", "airport"],
                   ["car rental", "car", "rental center", "drover", "ecars", "cars", "car hire", "rent a car", "taxi", "cab", "ground", "chauffeur", "uber"],
                   ["room", "hotel night", "reception", "hotels", "hotel", "rooms","property", "properties", "accommodation"],
                   ["sncf", "sj", "railcard", "railway", "rail", "train", "trains"]]

topic_model = BERTopic(seed_topic_list=seed_topic_list, calculate_probabilities=False)
topics, probs= topic_model.fit_transform(data_de)

The error is

if self.seed_topic_list is not None and self.embedding_model is not None:
--> 287             y, embeddings = self._guided_topic_modeling(embeddings)
TypeError: No loop matching the specified signature and casting was found for ufunc add

I don't think the error is caused by my "data_de", since it works well if I don't specify seed_topic_list. Any suggestions on fixing this error?

@MaartenGr
Copy link
Owner

Strange, I have been testing it in the last few days but I do not seem to be able to reproduce the error. Just to be sure, could you post the entire error message? I believe the true location of the error is missing in your error message.

@YuanyuanLi96
Copy link
Author

Here is the complete error message.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/var/folders/h1/ljs__fsd5gng3jj7gv62x88h0000gp/T/ipykernel_79098/2074250589.py in <module>
      5 
      6 topic_model = BERTopic(seed_topic_list=seed_topic_list, calculate_probabilities=False,min_topic_size=100)
----> 7 topics, probs= topic_model.fit_transform(data_de)

~/opt/anaconda3/lib/python3.8/site-packages/bertopic/_bertopic.py in fit_transform(self, documents, embeddings, y)
    285         # Reduce dimensionality with UMAP
    286         if self.seed_topic_list is not None and self.embedding_model is not None:
--> 287             y, embeddings = self._guided_topic_modeling(embeddings)
    288         umap_embeddings = self._reduce_dimensionality(embeddings, y)
    289 

~/opt/anaconda3/lib/python3.8/site-packages/bertopic/_bertopic.py in _guided_topic_modeling(self, embeddings)
   1424         for seed_topic in range(len(seed_topic_list)):
   1425             indices = [index for index, topic in enumerate(y) if topic == seed_topic]
-> 1426             embeddings[indices] = np.average([embeddings[indices], seed_topic_embeddings[seed_topic]], weights=[3, 1])
   1427         return y, embeddings
   1428 

<__array_function__ internals> in average(*args, **kwargs)

~/opt/anaconda3/lib/python3.8/site-packages/numpy/lib/function_base.py in average(a, axis, weights, returned)
    405             wgt = wgt.swapaxes(-1, axis)
    406 
--> 407         scl = wgt.sum(axis=axis, dtype=result_dtype)
    408         if np.any(scl == 0.0):
    409             raise ZeroDivisionError(

~/opt/anaconda3/lib/python3.8/site-packages/numpy/core/_methods.py in _sum(a, axis, dtype, out, keepdims, initial, where)
     45 def _sum(a, axis=None, dtype=None, out=None, keepdims=False,
     46          initial=_NoValue, where=True):
---> 47     return umr_sum(a, axis, dtype, out, keepdims, initial, where)
     48 
     49 def _prod(a, axis=None, dtype=None, out=None, keepdims=False,

TypeError: No loop matching the specified signature and casting was found for ufunc add

@MaartenGr
Copy link
Owner

Could you share the versions of packages in your environment? Also, have you tried installing BERTopic in a clean environment?

@YuanyuanLi96
Copy link
Author

YuanyuanLi96 commented Aug 22, 2021

Yes, I re-installed in a new environment but got the same error when run guided bertopic, here is the list of package versions:

Package                 Version
----------------------- -------------------
absl-py                 0.13.0
appnope                 0.1.2
argcomplete             1.12.3
argon2-cffi             20.1.0
astunparse              1.6.3
attrs                   21.2.0
backcall                0.2.0
bertopic                0.9.0
bleach                  4.0.0
blis                    0.7.4
bpemb                   0.3.3
cached-property         1.5.2
cachetools              4.2.2
catalogue               2.0.6
certifi                 2020.6.20
cffi                    1.14.6
charset-normalizer      2.0.4
clang                   5.0
click                   7.1.2
cloudpickle             1.6.0
cycler                  0.10.0
cymem                   2.0.5
Cython                  0.29.24
dataclasses             0.6
debugpy                 1.4.1
decorator               5.0.9
defusedxml              0.7.1
Deprecated              1.2.12
entrypoints             0.3
example                 0.1.0
filelock                3.0.12
flair                   0.7
flatbuffers             1.12
ftfy                    6.0.3
future                  0.18.2
gast                    0.3.3
gdown                   3.13.0
gensim                  3.8.3
google-auth             1.35.0
google-auth-oauthlib    0.4.5
google-pasta            0.2.0
grpcio                  1.39.0
h5py                    2.10.0
hdbscan                 0.8.27
huggingface-hub         0.0.15
hyperopt                0.2.5
idna                    3.2
importlib-metadata      3.10.1
ipykernel               6.2.0
ipython                 7.26.0
ipython-genutils        0.2.0
ipywidgets              7.6.3
Janome                  0.4.1
jedi                    0.18.0
Jinja2                  3.0.1
joblib                  1.0.1
jsonschema              3.2.0
jupyter                 1.0.0
jupyter-client          7.0.1
jupyter-console         6.4.0
jupyter-core            4.7.1
jupyterlab-pygments     0.1.2
jupyterlab-widgets      1.0.0
keras                   2.6.0
Keras-Preprocessing     1.1.2
kiwisolver              1.3.1
konoha                  4.6.5
langdetect              1.0.9
llvmlite                0.37.0
lxml                    4.6.3
Markdown                3.3.4
MarkupSafe              2.0.1
matplotlib              3.4.3
matplotlib-inline       0.1.2
mistune                 0.8.4
mpld3                   0.3
murmurhash              1.0.5
nbclient                0.5.4
nbconvert               6.1.0
nbformat                5.1.3
nest-asyncio            1.5.1
networkx                2.6.2
nltk                    3.6.2
notebook                6.4.3
numba                   0.54.0
numpy                   1.20.0
oauthlib                3.1.1
opt-einsum              3.3.0
overrides               3.1.0
packaging               21.0
pandas                  1.3.2
pandocfilters           1.4.3
parso                   0.8.2
pathy                   0.6.0
pexpect                 4.8.0
pickleshare             0.7.5
Pillow                  8.3.1
pip                     21.2.4
plotly                  4.14.2
preshed                 3.0.5
prometheus-client       0.11.0
prompt-toolkit          3.0.20
protobuf                3.17.3
ptyprocess              0.7.0
py4j                    0.10.9
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycparser               2.20
pydantic                1.8.2
Pygments                2.10.0
pynndescent             0.5.4
pyparsing               2.4.7
pyrsistent              0.18.0
PySocks                 1.7.1
pyspark                 3.1.2
python-dateutil         2.8.2
pytz                    2021.1
pyzmq                   22.2.1
qtconsole               5.1.1
QtPy                    1.10.0
regex                   2021.8.21
requests                2.26.0
requests-oauthlib       1.3.0
retrying                1.3.3
rsa                     4.7.2
sacremoses              0.0.45
scikit-learn            0.24.2
scipy                   1.4.1
segtok                  1.5.10
Send2Trash              1.8.0
sentence-transformers   1.2.1
sentencepiece           0.1.91
setuptools              49.3.1.post20200810
six                     1.16.0
smart-open              5.2.0
spacy                   3.1.2
spacy-legacy            3.0.8
sqlitedict              1.7.0
srsly                   2.4.1
tabulate                0.8.9
tensorboard             2.2.2
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
tensorflow              2.2.0
tensorflow-estimator    2.2.0
tensorflow-hub          0.12.0
tensorflow-text         2.2.1
termcolor               1.1.0
terminado               0.11.1
testpath                0.5.0
thinc                   8.0.8
threadpoolctl           2.2.0
tokenizers              0.9.3
torch                   1.7.0
torchvision             0.8.1
tornado                 6.1
tqdm                    4.62.1
traitlets               5.0.5
transformers            3.5.1
typer                   0.3.2
typing-extensions       3.7.4.3
umap-learn              0.5.1
urllib3                 1.26.6
wasabi                  0.8.2
wcwidth                 0.2.5
webencodings            0.5.1
Werkzeug                2.0.1
wheel                   0.37.0
widgetsnbextension      3.5.1
wrapt                   1.12.1
zipp                    3.5.0
​```

@MaartenGr
Copy link
Owner

Seeing as it seems to be a numpy error, could you upgrade numpy with pip install --upgrade numpy and try again?

@gsalfourn
Copy link

Hi Maarten,

I think the issue may be related to guided bertopic. When I tried to run a guided bertopic in a clean vscode environment, I run into the same issue. However, when I run the same code without the seed_topic_list (a non-guided model) the model run without any error codes. I have attached the codes I was trying out

# import umap and hdbscan modules
import umap
import hdbscan

# define umap model to reduce embeddings dimensionality
umap_model = umap.UMAP(n_neighbors=15,
                       min_dist=0.0,
                       n_components=10,
                       metric='cosine',
                       low_memory=False,
                       random_state=42)

# define hdbscan model to perform documents clustering
hdbscan_model = hdbscan.HDBSCAN(min_cluster_size=50,
                                min_samples=15,
                                metric='euclidean',
                                cluster_selection_method='eom',
                                prediction_data=True)


# topics generated from keybert search
seed_topic_list = [['customer', 'order', 'service', 
                    'quality',  'transaction', 'delivery', 
                    'shopping', 'staff', 'product',  
                    'store',  'online', 'stock',  
                    'size', 'time', 'website']]

# import bertopic module
from bertopic import BERTopic

# create bertopic model
topic_model = BERTopic(top_n_words=10,
                        min_topic_size=10,
                        n_gram_range=(1,2),
                        calculate_probabilities=True,
                        umap_model=umap_model,
                        hdbscan_model=hdbscan_model,
                        embedding_model=sentence_model,
                        seed_topic_list=seed_topic_list,
                        low_memory=False,
                        verbose=True)

# train model, extract topics and probabilities
topics, probabilities = topic_model.fit_transform(docs)

Below is the environment

Version: 1.59.1 (user setup)
Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
Date: 2021-08-19T11:56:46.957Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Windows_NT x64 10.0.19042

bertopic==0.9.0
certifi==2021.5.30
charset-normalizer==2.0.4
click==8.0.1
colorama==0.4.4
Cython==0.29.24
filelock==3.0.12
hdbscan==0.8.27
huggingface-hub==0.0.12
idna==3.2
joblib==1.0.1
llvmlite==0.37.0
nltk==3.6.2
numba==0.54.0
numpy==1.20.3
packaging==21.0
pandas==1.3.2
Pillow==8.3.1
plotly==4.14.2
pynndescent==0.5.4
pyparsing==2.4.7
python-dateutil==2.8.2
pytz==2021.1
PyYAML==5.4.1
regex==2021.8.21
requests==2.26.0
retrying==1.3.3
sacremoses==0.0.45
scikit-learn==0.24.2
scipy==1.7.1
sentence-transformers==2.0.0
sentencepiece==0.1.96
six==1.16.0
threadpoolctl==2.2.0
tokenizers==0.10.3
torch==1.9.0
torchvision==0.10.0
tqdm==4.62.1
transformers==4.9.2
typing-extensions==3.10.0.0
umap-learn==0.5.1
urllib3==1.26.6
(tpmodelENV) PS D:\Python\bertopic\topic-models> 

And the error code

Traceback (most recent call last):
  File "d:\Python\bertopic\topic-models\topicmodels_v2.py", line 92, in <module>
    topics, probabilities = topic_model.fit_transform(docs)
    y, embeddings = self._guided_topic_modeling(embeddings)
  File "D:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\bertopic\_bertopic.py", line 1426, in _guided_topic_modeling
    embeddings[indices] = np.average([embeddings[indices], seed_topic_embeddings[seed_topic]], weights=[3, 1])
  File "<__array_function__ internals>", line 5, in average
  File "D:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\numpy\lib\function_base.py", line 407, in average
    scl = wgt.sum(axis=axis, dtype=result_dtype)
  File "D:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\numpy\core\_methods.py", line 47, in _sum
    return umr_sum(a, axis, dtype, out, keepdims, initial, where)
TypeError: No loop matching the specified signature and casting was found for ufunc add

@MaartenGr
Copy link
Owner

I took your code and used the 20Newsgroups dataset instead to try to reproduce your issue in a basic Google Colab session:

import umap
import hdbscan
from sentence_transformers import SentenceTransformer
from sklearn.datasets import fetch_20newsgroups

docs = fetch_20newsgroups(subset='all',  remove=('headers', 'footers', 'quotes'))["data"]
sentence_model = SentenceTransformer("paraphrase-MiniLM-L6-v2")

# define umap model to reduce embeddings dimensionality
umap_model = umap.UMAP(n_neighbors=15,
                       min_dist=0.0,
                       n_components=10,
                       metric='cosine',
                       low_memory=False,
                       random_state=42)

# define hdbscan model to perform documents clustering
hdbscan_model = hdbscan.HDBSCAN(min_cluster_size=50,
                                min_samples=15,
                                metric='euclidean',
                                cluster_selection_method='eom',
                                prediction_data=True)


# topics generated from keybert search
seed_topic_list = [['customer', 'order', 'service', 
                    'quality',  'transaction', 'delivery', 
                    'shopping', 'staff', 'product',  
                    'store',  'online', 'stock',  
                    'size', 'time', 'website']]

# import bertopic module
from bertopic import BERTopic

# create bertopic model
topic_model = BERTopic(top_n_words=10,
                        min_topic_size=10,
                        n_gram_range=(1,2),
                        calculate_probabilities=True,
                        umap_model=umap_model,
                        hdbscan_model=hdbscan_model,
                        embedding_model=sentence_model,
                        seed_topic_list=seed_topic_list,
                        low_memory=False,
                        verbose=True)

# train model, extract topics and probabilities
topics, probabilities = topic_model.fit_transform(docs)

However, it works without any issue so far. So it seems that the issue is perhaps related to the dataset you are using. How large is your data?

Also, could you update numpy with pip install numpy==1.21.2? That is the version I am currently using in Google Colab.

@gsalfourn
Copy link

Hi Maarten, I think I may have stumbled upon the issue with guided bertopic. So here are the steps I took to diagnose what was wrong in my case after your suggestion to pip install numpy==1.21.2.

Step 1: pip install numpy==1.21.2 (based on your suggestion)

(tpmodelENV) PS D:\Python\bertopic\topic-models> py -m pip install numpy==1.21.2
Collecting numpy==1.21.2
  Using cached numpy-1.21.2-cp39-cp39-win_amd64.whl (14.0 MB)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.20.3
    Uninstalling numpy-1.20.3:
      Successfully uninstalled numpy-1.20.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
numba 0.54.0 requires numpy<1.21,>=1.17, but you have numpy 1.21.2 which is incompatible.
Successfully installed numpy-1.21.2

Step 2: numba error when I tried to run the model with numpy==1.21.2

# numba error after installing numpy==121.2
Traceback (most recent call last):
  File "d:\Python\bertopic\topic-models\topicmodels_v3.py", line 46, in <module>
    import umap
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\umap\__init__.py", line 2, in <module>
    from .umap_ import UMAP
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\umap\umap_.py", line 28, in <module>
    import numba
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\numba\__init__.py", line 198, in <module>
    _ensure_critical_deps()
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\numba\__init__.py", line 138, in _ensure_critical_deps
    raise ImportError("Numba needs NumPy 1.20 or less")
ImportError: Numba needs NumPy 1.20 or less

Step 3: pip install numpy ==1.20

Collecting numpy==1.20
  Using cached numpy-1.20.0-cp39-cp39-win_amd64.whl (13.7 MB)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.21.2
    Uninstalling numpy-1.21.2:
      Successfully uninstalled numpy-1.21.2
Successfully installed numpy-1.20.0

I then run the model with numpy==1.20 and it worked. So, at least, in my environment, it may have to do with numba v. numpy compatibility issues. Below is the final results

Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3125/3125 [05:49<00:00,  8.95it/s]
2021-08-23 11:27:21,879 - BERTopic - Transformed documents to Embeddings
2021-08-23 11:28:54,292 - BERTopic - Reduced dimensionality with UMAP
2021-08-23 11:37:39,465 - BERTopic - Clustered UMAP embeddings with HDBSCAN

@YuanyuanLi96
Copy link
Author

Hi Maarten, I think I may have stumbled upon the issue with guided bertopic. So here are the steps I took to diagnose what was wrong in my case after your suggestion to pip install numpy==1.21.2.

Step 1: pip install numpy==1.21.2 (based on your suggestion)

(tpmodelENV) PS D:\Python\bertopic\topic-models> py -m pip install numpy==1.21.2
Collecting numpy==1.21.2
  Using cached numpy-1.21.2-cp39-cp39-win_amd64.whl (14.0 MB)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.20.3
    Uninstalling numpy-1.20.3:
      Successfully uninstalled numpy-1.20.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
numba 0.54.0 requires numpy<1.21,>=1.17, but you have numpy 1.21.2 which is incompatible.
Successfully installed numpy-1.21.2

Step 2: numba error when I tried to run the model with numpy==1.21.2

# numba error after installing numpy==121.2
Traceback (most recent call last):
  File "d:\Python\bertopic\topic-models\topicmodels_v3.py", line 46, in <module>
    import umap
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\umap\__init__.py", line 2, in <module>
    from .umap_ import UMAP
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\umap\umap_.py", line 28, in <module>
    import numba
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\numba\__init__.py", line 198, in <module>
    _ensure_critical_deps()
  File "d:\Python\bertopic\topic-models\tpmodelENV\lib\site-packages\numba\__init__.py", line 138, in _ensure_critical_deps
    raise ImportError("Numba needs NumPy 1.20 or less")
ImportError: Numba needs NumPy 1.20 or less

Step 3: pip install numpy ==1.20

Collecting numpy==1.20
  Using cached numpy-1.20.0-cp39-cp39-win_amd64.whl (13.7 MB)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.21.2
    Uninstalling numpy-1.21.2:
      Successfully uninstalled numpy-1.21.2
Successfully installed numpy-1.20.0

I then run the model with numpy==1.20 and it worked. So, at least, in my environment, it may have to do with numba v. numpy compatibility issues. Below is the final results

Batches: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3125/3125 [05:49<00:00,  8.95it/s]
2021-08-23 11:27:21,879 - BERTopic - Transformed documents to Embeddings
2021-08-23 11:28:54,292 - BERTopic - Reduced dimensionality with UMAP
2021-08-23 11:37:39,465 - BERTopic - Clustered UMAP embeddings with HDBSCAN

@gsalfourn I also have the same compatibility issue, so I have to degrade numpy to 1.20. But then the guided BERT still has the same error. Have you been able to run guided BERT?

@gsalfourn
Copy link

Yes, I was able to run guided topic in a clean vscode environment without any issues, after using numpy==1.20. I'm now testing it out in Colab to see, since Maarten said he was able to run my code without any issues in Colab.

@gsalfourn
Copy link

Guided topic is working in Colab. Will try it out in jupyter notebook and report my findings

@gsalfourn
Copy link

Now, we have a strange/weird case on our hands. When I tried to run the same guided topic model in Jupyter Notebook using the same vscode venv that run without any errors, the TypeError returns. Below is the code relating to the error observed in Jupyter Notebook.

TypeError                                 Traceback (most recent call last)
<timed exec> in <module>

c:\python\python39\lib\site-packages\bertopic\_bertopic.py in fit_transform(self, documents, embeddings, y)
    285         # Reduce dimensionality with UMAP
    286         if self.seed_topic_list is not None and self.embedding_model is not None:
--> 287             y, embeddings = self._guided_topic_modeling(embeddings)
    288         umap_embeddings = self._reduce_dimensionality(embeddings, y)
    289 

c:\python\python39\lib\site-packages\bertopic\_bertopic.py in _guided_topic_modeling(self, embeddings)
   1424         for seed_topic in range(len(seed_topic_list)):
   1425             indices = [index for index, topic in enumerate(y) if topic == seed_topic]
-> 1426             embeddings[indices] = np.average([embeddings[indices], seed_topic_embeddings[seed_topic]], weights=[3, 1])
   1427         return y, embeddings
   1428 

<__array_function__ internals> in average(*args, **kwargs)

c:\python\python39\lib\site-packages\numpy\lib\function_base.py in average(a, axis, weights, returned)
    405             wgt = wgt.swapaxes(-1, axis)
    406 
--> 407         scl = wgt.sum(axis=axis, dtype=result_dtype)
    408         if np.any(scl == 0.0):
    409             raise ZeroDivisionError(

c:\python\python39\lib\site-packages\numpy\core\_methods.py in _sum(a, axis, dtype, out, keepdims, initial, where)
     45 def _sum(a, axis=None, dtype=None, out=None, keepdims=False,
     46          initial=_NoValue, where=True):
---> 47     return umr_sum(a, axis, dtype, out, keepdims, initial, where)
     48 
     49 def _prod(a, axis=None, dtype=None, out=None, keepdims=False,

TypeError: No loop matching the specified signature and casting was found for ufunc add

The matching venv for vscode and Jupyter Notebook is below:

(tpmodelENV) PS D:\Python\bertopic\topic-models> 
bertopic==0.9.0
certifi==2021.5.30       
charset-normalizer==2.0.4
click==8.0.1
colorama==0.4.4
Cython==0.29.24
filelock==3.0.12
hdbscan==0.8.27
huggingface-hub==0.0.12  
idna==3.2
joblib==1.0.1
llvmlite==0.37.0
nltk==3.6.2
numba==0.54.0
numpy==1.20.0
packaging==21.0
pandas==1.3.2
Pillow==8.3.1
plotly==4.14.2
pynndescent==0.5.4
pyparsing==2.4.7
python-dateutil==2.8.2
pytz==2021.1
PyYAML==5.4.1
regex==2021.8.21
requests==2.26.0
retrying==1.3.3
sacremoses==0.0.45
scikit-learn==0.24.2
scipy==1.7.1
sentence-transformers==2.0.0
sentencepiece==0.1.96
six==1.16.0
threadpoolctl==2.2.0
tokenizers==0.10.3
torch==1.9.0
torchvision==0.10.0
tqdm==4.62.1
transformers==4.9.2
typing-extensions==3.10.0.0
umap-learn==0.5.1
urllib3==1.26.6

@YuanyuanLi96
Copy link
Author

YuanyuanLi96 commented Aug 23, 2021

@gsalfourn Yes, I am using Jupyter notebook, so it seems this error only occurs in Jupyter notebook. Thanks for your testing!

@MaartenGr
Copy link
Owner

I just tried it out in a Jupyter Notebook but unfortunately could not reproduce your issue. It seems that the issue can be found through a Numba/Numpy combination that does not work well together.

The numba/numpy combo I use in the jupyter notebook/lab sessions:

numba==0.53.1
numpy==1.21.1

I would advise installing the versions above since the new Numba release does not support numpy>1.20. See this issue.

@xunkai55
Copy link

@MaartenGr Sorry for jumping in, as the reporter of the issue you mentioned (numba/numba#7339), new numba (0.54) does only support numpy==1.20 (with Python 3.7 on Linux)

@YuanyuanLi96
Copy link
Author

I just tried it out in a Jupyter Notebook but unfortunately could not reproduce your issue. It seems that the issue can be found through a Numba/Numpy combination that does not work well together.

The numba/numpy combo I use in the jupyter notebook/lab sessions:

numba==0.53.1
numpy==1.21.1

I would advise installing the versions above since the new Numba release does not support numpy>1.20. See this issue.

Yes, this combination works for me! Thanks to everybody!

@garenkwan
Copy link

For what it's worth, I find that I have to downgrade numpy to 1.20.* and upgrade it again back to 1.21.1 every time I restart the environment on my local machine.
So while not a 'fix', this could be another workaround to get things running.

@ginward
Copy link

ginward commented Sep 26, 2021

I have the same issue. It seems that installing the above numpy version works for me.

@sheddyranking
Copy link

i tried plotting this
sns.regplot(x=df['budget'], y=df['gross'], scatter_kws={'color':'red'}, line_kws={'color':'blue'})

And i got this error

No loop matching the specified signature and casting was found for ufunc svd_n_s

@sheddyranking
Copy link

i upgraded the version of NumPy as instructed above, it still doesn't work for me, i am using Jupyter Notebook

@MaartenGr
Copy link
Owner

@sheddyranking If I am not mistaken, it seems that your issue is related to seaborn and not bertopic, right? Perhaps they can help you out better than I can at their issues page.

@sheddyranking
Copy link

yes sir

@FengZhiheng
Copy link

pip install numpy ==1.20

It works for me when I change the numpy version to

pip install numpy ==1.20.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants