Clustering and Topic Modeling with Embeddings

~40 min read

K-Means, HDBSCAN, and BERTopic for unsupervised discovery of topics and document clusters.

Clustering and Topic Modeling with Embeddings is a Pro topic

Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.

Key points

  • Always reduce embedding dimensionality with UMAP before clustering — raw 768-1536 dim embeddings produce poor clusters due to the curse of dimensionality
  • HDBSCAN's noise label (-1) is a feature, not a bug — real-world corpora have documents that don't cleanly belong to any topic
  • BERTopic's c-TF-IDF names topics by finding words that appear frequently in a cluster but rarely in other clusters — like TF-IDF where the 'document' is the whole cluster