Skip to content

ML Models & Algorithms

BERTopic

In shortA modular topic modelling technique that clusters transformer embeddings and labels each cluster with class-based TF-IDF to produce readable topics.

Updated 24 Oct 2026· 2 min read

BERTopic is a topic modelling technique, introduced by Maarten Grootendorst in 2022, that groups documents by meaning and describes each group with its most distinctive words. It combines transformer embeddings with clustering, which makes it far better than older bag-of-words models at handling synonyms and context. It is the approach MLforSEO reaches for first when clustering keywords, reviews, titles and page content.

How it works

BERTopic is a pipeline of swappable steps, which MLforSEO describes as building with Lego:

  • Embed each document with a sentence-transformer model. The default English model, all-MiniLM-L6-v2, produces 384-dimensional vectors.
  • Reduce those vectors to a handful of dimensions with UMAP.
  • Cluster the reduced vectors, by default with HDBSCAN, which finds dense groups and leaves outliers in a separate topic labelled -1. You can swap in K-means or BIRCH.
  • Describe each cluster with c-TF-IDF, which treats all documents in a cluster as one and finds the words that set it apart from the other clusters.

Each step is optional and replaceable, so you can change the embedding model for another language, fix the number of topics, or add an LLM to write topic labels.

How it’s used in SEO and marketing

  • Clustering page content to audit topical coverage, overlaps and gaps across a site or a competitor’s site.
  • Mapping a large keyword list to topics when you have no predefined topic list.
  • Grouping customer reviews, Reddit threads or YouTube titles to see what people talk about, ideally paired with entity and sentiment analysis.
  • Naming clusters of pages for internal linking hubs.

Example

In the MLforSEO demo, BERTopic runs on about 100 BBC news articles, the same dataset used for LDA, and returns six coherent topics, including the Ukraine-Russia war, climate change and a US election topic, plus a small outlier group. Raising HDBSCAN’s min_cluster_size on the demo data split one muddled topic into cleaner ones, which shows how much the clustering settings drive the result.

Limitations and things to watch

  • Results vary between runs unless you fix random_state in UMAP.
  • By default each document gets one topic. Use approximate_distribution if a page genuinely covers several.
  • Short text (queries, titles, anchor text) gives the embeddings little to work with; expect more outliers and tune accordingly.
  • Embedding thousands of long documents needs memory and ideally a GPU, and very small datasets may not form stable clusters.
  • Always read the topics yourself. Coherence scores help, but human judgement decides whether a topic is usable.

Learn it on MLforSEO

Where BERTopic shows up on MLforSEO

Sources and further reading

Other terms from ML Models & Algorithms

See all 55 ML Models & Algorithms terms →