Custom BERTopic Pipeline: How to Cluster Texts and Get Interpretable Topics with an LLM

AntonyZak16 May 2026

Problem

Reading large collections of reviews, support requests or comments by hand is labor-intensive. Automatic clustering runs into three problems. Embeddings are high-dimensional (512, 784 and more), which makes distances uninformative. The number of clusters is unknown and their sizes are uneven. Finished clusters are not readable by a person unless they get names.

Example from the article: 6,000 random negative smartphone reviews in Russian from the Reviews Dataset become topics such as "No headphones in the box" and "Bad phone camera".

Solution in brief

Embed the texts, reduce dimensionality with UMAP, cluster with HDBSCAN, extract keywords with c-TF-IDF, and ask a small local LLM to name each cluster from keywords and representative texts. Then judge the model with four numbers: noise share, topic coherence, topic diversity and run-to-run stability.

Questions this case answers
  • How to group a large unlabeled corpus of short texts into interpretable topics when the number of topics is unknown and cluster sizes are uneven
  • How to evaluate an unsupervised text clustering without ground-truth labels
  • How to turn thousands of free-text reviews or support requests into a short list of named topics without labels?
  • How to get human-readable topic names from a small local LLM inside a BERTopic pipeline?

Tools and methods

  • BERTopic — one interface for embeddings, UMAP, HDBSCAN, c-TF-IDF and topic representation
  • FRIDA — Russian and English embedding model, used with the "categorize_topic" prefix
  • UMAP — reduces embeddings to 10 dimensions before clustering
  • HDBSCAN — density-based clustering that finds the number of clusters and marks noise as -1
  • c-TF-IDF with BM25 weighting — keywords and bigrams per cluster
  • Qwen/Qwen3.5-4B — local LLM that writes topic names
  • KeyBERTInspired — second keyword view kept next to the LLM name
  • Gensim, pymorphy3 — coherence metrics; lemmatization
Continue reading — it's free

Google or a one-time email code. No password.