BERTopic is a modular topic modeling algorithm that generates document embeddings using pre-trained transformer models like Sentence-BERT, then clusters these high-dimensional vectors with HDBSCAN to identify dense semantic groups. Unlike traditional generative models such as Latent Dirichlet Allocation (LDA), it does not assume a fixed number of topics or rely on bag-of-words representations, instead preserving contextual meaning through deep neural embeddings.
Glossary
BERTopic

What is BERTopic?
BERTopic is a modern topic modeling technique that leverages pre-trained transformer embeddings and class-based TF-IDF to create dense clusters representing coherent, easily interpretable topics.
After clustering, BERTopic applies a class-based variant of TF-IDF (c-TF-IDF) to extract topic representations, treating all documents in a cluster as a single combined document to identify the most salient terms. This approach produces highly coherent, human-interpretable topics while maintaining the flexibility to model dynamic topic evolution and incorporate custom embedding models for domain-specific corpora.
Key Features of BERTopic
BERTopic is a modern topic modeling technique that leverages pre-trained transformer embeddings and class-based TF-IDF to create dense clusters representing coherent topics. Its modular design allows for flexible component swapping at each stage of the pipeline.
Document Embedding
The pipeline begins by converting documents into dense vector representations using pre-trained transformer models. By default, BERTopic uses sentence-transformers to generate semantically rich embeddings that capture contextual meaning beyond simple keyword frequencies.
- Supports any Hugging Face embedding model
- Can integrate spaCy, Gensim, or Word2Vec models
- Enables multilingual topic modeling with cross-lingual embeddings
- Preserves semantic similarity: documents with similar meaning cluster together even with different vocabulary
Dimensionality Reduction
High-dimensional embeddings are reduced to a lower-dimensional space to combat the curse of dimensionality. BERTopic defaults to UMAP (Uniform Manifold Approximation and Projection), which preserves both local and global data structure better than traditional PCA.
- Default UMAP preserves neighborhood structure for clustering
- Optional PCA or t-SNE for specific use cases
- Handles sparse high-dimensional data efficiently
- Critical step: poor reduction leads to fragmented or merged topics
Cluster-Based Topic Discovery
Reduced embeddings are clustered using HDBSCAN, a density-based algorithm that automatically identifies clusters of varying densities and marks outliers as noise. Unlike K-Means, HDBSCAN does not require pre-specifying the number of topics.
- Noise points are treated as outliers, not forced into topics
- Automatically discovers the natural number of topics
- Handles clusters of different shapes and densities
- Outlier reduction improves topic coherence by excluding ambiguous documents
Class-Based TF-IDF (c-TF-IDF)
Instead of calculating term importance across individual documents, BERTopic computes class-based TF-IDF where each topic cluster is treated as a single aggregated document. This identifies words that are frequent within a topic but rare across all topics.
- Formula: weights term frequency by inverse class frequency
- Produces highly discriminative topic-word distributions
- Enables dynamic topic labeling from top-ranked terms
- Outperforms standard TF-IDF for topic representation by modeling inter-topic distinctiveness
Topic Representation & Fine-Tuning
BERTopic offers multiple strategies for generating human-readable topic labels beyond raw c-TF-IDF keywords. The Maximal Marginal Relevance (MMR) algorithm balances term relevance with diversity to avoid redundant keywords.
- KeyBERTInspired: uses embedding similarity to refine keywords
- Part-of-Speech filtering: retains only nouns and adjectives
- GPT-based labeling: generates natural language topic names via LLMs
- Zero-shot topic merging: consolidates similar topics using semantic similarity thresholds
Dynamic Topic Modeling
BERTopic extends static topic modeling to temporal analysis by tracking how topics evolve over time. Documents are binned by timestamp, and topic frequencies are calculated per time slice to model topic evolution without retraining separate models.
- Topics over Time: visualizes topic frequency trends
- Merging and splitting detection: identifies topic drift
- Normalizes for varying document volumes across time periods
- Enables longitudinal analysis of thematic shifts in document streams
Frequently Asked Questions
Explore common questions about BERTopic, a modern topic modeling technique that leverages transformer embeddings and class-based TF-IDF to create dense, coherent topic clusters.
BERTopic is a modern topic modeling technique that leverages pre-trained transformer embeddings and class-based TF-IDF (c-TF-IDF) to create dense clusters representing coherent topics. Unlike traditional models like LDA that rely on bag-of-words representations, BERTopic operates in three distinct stages. First, it converts documents into high-dimensional vector embeddings using sentence transformers, capturing deep semantic context. Second, it reduces the dimensionality of these embeddings using UMAP (Uniform Manifold Approximation and Projection) to preserve both local and global data structure. Third, it applies HDBSCAN, a density-based clustering algorithm, to identify dense regions of semantically similar documents while treating outliers as noise. Finally, it extracts topic representations by treating all documents in a cluster as a single combined document and applying c-TF-IDF, which weights terms based on their frequency within a topic relative to their frequency across all topics. This modular architecture allows BERTopic to discover topics with arbitrary shapes, handle noise effectively, and produce highly interpretable topic-word distributions without requiring a pre-specified number of topics.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Explore the foundational algorithms, evaluation metrics, and inference methods that surround BERTopic in the modern topic modeling landscape.
Latent Dirichlet Allocation (LDA)
The generative probabilistic model that serves as the statistical foundation for topic modeling. LDA represents documents as random mixtures over latent topics, where each topic is characterized by a distribution over words.
- Uses Dirichlet priors to control sparsity of topic distributions
- Relies on Gibbs sampling or variational inference for posterior approximation
- Requires pre-specifying the number of topics (K) hyperparameter
- Outputs document-topic distributions and topic-word distributions
Topic Coherence Evaluation
The standard interpretability metric for assessing topic quality by measuring semantic similarity between top-ranked words. Unlike perplexity scores which optimize for predictive likelihood, coherence correlates with human judgment.
- C_V coherence combines normalized PMI with cosine similarity over word context vectors
- Pointwise Mutual Information (PMI) measures word association strength
- Topic intrusion tasks inject outlier words to test human interpretability
- Topic diversity calculates the percentage of unique words across all topics
Non-Negative Matrix Factorization (NMF)
A linear algebra alternative to probabilistic topic models that decomposes the document-term matrix (DTM) into two lower-dimensional non-negative matrices. The non-negativity constraint produces additive, parts-based representations that are often more interpretable than LDA for short texts.
- Works directly on TF-IDF weighted matrices
- No distributional assumptions required
- Often combined with BERTopic for class-based TF-IDF refinement
Hierarchical Dirichlet Process (HDP)
A nonparametric Bayesian model that eliminates the need to pre-specify the number of topics. HDP places a Dirichlet process prior on the topic space, allowing the model to infer the optimal number of topics directly from the data.
- Enables infinite topic mixtures that grow with corpus complexity
- Uses Chinese Restaurant Process as the underlying combinatorial process
- Particularly useful when the true topic cardinality is unknown
Gibbs Sampling Inference
A Markov Chain Monte Carlo (MCMC) algorithm used for approximate posterior inference in Bayesian topic models. Gibbs sampling iteratively samples latent topic assignments for each word token conditioned on all other current assignments.
- Converges to the true posterior given sufficient iterations
- Computationally intensive for large corpora
- Contrasts with variational inference which optimizes a tractable lower bound
- Foundation for collapsed Gibbs sampling in LDA implementations like Gensim
pyLDAvis Visualization
An interactive visualization library for interpreting topic models by projecting inter-topic distances onto a two-dimensional plane. The intertopic distance map uses multidimensional scaling to display topic overlap and distinctness.
- Displays salient terms using a relevance metric balancing frequency and lift
- Allows users to adjust the relevance parameter λ to explore topic-word relationships
- Compatible with BERTopic through its embedding-based visualization approach
- Essential for qualitative model validation and stakeholder communication

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us