A Python library for fast CPU clustering of large high-dimensional embedding vectors, with a scikit-learn style API.
MaartenGr/BERTopic
A Python topic modeling library that combines transformer embeddings with c-TF-IDF to produce interpretable topics from text.
- Stars
- 7,937
- Forks
- 931
- Open issues
- 478
- Last commit
- 2 days ago
What is it?
BERTopic is a Python library for topic modeling. It embeds documents with transformer models, reduces their dimensionality, clusters them into groups, and then describes each group with its most distinctive words using a class-based TF-IDF procedure. The result is a set of topics with readable keyword descriptions, along with per-document topic assignments and probabilities.
The library is modular. Each stage, including the embedding model, dimensionality reduction, clustering, tokenization, term weighting and topic representation, can be swapped or removed. Topic representations can be refined with KeyBERT-style keywords, LLM-generated labels such as those from OpenAI models, or several representations at once through multi-aspect modeling.
Beyond basic fitting, BERTopic supports guided, supervised, semi-supervised, zero-shot, hierarchical, dynamic over time, per-class, online and multimodal topic modeling. It also offers interactive visualizations, such as an LDAvis-like topic map, and methods to save, load and merge models.
Key features
- 01Builds topics from transformer embeddings, UMAP-style dimensionality reduction and HDBSCAN-style clustering.
- 02Describes topics with c-TF-IDF keywords, and can refine them with KeyBERT or LLM-based representations.
- 03Supports guided, supervised, zero-shot, hierarchical, dynamic and online topic modeling.
- 04Provides interactive visualizations of topics, documents, hierarchies and topics over time.
- 05Lets each pipeline stage be swapped out or removed.
Use cases
- Exploring a large collection of customer feedback, support tickets or survey responses to find recurring themes.
- Tracking how topics in news, social media or research abstracts shift over time.
- Analyzing document collections in multiple languages with a multilingual embedding model.
- Labeling clusters of text with human-readable topic names generated by an LLM.
Quick start
- 1
Install BERTopic with pip
pip install bertopic - 2
Fit the model on your documents with fit_transform in Python
Things to know
- The default install pulls in heavy dependencies such as transformers and UMAP, so a light-weight install is needed for a smaller footprint.
- Some optional topic labelling features, such as the OpenAI representation, require an API key from a paid service.
In collections
Topics
FAQ
- What is BERTopic?
- A Python topic modeling library that combines transformer embeddings with c-TF-IDF to produce interpretable topics from text. BERTopic is a Python library for topic modeling. It embeds documents with transformer models, reduces their dimensionality, clusters them into groups, and then describes each group with its most distinctive words using a class-based TF-IDF procedure. The result is a set of topics with readable keyword descriptions, along with per-document topic assignments and probabilities.
- Is BERTopic free to use? What license does it have?
- BERTopic is open source under the MIT license. Check the license terms before using it in commercial products.
- Is BERTopic still maintained?
- Actively maintained. The last commit to BERTopic was on Nov 5, 2026.
- What can I use BERTopic for?
- Exploring a large collection of customer feedback, support tickets or survey responses to find recurring themes. Tracking how topics in news, social media or research abstracts shift over time. Analyzing document collections in multiple languages with a multilingual embedding model. Labeling clusters of text with human-readable topic names generated by an LLM.
- How do I install BERTopic?
- Install BERTopic with pip: pip install bertopic Fit the model on your documents with fit_transform in Python
- Where can I get BERTopic?
- The source code and installation instructions are on GitHub: https://github.com/MaartenGr/BERTopic
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Fast, state-of-the-art tokenization library in Rust with Python and Node.js bindings for NLP and language model pipelines.
spaCy components and architectures that plug Hugging Face transformer models such as BERT, RoBERTa and XLNet into spaCy pipelines.
A Chinese-language course-style repository covering AI math basics, machine learning, deep learning, Transformer, BERT and competition case studies, with annotated code and datasets.
Industrial-strength NLP library for Python and Cython, offering tokenization, pretrained pipelines and trained models for tagging, parsing and entity recognition.
Run Hugging Face Transformers models directly in the browser or JavaScript runtimes with no server, using ONNX Runtime.