There is a newer version of the record available.

Published March 19, 2025 | Version v0.17.0

MaartenGr/BERTopic: v0.17.0

  • 1. WZB Berlin Social Science Center
  • 2. @GateNLP
  • 3. Textify AI (@T3xtifyai)
  • 4. Google
  • 5. @swca
  • 6. Hugging Face
  • 7. @Docket Inc.
  • 8. Proton AG
  • 9. @Nubank
  • 10. Freelancer and educator in data science & AI @anthology-of-data-science, Fellow @eaisi
  • 11. CloseFactor
  • 12. @scitedotai @dalhousie
  • 13. ICMC, University of São Paulo
  • 14. Mustang Analytics
  • 15. Queen's University

Description

<h3><b>Highlights:</a></b></h3>

<h3><b>Fixes:</a></b></h3>

Model2Vec

With Model2Vec, we now have a very interesting pipeline for light-weight embeddings. Combined with the light-weight installation, you can now run BERTopic without using pytorch!

Installation is straightforward:

pip install --no-deps bertopic
pip install --upgrade numpy pandas scikit-learn tqdm plotly pyyaml

This will install BERTopic even without UMAP or HDBSCAN, so you can use other techniques instead. If these are not installed, then it uses PCA with scikit-learn's HDBSCAN instead. You can install them, together with Model2Vec:

pip install model2vec umap-learn hdbscan

Then, creating a BERTopic model is as straightforward as you are used to:

from bertopic import BERTopic
from model2vec import StaticModel

# Model2Vec
embedding_model = StaticModel.from_pretrained("minishlab/potion-base-8M")

# BERTopic
topic_model = BERTopic(embedding_model=embedding_model)

DataMapPlot

To use the interactive version of DataMapPlot, you only need to run the following:

from umap import UMAP

# Reduce your embeddings to 2-dimensions
reduced_embeddings = UMAP(n_neighbors=10, n_components=2, min_dist=0.0, metric='cosine').fit_transform(embeddings)

# Create an interactive DataMapPlot figure
topic_model.visualize_document_datamap(docs, reduced_embeddings=reduced_embeddings, interactive=True

Files

MaartenGr/BERTopic-v0.17.0.zip

Files (296 Bytes)

Name Size Download all
md5:49bace8a056539fd823de737ea7c92a0
296 Bytes Preview Download

Additional details

Related works