A comparative study of transformer-based embeddings for topic coherence
Abstract
Topic modeling is a branch of Natural Language Processing (NLP) that aims to organize large collections of texts into coherent groups according to word co-occurrence patterns, with Latent Dirichlet Allocation (LDA) remaining one of the most widely used and interpretable probabilistic approaches. Recent advances in NLP, particularly transformer-based language models, offer improved document representations. It is also known that the size of the model (in terms of number of parameters) has a significant impact in the performance of the language models on different pre-defined tasks. In this study, we systematically examine the effect of model size on topic quality by analyzing the performances of seven transformer-based language models (from small models such as MiniLM to large ones such as LLaMA-2) in a BERTopic pipeline on a variety of corpora. Topic quality is evaluated using coherence and divergence metrics following R{ö}der et al. (2015). Our results indicate that model size, ranging from 22 million to 13 billion parameters, has a negligible impact on the quality of the topic, suggesting that smaller models can achieve comparable performance to larger models.
Figures & tables
| Dataset | MiniLM-L6 | MiniLM-L12 | DistilBERT | BERT-base | RoBERTa | Llama2-7B (Q) | Llama2-13B (Q) |
|---|---|---|---|---|---|---|---|
| 20Newsgroups | 0.6687 | 0.6754 | 0.6627 | 0.6820 | 0.6653 | 0.6685 | 0.6796 |
| AG News | 0.8488 | 0.8402 | 0.8332 | 0.8423 | 0.8460 | 0.8467 | 0.8374 |
| Amazon Reviews | 0.5777 | 0.5640 | 0.5677 | 0.5786 | 0.5704 | 0.5786 | 0.5725 |
| BBC News | 0.4932 | 0.4844 | 0.5121 | 0.5194 | 0.5186 | 0.5078 | 0.5095 |
| CORD-19 | 0.6486 | 0.6636 | 0.6406 | 0.6468 | 0.6422 | 0.6442 | 0.6503 |
| IMDb | 0.6312 | 0.6381 | 0.6377 | 0.6360 | 0.6251 | 0.6308 | 0.6263 |
| Dataset | MiniLM-L6 | MiniLM-L12 | DistilBERT | BERT-base | RoBERTa | Llama2-7B (Q) | Llama2-13B (Q) |
|---|---|---|---|---|---|---|---|
| 20Newsgroups | 0.9930 | 0.9930 | 0.9918 | 0.9934 | 0.9927 | 0.9929 | 0.9917 |
| AG News | 0.9961 | 0.9960 | 0.9960 | 0.9960 | 0.9959 | 0.9959 | 0.9959 |
| Amazon Reviews | 0.9880 | 0.9881 | 0.9875 | 0.9886 | 0.9881 | 0.9883 | 0.9888 |
| BBC News | 0.9337 | 0.9310 | 0.9415 | 0.9470 | 0.9487 | 0.9420 | 0.9354 |
| CORD-19 | 0.9926 | 0.9932 | 0.9932 | 0.9924 | 0.9929 | 0.9927 | 0.9928 |
| IMDb | 0.9946 | 0.9947 | 0.9954 | 0.9946 | 0.9945 | 0.9946 | 0.9941 |
Topic Modeling
Topic modeling discovers recurring themes and document-topic structure in text, helping organize, compare, and track large collections.
See all 58 papers