BERTopic — Neural Topic Modeling
- Introduced by
- Maarten Grootendorst
- Year
- 2022
- Type
- Neural topic-modeling pipeline
What does it do?
BERTopic is a neural topic-modeling pipeline introduced by Maarten Grootendorst in 2022.
It combines BERT-based contextual embeddings with UMAP dimensionality reduction and HDBSCAN clustering to produce coherent, dynamic topics, achieving higher topic coherence than classic topic models.
The intuition behind the method
Classic topic models treat a document as a bag of words and rarely capture what words mean in context. BERTopic instead starts from contextual embeddings, so documents that talk about the same thing in different words end up close together. It groups those nearby documents into clusters and then reads off the words that make each cluster distinctive — and those distinctive words become the topic. The result is a set of human-readable themes that emerge from the meaning of the text rather than from raw word counts.
History
BERTopic was introduced by Maarten Grootendorst in 2022 as a neural topic-modeling approach that pairs transformer embeddings with a class-based TF-IDF procedure. It draws on the HDBSCAN density-based clustering algorithm of McInnes, Healy and Astels (2017) for the clustering stage, moving topic modeling away from purely count-based methods toward embedding-driven, coherence-focused topics.
When to use it
Use BERTopic when you have a text corpus and want to discover its underlying themes without specifying them in advance. It suits exploratory and descriptive work on cross-sectional or longitudinal text. A sufficient number of documents is needed — at least 50, with more than 100 recommended — and GPU or high compute is preferred because the embedding step is expensive. With very few documents the density-based clustering has too little signal to form stable topics.
Limitations and considerations
- Needs a sufficient number of documents — at least 50, with more than 100 recommended — to form stable topics.
- GPU or high compute is preferred because the transformer embedding step is expensive.
- Results depend on the embedding model and on the UMAP and HDBSCAN settings chosen.
- HDBSCAN leaves some documents unassigned as outliers, so not every document receives a topic.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Builds on contextual embeddings, so it captures meaning that bag-of-words models miss.
- Produces coherent, interpretable topics with higher coherence than classic topic models.
- Supports dynamic topic modeling, tracking how topics shift across time on time-stamped corpora.
- A multilingual embedding model lets the same pipeline work across languages.
Applications
- Discovering themes in large collections of documents or reports for exploratory analysis.
- Tracking how topics in a corpus evolve over time on time-stamped text.
- Summarising open-ended survey responses or reviews into interpretable themes.
- Organising scientific or social-media corpora into coherent topic clusters across languages.
How it works
How it works
Each document is converted into a contextual embedding using a BERT-based transformer model. Because the embedding captures meaning in context, documents expressing the same idea in different wording land near each other in the vector space. A multilingual model lets the same pipeline handle corpora in many languages.
The high-dimensional embeddings are projected into a lower-dimensional space with UMAP. This reduction keeps the local neighbourhood structure intact while making the data tractable for the clustering step that follows, where high dimensionality would otherwise dilute density.
HDBSCAN groups the reduced embeddings into density-based clusters. Because it is density-based, it finds clusters of varying shape and leaves genuinely sparse documents unassigned as outliers rather than forcing every document into a topic.
For each cluster a class-based TF-IDF score ranks the terms that are most distinctive of that cluster. The top-ranked terms become the topic's representation, yielding coherent, interpretable topics and, on time-stamped corpora, dynamic topics that can be tracked over time.
Common pitfalls
- Running it on too few documents leaves the clustering step without enough density to form meaningful topics.
- Choosing an embedding model that does not match the corpus language degrades topic quality; use a multilingual or domain-appropriate model.
- Treating outlier (unassigned) documents as a failure rather than expected behaviour of density-based clustering.
- Reading topics from class-based TF-IDF terms without inspecting representative documents, which can lead to over-interpreting a label.
Frequently asked questions
How is BERTopic different from classic topic models like LDA?
Classic models such as LDA work from word counts and a bag-of-words view of each document. BERTopic starts from contextual transformer embeddings, reduces them with UMAP, clusters them with HDBSCAN, and labels each cluster with class-based TF-IDF terms. Because it captures meaning in context, it generally yields more coherent, interpretable topics.
How many documents do I need?
At least 50 documents, with more than 100 recommended. The clustering step is density-based, so with too few documents there is not enough signal to form stable topics.
Why are some of my documents not assigned to any topic?
HDBSCAN is a density-based clustering algorithm and deliberately leaves genuinely sparse or atypical documents unassigned as outliers rather than forcing them into a topic. This is expected behaviour, not an error.
Can BERTopic handle non-English text?
Yes. By selecting a multilingual embedding model the same pipeline can process corpora in many languages; matching the embedding model to the corpus language is key to good topic quality.
Related methods
Sources
Grootendorst, M. (2022). BERTopic: Neural topic modeling with a class-based TF-IDF procedure. arXiv:2203.05794.
Open DOI referenceCopied.McInnes, L., Healy, J. & Astels, S. (2017). hdbscan: Hierarchical density based clustering. Journal of Open Source Software, 2(11), 205.
Open DOI referenceCopied.