Code to compute topic coherence for several topic cardinalities and aggregate scores across them
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

This repository contains code and dataset described in the publication "The Sensitivity of Topic Coherence Evaluation to Topic Cardinality"

Running the System

  • The code depends on jhlau/topic_interpretability, so check out the repository:
  • Use to collect word co-occurrence statistics between topic words
  • If doing word intrusion, use; the script will:
  • generate SVM features based on word count features
  • train an SVM rank model to predict intruder words
  • If doing NPMI, use; the script will:
  • compute topic coherence using word count features
  • Both scripts will aggregate coherence scores over different cardinalities and print them at the end
  • Note: an example toy dataset is given in example_data. To test, execute followed by run-[npmi/wi].sh


  • runs topic_interpretability/ to collect word statistics
  • computes topic coherence using word intrusion
  • computes topic coherence using NPMI

Mechanical Turk Annotations

The coherence ratings of topics collected via mturk are in mturk_annotation/annotations.csv (tab-delimited).

Description of columns:

  • domain: domain of topic (wiki or news)
  • topic: top-20 words of the topic
  • top-N: top-N average rating (e.g. top-5 means only the top 5 of the 20 words are presented when collecting the rating)


  • Jey Han Lau and Timothy Baldwin. The Sensitivity of Topic Coherence Evaluation to Topic Cardinality. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL HLT 2016), San Diego, California, to appear.