MaartenGr / BERTopic

Leveraging BERT and c-TF-IDF to create easily interpretable topics.
https://maartengr.github.io/BERTopic/
MIT License
6.16k stars 764 forks source link

Pickling a guided topic model object returns error #653

Closed AlduCor closed 2 years ago

AlduCor commented 2 years ago

Hi!

When trying to pickle a topic model object that was created by using guided topic modelling (passing a seed_topic_list) you get:

TypeError: cannot pickle 'dict_values' object

Simple workaround is to delete the attribute from the class: del topic_model.__dict__["seed_topic_list"] then pickle. But I guess a simple fix would be better down the line...

I'm happy to do a PR if you'd like. Or if I'm missing something obvious; I'm sorry!

MaartenGr commented 2 years ago

Could you share your code for training this model and the entire error message? Also, do you have a minimal reproducible example for this? I am not familiar with the error and it might stem from multiple places. So I think it would be best to first get to the bottom of this before doing PRs.

AlduCor commented 2 years ago

Sorry to waste your time. I figured out what the issue was. Not a bug. I was passing dict.values() instead of a list of lists as the seed_topic_list variable. Thanks for a really great package!!!