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

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?

19 Answers

βœ”οΈAccepted Answer

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:


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

Related Issues:

BERTopic No loop matching the specified signature and casting was found for ufunc add
I just tried it out in a Jupyter Notebook but unfortunately could not reproduce your issue ...
transformers Installation Error - Failed building wheel for tokenizers
I managed to solve the issue by installing Rust compiler Install Rust link curl --proto '=https' --t...
tokenizers How to add some new special tokens to a pretrained tokenizer?
Try this and give feedback: Hi guys I want to add some new special tokens like [XXX] to a pretrained...
transformers How to get all layers(12) hidden states of BERT?
You should have obtained the 12 layers as well as the embedding output ❓ Questions & Help I tried to...
transformers Failing to load saved TFBertModel
change base_output = base_model([ids mask token_type_ids]) to base_output = base_model.bert([ids mas...
transformers token indices sequence length is longer than the specified maximum sequence length
This means you're encoding a sequence that is larger than the max sequence the model can handle (whi...
transformers Unable to load weights from pytorch checkpoint file
I had this problem when I trained the model with torch==1.6.0 and tried to load the model with 1.3.1...
transformers Bert for passage reranking
Update for latest transformers add and convert_bert_original_tf_checkpoint_to_p...
transformers Input file format for examples/
Hi two datasets are available in TextDataset ❓ Questions & Help Details I want...
transformers does not save keras model that includes DIstillBert layer
Same issue πŸ› Bug Information I am trying to build a Keras Sequential model where I use DistillBERT ...
transformers TypeError: 'ByteLevelBPETokenizer' object is not callable
It should be possible to do something like this for now: And then you should be able to use it with ...
transformers GPT2 Sentence Probability: Necessary to Prepend "<|endoftext|>"?
Dig into this a little When computing sentence probability do we need to prepend the sentence with a...
transformers dropout(): argument 'input' (position 1) must be Tensor, not str With Bert
No need to downgrade the transformers Just do the following - it's from the migration guide. ...
transformers XLNET SQuAD2.0 Fine-Tuning - What May Have Changed?
@WilliamNurmi @knuser : Fine-tuning the albert_xxlargev1_sqd2_512_bs48 script with Transformers 2.4....
transformers How to use fine-tuned BART for prediction?
I found a solution The model.generate() function is necessary to extract the predictions ...
haystack Haystack with Albert is awesome! XLNet question
If you update FARM on latest master you should be able to increase the batch size a lot @Timoeller Y...
transformers GPT-2 XL PyTorch Quantization for use on a Cloud Server
I managed to quantize Pytorch GPT-2 XL to int8 with quantize_torch_model method from this script ...
transformers pip install [--editable] . ---> Error
The pip install -e is probably working it's just that some tests are failing due to code not tests o...
keras Loading model with custom loss function: ValueError: 'Unknown loss function'
I solved this problem by adding 'custom_bojects' my loss function: I trained and saved a model that ...
keras Tensorflow backend - bug in model._make_predict_function(...)
I had this problem when doing inference in a different thread than where I loaded my model ...
keras Creating Model variable throws "AttributeError: 'Tensor' object has no attribute '_keras_history'"
@zaid478 oh I assumed you were doing it on coursera Anyway Hello all setup: Keras 2.0 Tensorflow 1.0...
tensorflow ImportError: cannot open shared object file: No such file or directory
@rhinsall I just found this out myself not sure if it's common knowledge but got around this by doin...
keras "<tensor> is not an element of this graph." when loading model.
I had a problem similar to that of @piraka9011 which was solved by calling model._make_predict_funct...
pytorch I can't import PyTorch, libomp.dylib can't be loaded.
brew install libomp solves the problem. πŸ› Bug I tried to install PyTorch but I can't use it ...
pytorch RuntimeError: cuda runtime error (59) : device-side assert triggered when running transfer_learning_tutorial
@soumith Hi I find the error it is due to my labels contain value -1 which is unacceptable in criter...
tensorflow At Runtime : "Error while reading resource variable softmax/kernel from Container: localhost"
I had the same issue in tensorflow 1.13.1 which I have resolved by creating a reference to the sessi...
tensorflow Mac + Python 3.6.1: Attempting to download mnist data results in CERTIFICATE_VERIFY_FAILED error
This might have also been because I recently switched to a new machine and it's still only partially...
tensorflow UnrecognizedFlagError: Unknown command line flag 'f'
I solved this issue by adding the line:'f' '' 'kernel') what this essent...
tensorflow FutureWarning: Deprecated numpy API calls in tf.python.framework.dtypes
@Akeaakar And for the time being pip install numpy<1.17 to revert to numpy version 1.16.4 ...
tensorflow ERROR: Cannot uninstall 'wrapt'. during upgrade
This worked for me: pip install wrapt --upgrade --ignore-installed pip install tensorflow ...
pytorch ModuleNotFoundError: No module named 'torch._C'
Solution the problem is that you have a folder called torch in the same directory which is being pic...
tensorflow Keras application - Tensor is not an element of this graph on eval after train
K.clear_session() did not work for me however what worked was : While predicting use the same graph ...
xgboost Problems while installing in OSX 10.11.6?
Success! πŸŽ‰ I found this here: clang LLVM compiler on Mac OS X from Xcode doesn't support OpenMP mul...
keras Quick Question: can a model be fit for multiple times?
Yes successive calls to fit will incrementally train the model. I'm now having something around 5000...
tensorflow InternalError: Blas GEMM launch failed
Make sure you have no other processes using the GPU running Run nvidia-smi to check this. ...
pytorch RuntimeError: DataLoader worker is killed by signal: Killed.
I've encountered the same problem recently If you're using the docker to run the PyTorch program wit...
tensorflow Is python 3.7.x supported with Tensorflow
I sill get Ive been trying to install Tensorflow on my computer which currently runs python 3.7 howe...
tensorflow Tensorflow installation Error in Mac Sierra due to numpy
Also Had to do this with the six dependency as well Hi I want to install TensorFlow on Mac Currently...
keras Error when checking model target: expected activation_2 to have shape (None, 10) but got array with shape (3, 1)
Your model has an output of shape (10,) however your outputs have dimension (1,) You probably want t...
tensorflow tensorboard: view graph from saved_model.pb file [feature request]
@brandondutra As far as I know you don't need to create any summaries to load the graph into Tensorb...
keras Is there a way in Keras to apply different weights to a cost function?
Ok so I had the time to quickly test it Hi there I am trying to implement a classification problem w...
tensorflow ImportError: cannot open shared object file: No such file or directory
Double check that you have exported the LD_LIBRARY_PATH export LD_LIBRARY_PATH=/usr/local/cuda-8.0/l...
pytorch [PyTorch][Feature Request] Label Smoothing for CrossEntropyLoss
Here is my implement Hi guys The type torch.LongTensor of target will hinder the implementation like...
caffe version `GLIBCXX_3.4.21' not found
^ Should fix this error Please ask installation questions only in the Caffe mailing list. ...
keras Keras model cannot be loaded if it contains a Lambda layer calling tf.image.resize_images
Try using custom_objects argument in load_model (or model_from_json) function For your case load_mod...
keras how to use fit_generator with multiple image inputs
Thanks Here is how I solved it following some ideas from issue 3386 maybe someone might find it usef...
tensorflow Tensorflow Failed to create Session
maybe out of GPU memory? Try running with export CUDA_VISIBLE_DEVICES='' Hi I tried basic program in...