1

I am attempting to test out this KeyBERT model. I am new to Python (much experience in R). I'm not sure how to debug this issue since the error message is so short. My question is, how do I debug this with such little information? Where to start?

I have a fresh install of Anaconda with Python 3.9.13:

Python 3.9.13 (main, Aug 25 2022, 18:29:29) [Clang 12.0.0 ] :: Anaconda, Inc. on darwin

When attempting to initialize a KeyBERT model I get a segmentation fault error. I'm not sure what the next steps would be to debug this. I'm well-versed with R, but still new to Python so I don't have a toolbox of debug steps. Any thoughts about where to look first?

>>> from keybert import KeyBERT
>>> kw_model = KeyBERT()
zsh: segmentation fault  python

I've run it in a Jupyter notebook with the same results. The first time I used it, the models were downloaded (I expect succesfully?). But when attempting to initialize the model, I get this segfault.

Edited to add, I used faulthandler to get this output:

(base) user@place ~ % python -q -X faulthandler
>>> from keybert import KeyBERT
>>> kw_model = KeyBERT()
Fatal Python error: Fatal Python error: Segmentation fault

Segmentation faultThread 0x

00000002054742c0 (most recent call first):
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1568 in _load_from_state_dict
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/transformers/modeling_utils.py", line 469 in load
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/transformers/modeling_utils.py", line 473 in load
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/transformers/modeling_utils.py", line 473 in load
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/transformers/modeling_utils.py", line 475 in _load_state_dict_into_model
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2517 in _load_pretrained_model
  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2326 in from_pretrained
zsh: segmentation fault  python -q -X faulthandler

1 Answer 1

3

I have solved this issue. Steps

  1. Reinstalled PyTorch using conda
  2. I imported torch before importing KeyBERT

Runs successfully, no errors, output is as expected. Thanks for anyone that read this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.