BERTopic
Leveraging BERT and c-TF-IDF to create easily interpretable topics.
What is BERTopic?
Leveraging BERT and c-TF-IDF to create easily interpretable topics.
Overview of BERTopic
What it is
BERTopic is a topic modeling technique that leverages transformers and c-TF-IDF to create dense clusters, allowing for easily interpretable topics while keeping important words in the topic descriptions. It supports various topic modeling techniques including guided, supervised, semi-supervised, manual, multi-topic distributions, hierarchical, class-based, dynamic, online/incremental, multimodal, multi-aspect, text generation/LLM, zero-shot, merge models, and seed words.
Key features
- Supports a wide range of topic modeling techniques: guided, supervised, semi-supervised, manual, hierarchical, dynamic, online/incremental, multimodal, multi-aspect, text generation/LLM, zero-shot, merge models, and seed words.
- Modular design allows swapping or removing components such as embedding models, dimensionality reduction, clustering, tokenization, token weighting, and topic representation.
- Includes multiple visualization options, such as visualize_topics() similar to LDAvis.
- Provides fine-tunable topic representations, including KeyBERTInspired and integration with OpenAI models like GPT for generating labels, summaries, phrases, and keywords.
- Offers methods to access single topics, all topics, topic frequencies, topic information, document information, representative documents, and to update or merge topics.
- Supports multilingual modeling with the option
BERTopic(language='multilingual')for 50+ languages.
Use cases
BERTopic can be used for extracting interpretable topics from text datasets, such as news articles, academic abstracts, social media posts, or any collection of documents. It is suitable for exploratory data analysis, content categorization, trend detection, and building topic-based recommendation systems. The modularity allows customization for specific domains, and the support for dynamic and online topic modeling makes it applicable to streaming data or evolving corpora.
Getting started
Installation can be done using uv or pip:bashuv add bertopicorbashpip install bertopicFor additional embedding backends:bashpip install bertopic[flair,gensim,spacy,use]For a quick start, see the repository README for example code using the 20 newsgroups dataset.
License and pricing
This project is licensed under the MIT license. It is open source and free to use.
Based on the project's public README and repository metadata.