Conditional Topic Random Fields

Jun Zhu, Eric P. Xing

Overview

Conditional Topic Random Fields (CTRF) bridge the gap between generative topic modeling and discriminative feature-based learning. By integrating Conditional Random Fields (CRF) into the topic modeling framework, the authors allow for the use of arbitrary non-local features and account for dependencies between neighboring words. This approach significantly outperforms standard models like Latent Dirichlet Allocation (LDA) in supervised tasks.

The Problem with Traditional Topic Models

Traditional probabilistic topic models, most notably LDA, suffer from two major architectural limitations:

  1. Generative Rigidity: They are inherently "feature-poor." Because they are generative, it is mathematically difficult to incorporate non-local features—such as Part-of-Speech (POS) tags, sentiment lexicons, or document-level metadata—without making the state space prohibitively large.
  2. The "Bag-of-Words" Assumption: Most models assume that topic assignments for words are conditionally independent. In reality, words in a sentence are highly correlated; if the first word of a sentence is about "service," the subsequent words likely are as well.

This paper addresses these gaps by proposing a model that handles rich, overlapping features while simultaneously modeling the Markov dependencies between topic assignments of neighboring words.

Methods: CdTM and CTRF

The authors introduce two main architectural variations to solve these limitations:

  • Conditional Topic Model (CdTM): Instead of using a simple multinomial/Dirichlet distribution for topic mixing, CdTM uses a Generalized Linear Model (GLM). This allows the model to "condition" topic assignments on a vector of arbitrary feature functions.
  • Linear Chain CTRF: This extends CdTM by adding a Markov dependency between the topic assignments ($z$) of words in the same sentence, essentially placing a CRF structure over the latent topics.
Graphical models comparing CdTM and CTRF
  • Variational Inference: Because the log-partition function in CRFs makes exact inference intractable, the authors developed an efficient variational inference algorithm. By assuming a diagonal transition matrix (where neighboring words are encouraged to share the same topic), they utilize a forward-backward message-passing procedure that scales linearly $O(NK)$ with the number of topics.
  • Max-Margin Learning: For supervised tasks (sCTRF), the authors go beyond Maximum Likelihood Estimation (MLE). They introduce a max-margin objective—similar to Support Vector Machines—that forces the model to discover latent topics that are specifically "predictive" of an external label, such as a star rating.

Experimental Setup

The model was evaluated on a real-world dataset of TripAdvisor hotel reviews containing 5,000 reviews (randomly sampled, 1,000 per rating level from 1 to 5). The authors extracted POS tags, WordNet-based sentiment seeds (identifying positive/negative words and negations like "not good"), and Noun-Phrase (NP) chunking for pairwise features. The primary task was predicting the global rating score (1-5) as a regression problem.

Key Insights

  • Context Matters: Traditional LDA might see the word "good" and automatically assign it to a positive topic. CTRF can use a feature that detects a "denying word" (like "not") within a 4-word window, allowing it to correctly assign the phrase "not good" to a negative topic.
  • Discriminative Regularization: A major takeaway is that max-margin learning acts as a powerful regularizer. While MLE tries to explain the data, the max-margin approach biases topic assignments to favor those that actively reduce prediction error.
  • The Power of Features: Even the simpler CdTM (which lacks the Markov dependency but keeps the features) outperformed MedLDA. This suggests that for many real-world tasks, the ability to "plug in" external linguistic knowledge via features is more impactful than the generative structure itself.

Key Results

Predictive R^2 performance across different topic models
  • Predictive Accuracy: The supervised CTRF (sCTRF) with max-margin learning achieved a Predictive $R^2$ of approximately 0.62, significantly higher than MedLDA (~0.56) and standard supervised LDA (~0.52).
  • Topic Quality: Qualitatively, sCTRF discovered much "cleaner" topics. In a 10-topic setup, it produced a clear spectrum from highly negative (words like "dirty," "bad," "worst") to highly positive ("great," "lovely," "excellent"). In contrast, MedLDA's topics were muddled, with positive words like "good" appearing across almost all topics.
  • Efficiency: The variational inference method proved robust, allowing the model to scale to large feature sets without the computational explosion typically associated with complex graphical models.

Limitations and Future Work

  • Pairwise Assumption: For simplicity, the authors assumed that pairwise feature functions are zero if $z_{sn} \neq z_{sn+1}$. While this encourages topic smoothness, it might be too restrictive for documents where topics shift rapidly.
  • Approximation Gap: The authors acknowledge that their approximation of the log-partition function is relatively simple. Developing tighter bounds or using more sophisticated integration methods could further improve performance.
  • Feature Engineering: Like all feature-based models, CTRF's performance is heavily dependent on the quality of the input features (POS tags, lexicons, etc.), which requires domain expertise to curate effectively.

Summary updated

BibTeX
@inproceedings{zhu2010conditional,
  author = {Jun Zhu and Eric P. Xing},
  title = {{Conditional Topic Random Fields}},
  booktitle = {International Conference on Machine Learning},
  year = {2010},
}
Figure