MaartenGr / BERTopic

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

Issue with loading BERTopic model. 'NNDescent' object has no attribute '_bit_trees' #1933

Open siyerp opened 6 months ago

siyerp commented 6 months ago

The code:

from bertopic import BERTopic
model_path = "/path/to/bertopic/model"
model = BERTopic.load(model_path)

The error: AttributeError: 'NNDescent' object has no attribute '_bit_trees'

The solution:

I downgraded my pynndescent from 0.5.12 to 0.5.11. That solved the problem, but just bringing this to your attention in case there's a change that needs to be made moving forward.

MaartenGr commented 6 months ago

Thank you for sharing! You might also be able to prevent this issue by installing the latest umap-learn which might have fixed this issue.

lucijakrusic commented 6 months ago

I'm having the same issue now, and neither downgrading the pynndescent nor installing umap-learn helped. Beforehand, I also had an issue with loading the model, for which I upgraded numba. Any suggestions? Thanks in advance!

MaartenGr commented 6 months ago

@lucijakrusic Not quite sure what the solve is here. I assume you are loading from a pickle, right? In that case, you will need to make sure that all versions of all dependencies are exactly the same as when you saved the model.