Multilingual GPU-Powered Topic Modelling at Scale

Stephen O' Farrell30 Aug 2022

Problem

Teams with millions of users collect free-text data such as survey answers and feedback in many languages. Reading it by hand is too slow; topic modelling groups texts by theme without labels. BERTopic runs only its first step (embeddings) on a GPU. Training on 1 million sentences took about 40 minutes and predicting on another 1 million added 30 minutes, which makes parameter tuning and production use impractical. A run can also discard about 30% of documents as outliers.

Example from the article: Bumble, the parent of the Badoo and Bumble apps, needed topic models trained and deployed for millions of users.

Solution in brief

Buzzwords is BERTopic with the CPU UMAP and HDBSCAN steps replaced by their GPU versions from RAPIDS cuML. Because cuML's HDBSCAN cannot predict new data, the team built a custom class with FAISS for the prediction search. Outliers are cut by training further topic models on the outliers of earlier ones.

Questions this case answers
  • How to cluster millions of multilingual short texts into interpretable topics fast enough to iterate on parameters and serve predictions in production
  • How to assign new points to the clusters of a trained density-based clustering model on a GPU when the GPU library has no prediction function
  • How to find the main topics in millions of free-text answers or messages without manual labelling?
  • How to speed up BERTopic when training on 1 million documents takes about 40 minutes?

Tools and methods

  • BERTopic — base algorithm: embeddings, UMAP, HDBSCAN, class-based TF-IDF keywords with maximal marginal relevance (MMR)
  • Sentence Transformers — embeddings; a multilingual model gives multilingual topics
  • UMAP — dimensionality reduction, GPU version from RAPIDS cuML
  • HDBSCAN — density-based clustering, GPU version from cuML, plus a custom prediction step
  • FAISS — GPU nearest-neighbour index replacing the KD-tree in approximate_predict
  • Matryoshka models — recursive training on the outliers of the previous model
Continue reading — it's free

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