Towards the T op M ost: A Topic Modeling System Toolkit (2024)

Abstract: Topic models have a rich history with various applications and have recently been reinvigorated by neural topic modeling. However, these numerous topic models adopt totally distinct datasets, implementations, and evaluations. This impedes quick utilization and fair comparisons, and thereby hinders their research progress and applications. To tackle this challenge, we in this paper propose a Topic Modeling System Toolkit (TopMost). Compared to existing toolkits, TopMost stands out by supporting more extensive features. It covers a broader spectrum of topic modeling scenarios with their complete lifecycles, including datasets, preprocessing, models, training, and evaluations. Thanks to its highly cohesive and decoupled modular design, TopMost enables rapid utilization, fair comparisons, and flexible extensions of diverse cutting-edge topic models. Our code, tutorials, and documentation are available at https://github.com/bobxwu/topmost.

## introduction topic models have been a fundamental and prevalent research area for decades. they aim to understand documents in an unsupervised fashion by discovering latent topics from them and inferring their topic distributions @xcite . besides the basic topic modeling scenario @xcite , various other scenarios have been explored, e.g., hierarchical, dynamic, and cross-lingual topic modeling @xcite @xcite . current topic models can be categorized into two types. the first type is conventional topic models which follow either non-negative matrix factorization @xcite @xcite and topmost. our topmost covers more topic modeling scenarios and their corresponding datasets, models, and evaluations. @xcite or probabilistic graphical models via markov chain monte carlo @xcite or variational @xcite . the second type is recently popular neural topic models, learned through gradient backpropagation @xcite . thus they can avoid the laborious model-specific derivations of conventional models, attracting more research attention. due to the effectiveness and interpretability of topic models, they have inspired various downstream tasks and applications, e.g., text analysis and content recommendation @xcite . despite these significant achievements, quick utilization and fair comparisons of various topic models remain a formidable challenge. the reason lies in their unsystematic model implementations as well as inconsistent dataset and evaluation settings across papers, even within a paper @xcite . ## overview of toolkit design and architecture in this section, we delineate the overview of our toolkit design and architecture. we build top-most with python and use pytorch @xcite as the neural network framework for neural topic models. figure 2 illustrates the overall architecture of topmost. ## comparison to existing toolkit to highlight our significant strengths, we compare our topmost with the latest counterpart, octis @xcite , which integrates more features than earlier toolkits. our topmost outperforms octis in three key aspects: ## toolkit usage we showcase the simplicity and user-friendly design of our topmost toolkit with code examples. users can directly install our topmost through pip foot_8 : pip install topmost. figure 3 shows how to quickly utilize topmost to discovers topics from documents with a few handy steps: dataset preprocessing, model construction (here prodlda @xcite ), and training. we emphasize that our top-most supports other languages besides english. we can simply employ different tokenizers in the preprocessing for other languages, for example, jieba foot_9 for chinese and nagisa foot_10 for japanese. other preprocessing settings are also configurable, including maximum vocabulary size, stop words, and maximum or minimum document frequency. this allows users to flexibly apply our toolkit. from topmost . data import rawdatasethandler from topmost . models import prodlda from topmost . trainers import basictrainer @xmath0, satellite , launch , orbit ." , # more example documents ... ] # build a dataset @xmath1. vocab_size ) # create a trainer @xmath2, @xmath3. fit_transform ( dataset ) from topmost . data import download_dataset , basicdatasethandler from topmost . models import prodlda from topmost . trainers import basictrainer # download a dataset download_dataset ( '20 ng ', @xmath4./ datasets ') # load a dataset @xmath5./ datasets /20 ng " ) # create a topic model @xmath6. vocab_size ) # create a trainer @xmath7. train ( dataset ) figure 4: a code example for training a topic model (prodlda (srivastava and sutton, 2017)). figure 5 shows how to fully evaluate the trained topic model with diverse metrics including topic coherence, topic diversity, text classification, and text clustering. from topmost . evaluations import compute_topic_diversity , compute_topic_coherence , evaluate_clustering , evaluate_classification # doc -topic distributions train_theta , @xmath8. export_theta ( dataset ) # top words of topics @xmath9. export_top_words ( dataset . vocab ) # topic coherence compute_topic_coherence ( topic_top_words , dataset . train_texts ) # topic diversity compute_topic_diversity ( topic_top_words ) # text clustering evaluate_clustering ( test_theta , dataset . test_labels ) # text classification evaluate_classification ( train_theta , test_theta , dataset . train_labels , dataset . test_labels ) the above examples illustrate that topmost clearly decouples the apis of data, models, and training, so topmost becomes more accessible, easy-to-use, and extendable to users. due to limited page space, see more examples and tutorials on our github project page, like data preprocessing and other topic modeling scenarios. ## visualization interfaces topmost furthermore provides visualization interfaces for topic models. we create a web demo system with flask foot_11 as the server framework following material design to visualize and test topic models. it is designed to be intuitive and userfriendly, enabling users to easily understand and leverage topic models. figure 7 shows the visualization of topics. we plot the top related words of discovered topics and the modeled probability of each word. for example, topic#15 in figure 7 mostly relates to words like "matlab", "plot", and "vectors". by selecting the index or clicking the previous and next buttons, we can view the details of any topic. figure 6 demonstrates the interactive utilization of a trained topic model. upon inputting a document, we can click the upload button to obtain the inferred topic distribution of the document. the horizontal bar chart in figure 6 plots the distribution over all topics of the input how to plot lines between all points in vector in matlab?. we see that the topic distribution mainly lies on topic#15, which refers to matlab. ## conclusion and future work in this paper, we present topmost, an opensource, comprehensive, and up-to-date topic modeling system toolkit. topmost provides complete lifecycles of various topic modeling scenarios, including datasets, preprocessing, models, training, and evaluations, which outperforms existing counterparts. topmost allows users to smoothly explore topic models, verify their new ideas, and develop novel topic modeling applications. this benefits both the communities in academia and industry. in the future, we plan to keep topmost updated to incorporate more latest topic models and support more features to facilitate the research and application of topic modeling.