pythonbert-language-modeltopic-modeling

Trouble in installing BERTopic's dependency ''bertopic.dimensionality''


I'm trying to run the following code from the BERTopic documentation:

from bertopic import BERTopic
from bertopic.dimensionality import BaseDimensionalityReduction

# Fit BERTopic without actually performing any dimensionality reduction
empty_dimensionality_model = BaseDimensionalityReduction()
topic_model = BERTopic(umap_model=empty_dimensionality_model)

However, despite the fact that bertopic is installed and updated in my machine, I keep getting the output ModuleNotFoundError: No module named 'bertopic.dimensionality' . Is there any discontinuity? Or how can I assute to install bertopic.dimensionality?


Solution

  • I would advise starting from a completely fresh environment. Since it cannot be found in your environment and since the feature was added in the newest version of BERTopic (v0.13), that version might not yet be installed. You can check your version with import bertopic; bertopic.__version__. When you start from a completely fresh environment any issues with caching, conflicting dependencies, or version issues are often fixed. For me, it is working using the most recent release of BERTopic.