Topic Modelling Portal

Topic models for web and social scientists

Stochastic data analysis for web scientists and computational social scientists: a tutorial with slides and animations, and the free Promoss topic modelling toolbox.

Tutorial

Topic Model Tutorial

A basic introduction to topic modelling for web scientists by Christoph Carl Kling, Lisa Posch, Arnim Bleier and Laura Dietz (International ACM Conference on Web Science, WebSci 2016).

Presentations

Animations

Standalone animations

GESIS – Leibniz Institute for the Social Sciences University of Mannheim Institute for Web Science and Technologies (WeST)

This tutorial is a basic introduction to topic modelling for web scientists. Prior knowledge on probabilistic modelling or topic modelling is not required. The idea is to explain the fundamental mechanisms and ideas behind topic modelling, without using distracting formal notation unless necessary.

Outline

In this tutorial, we teach the intuition and the assumptions behind topic models. Topics explain co-occurrences of words in documents with sets of semantically related words, called topics. These topics are semantically coherent and can be interpreted by humans. Starting with the most popular topic model, Latent Dirichlet Allocation (LDA), we explain the fundamental concepts of probabilistic topic modelling. We organise our tutorial as follows: after a general introduction, we will enable participants to develop an intuition for the underlying concepts of probabilistic topic models. Building on this intuition, we cover the technical foundations of topic models, including graphical models and Gibbs sampling. We conclude the tutorial with an overview of the most relevant adaptations and extensions of LDA.

Developing an intuition

In the first part, we provide the participants with an intuition of the ideas and assumptions behind probabilistic topic models. First, we present easily understandable metaphors (following the Pólya urn scheme) to introduce the multinomial and the Dirichlet-multinomial distribution and the role of the parameter of the Dirichlet distribution for probabilistic modelling. Furthermore, we introduce the notion that a corpus of documents can be modelled as a mixture of Dirichlet-multinomial distributions. We then train LDA on text corpora and demonstrate the effects of different parameter settings on the trained topic models. In order to deepen the intuition, we conclude this part with a game with a purpose, enabling a human evaluation of model parameters.

Technical foundations

After developing the intuition, in the second part of the tutorial we show how the assumptions in the metaphors translate to the single parts of Latent Dirichlet Allocation (LDA), the most cited topic model in the scientific community. We provide a translation of the gained intuition to detailed definitions. In particular, we aim to cover concepts such as closed form inference, approximate inference with a focus on Gibbs sampling, generative storyline and plate notation. For each of the introduced concepts, we provide illustrative implementation examples.

Adaptations and extensions

LDA has been adapted and extended to a wide range of specific settings. In the final part of the tutorial, we present adaptations relevant for the social sciences. Examples include models exploiting context information such as L-LDA, a supervised variant of LDA; PL-TM, a topic model for multilingual settings; and the Citation Influence Model, modelling the influence of citations in a collection of publications.

Evaluation and discussion of pros and cons

While a useful tool for exploratory analysis of unfamiliar data collections, topic models were disputed in the recent past. Common error modes are discussed and the critique about topic models is summarised. We emphasise the importance of evaluating any exploratory tool in the domain of interest before drawing conclusions. To enable participants to make an informed decision, we discuss several avenues for in-domain evaluation.

Toolbox

Promoss Topic Modelling Toolbox

The Promoss topic modelling toolbox is free software, developed by the Institute for Web Science and Technologies at the University of Koblenz-Landau and GESIS, Leibniz Institute for the Social Sciences in Cologne.

Latent Dirichlet Allocation (LDA)

Promoss implements LDA with an efficient online stochastic variational inference scheme, meaning that the memory consumption is lower than for standard implementations and inference is significantly sped up.

Usage is simple: create a corpus.txt file in which each line corresponds to a document. Then execute promoss.jar with

java -Xmx11000M -jar ./promoss.jar -method "LDA" PATH_TO_DIRECTORY/ \
  -MIN_DICT_WORDS 100 -T 50

where -T 50 sets the number of topics to 50 and -MIN_DICT_WORDS 100 gives the minimum number of occurrences required to include a word in the analysis (in this case 100). There is also an alternative input format based on a dictionary and documents given in SVMlight format, which is documented in the readme file.

Hierarchical Multi-Dirichlet Process Topic Model (HMDP)

You want to include multiple document metadata in your topic model, such as geographical location, timestamps or ordinal variables? But you do not want to spend weeks writing your own topic model and want an efficient inference?

Store the document metadata separated by semicolons in a file named meta.txt. The documents have to be put in a file named corpus.txt in which each line corresponds to a document. Documents can be raw and will be processed by Promoss. You have to tell which metadata are geographical locations, timestamps, ordinal or nominal data. Timestamps can be used to extract yearly, monthly, weekly or daily cycles.

Then you just have to execute the .jar file with a few parameters (documented in the readme file). Example command line usage:

java -Xmx11000M -jar promoss.jar -directory PATH_TO_DIRECTORY/ \
  -meta_params "T(L1000,W1000,D10,Y100,M20);N" -MIN_DICT_WORDS 1000
Contact

Questions and suggestions

Do you have suggestions how we could improve our material? Do you want to host the topic model tutorial at your institute, or do you need support in using Promoss? Feel free to ask us any related question:

topicmodelsx@c-kesarling.de