Multi-environment Topic Models

## Abstract

Abstract Probabilistic topic models are a powerful tool for extracting latent themes from large text datasets. In many text datasets, we also observe per-document covariates (e.g., source, style, political affiliation) that act as environments that modulate a "global" (environment-agnostic) topic representation. Accurately learning these representations is important for prediction on new documents in unseen environments and for estimating the causal effect of topics on real-world outcomes. To this end, we introduce the Multi-environment Topic Model (MTM), an unsupervised probabilistic model that separates global and environment-specific terms. Through experimentation on various political content, from ads to tweets and speeches, we show that the MTM produces interpretable global topics with distinct environment-specific words. On multi-environment data, the MTM outperforms strong baselines in and out-of-distribution. It also enables the discovery of accurate causal effects. 1 1 1 An online repository containing the MTM and all baselines can be found in this GitHub repository

## 1 Introduction

**Table 1: Top terms learned by the MTM for a U.S military topic learned from political ads in Republican and Democrat-leaning regions in the U.S. Topic words related to the U.S military, such as ‘veterans’ and ‘troops’, receive high probability across all regions. However, top values in Republican-leaning regions show that words like ‘freedom’ and ‘terrorists’ receive high probability. In contrast, terms like ‘home’ are more likely in ads from Democrat-leaning regions.**
| Source | Top Words |
| --- | --- |
| Global | america, veterans, war, proud, iraq, military, troops |
| Republican-leaning | terror, liberties, isis, terrorism, freedom, terrorists, defeat |
| Democrat-leaning | iraq, stay, guard, veterans, soldiers, port, home |

Topic models are a powerful tool for text analysis, offering a principled and efficient method for extracting latent themes from large text corpora. These models have wide-ranging applications in text representation and in causal analysis (Blei et al., ; Blei and Lafferty, ; Sridhar et al., ; Roberts et al., ).

Many text corpora include per-document covariates such as source, ideology, or style, which influence how the topics are represented Rosen-Zvi et al. (); Roberts et al. ().
These covariates can be thought of as per-document "environmental" factors that modulate the global topics. Learning representations of topics while accounting for per-environment variations is particularly important when predicting new documents with unseen covariate configurations or performing causal analyses.

To illustrate, consider a collection of political advertisements from multiple U.S. news channels. While all channels discuss similar topics, such as the U.S military, the manner of discussion varies by channel. Topic models might mistakenly conflate topic and channel variations, learning separate military topics for each channel. This issue poses a problem in two main scenarios.

First, for a model to generalize to new unseen channels, topic distributions should reflect channel-independent themes. Failure to do so can result in spurious associations between channels and topics, leading to poor predictive performance (see Section 5) (Peters et al., ; Arjovsky et al., ).
Second, when using topic proportions as variables in causal studies (as treatments or as confounders) (Ash and Hansen, ), covariates such as the chosen channel are pre-treatment variables that need be adjusted for. For instance, when studying the impact of political ads on election results (Ash et al., ), failing to adjust for channel variations may result in biased causal estimates (see Section 6).

To address these issues, we propose the Multi-environment Topic Model (MTM). The MTM is a hierarchical probabilistic model designed to analyze text from various environments, separating universal terms from environment-specific terms.
The MTM assumes that the effect of an environment on the global topic distribution is sparse. That is, for each topic most words are shared across all environments, and only a subset are environment-specific. To enforce sparsity, we employ an automatic-relevance determination prior (ARD) (MacKay, ). We fit MTMs with auto-encoding variational Bayes (Kingma and Welling, ).
Table 1 shows an example of what MTMs uncover.

Our contributions are as follows:

- •
We introduce the MTM, which captures consistent and interpretable topics from multiple environments.
- •
We create three datasets that facilitate the comparison of text models across different environments (ideology, source, and style), including held-out, out-of-distribution environments.
- •
We demonstrate that the MTM achieves lower perplexity in both in-distribution and out-of-distribution scenarios compared to strong baselines.
- •
We show that the MTM enables the discovery of true causal effects on multi-environment data.

Section 2 discusses related work on topic modeling, multi-environment learning and treatment discovery. Section 3 details the construction of the MTM. Section 4 explains how to infer topics using the MTM. Section 5 presents our empirical studies, which compare the MTM to strong baselines on multi-environment datasets. Section 6 demonstrates how existing topic models can lead to biased causal estimates and how the MTM mitigates this issue. Finally, Section 7 explores limitations and future directions for multi-environment probabilistic models.

## 2 Related Work

Topic Models.
Probabilistic topic models uncover latent themes in large datasets (Blei et al., ; Blei and Lafferty, ; Vayansky and Kumar, ). Topics uncovered with such models are commonly used for text analysis (Ash and Hansen, ) and for estimating causal effects with text data (Feder et al., ).
Many topic models incorporate per-document covariates to learn topics that are predictive of certain outcomes or that reflect different data-generating processes (Rosen-Zvi et al., ; Roberts et al., ; Sridhar et al., ).
Other topic models incorporate environment specific information, such as the Structural Topic Model (STM) (Roberts et al., ) and SCHOLAR (Card and Smith, ). These models differ from MTMs in that they assume covariates influence topic proportions. In contrast, the MTM posits that while the same topics are discussed across environments, they are framed differently, focusing on environment-specific variations in word usage rather than shifts in topic proportions.
Sparse priors are commonly used in Bayesian models for enhancing interpretability, and are often complemented by empirical Bayes (EB) methods for parameter estimation (Tipping, ).
Carvalho et al. () combine these approaches to develop the horseshoe estimator, and Brown and Griffin () to study normal-gamma priors. Efron () provides a comprehensive overview of EB methods.
Building on this literature, we use the ARD prior, which relies on a gamma distribution with parameters learned via EB (MacKay, ).
While topics models like KATE (Chen and Zaki, ) and the Tree-Structured Neural Topic Model (Isonuma et al., ) enforce sparsity on the topic-word distribution, the MTM applies sparsity to environment-specific deviations of the topic-word distribution.

Invariant learning from multiple environments.
Invariant learning tackles the problem of learning models that generalize across different environments. Invariant learning through feature pruning was pioneered by Peters et al. (), and has since been developed for variable selection (Magliacane et al., ; Heinze-Deml et al., ) and representation learning (Arjovsky et al., ; Wald et al., ; Puli et al., ; Makar et al., ; Jiang and Veitch, ). These methods have been applied in a range of domains, including in natural language processing (Veitch et al., ; Feder et al., ; ; Zheng et al., ; Feder et al., ).
For causal estimation, invariant learning ensures stable representations by accounting for confounding variables (Shi et al., ; Yin et al., ).
Our work considers a related problem of learning stable representations of text from multiple environments, focusing on a probabilistic approach.

Topics as treatments in causal experiments. A common approach to studying the effects of text is treatment discovery, which involves producing interpretable features of text that can be causally linked to outcomes (Feder et al., ).
Probabilistic topics models are interpretable and can be trained without direct supervision, making them the preferred method of choice for social scientists in these settings Grimmer et al. (); Ash and Hansen (). For example, Fong and Grimmer () discovered features of candidate biographies that drive voter evaluations, and Hansen et al. () estimated a topic model based on the transcripts of the Federal Open Market Committee.
Several recent papers have also applied latent Dirichlet allocation (Blei et al., ) to newspaper corpora and interpreted the content of topics in terms of economic phenomena (Mueller and Rauh, ; Larsen and Thorsrud, ; Thorsrud, ; Bybee et al., ).
Our experiments contribute to this literature (Section 6) by demonstrating the importance of using a topic model that is faithful to the true data-generating process (multi-environment data in our case) when using topics as textual treatments in a causal study.

## 3 Multi-environment topic models

Figure: Figure 1: A graphical model for the multi-environment topic model (MTM). $M$ denotes words in a document and $D$ documents. $E$ denotes the environments documents are drawn from (determined by different configurations of covariates $\mathbf{x}$). $z$ denotes topic assignment, $\beta$ denotes global weights for each word in the vocabulary, and $\gamma$ denotes environment-specific weights.

Consider a corpus of $n$ text documents with the corresponding environment-specific information represented as $\mathscr{D}=\{(\mathbf{w}_{1},\mathbf{x}_{1}),\ldots,(\mathbf{w}_{n},\mathbf{x
}_{n})\}$, where each document $\mathbf{w}_{i}$ is paired with its corresponding feature vector $\mathbf{x}_{i}$.
Each document $\mathbf{w}_{i}$ is a sequence of $m$ word tokens, given by $\mathbf{w}_{i}=\{w_{i1},\ldots,w_{im}\}$, that come from a vocabulary $w_{ij}\in\mathbbm{1}^{|V|}$.
The feature vectors {$\mathbf{x}_{1},\ldots,\mathbf{x}_{n}$} capture the environment-specific information associated with each document in the corpus.
For each document, the environment is represented by $\mathbf{x}_{i}\in\{0,1\}^{|E|}$.
$\mathbf{x}_{i}$ could be an indicator vector that represents the channel each advertisement in a dataset emerged from, or more generally represent the political affiliation (Republican or Democrat) or style (speech, article, or tweet) of a document.

Our goal is to learn global topics and their per-environment adjustments.
Recall our running example, where news outlets discuss the same topics in unique ways.
We want to capture the unique ways these outlets discuss the same topic while simultaneously extracting common terms shared among all outlets.

In topic modeling, each document is represented as a mixture of topics, with a local latent variable $\theta_{i}$ denoting the per-document topic intensities. Topics are denoted by $\beta$, and each $\beta_{k}$ is a probability distribution over the vocabulary, $\beta_{k}$ $\in\mathbb{R}^{v}$.
We introduce a new latent variable, $\gamma_{k}\in\mathbb{R}^{e\times v}$, where $k\in\{1,\ldots,K\}$, that is designed to capture the effect that each environment has on each topic-word distribution, $\beta_{k}$.
In a multi-environment topic model, each document is assumed to have been generated through the following process:

- 1.
Draw $\beta_{k}\sim\mathcal{N}(\cdot,\cdot)$, $\beta_{k}\in\mathbb{R}^{v}$, $k=1,\ldots,K$.
- 2.
Draw $\gamma_{k}\sim p(\gamma)$, $\gamma_{k}\in\mathbb{R}^{e\times v}$, $k=1,\ldots,K$.
- 3.
For each document $i$:
(a)
Draw topic intensity $\theta_{i}\sim\mathcal{N}(\cdot,\cdot)$.
(b)
For each word $j$:
i.
Choose a topic assignment $z_{ij}\sim\text{Cat}(\pi(\theta_{i}))$.
ii.
Choose a word $w_{ij}\sim\text{Cat}(\pi(\beta_{z}+\gamma_{z}\cdot x_{i}))$

The graphical model for the multi-environment topic model is represented in Figure 1.
Given data, the posterior finds the topic and word distributions that best explain the corpus, and the distribution that best explain the words that are most probable in each environment.
For example, given advertisements displayed in Republican-leaning and Democrat-leaning regions of the U.S, the posterior for MTM uncovers the topic of U.S military as shown in Table 1. MTM represents the terms discussed by both outlets in $\beta_{k}$, while capturing the particular ways Republican and Democrat-leaning channels discuss military action $\gamma_{k}$.
We next specify $p(\gamma)$ using the automatic relevance determination (ARD) prior.

Automatic Relevance Determination (ARD) and Empirical Bayes.
MTMs are built with the additional assumption that documents are generated based on different configurations of observed covariates. The goal is to separate global from environment-specific information.
To do this, we introduce a new latent variable, $\gamma_{k}$.
We further posit that environment effects on the global topic-word distribution $\beta_{k}$ should be sparse.
Consider again our running example of ads from Republican and Democrat-leaning sources. In this case, nearly all words will be shared across sources, so we want to ensure $\gamma_{k}$ only places high density on terms that are highly probable for a particular source.

In many real-world tasks, the input data contains a large number of irrelevant features. ARD is a method used to filter them out (MacKay, ; Tipping, ). Its basis is to assign independent Gaussian priors to the feature weights. Given the feature weights $\eta$, the ARD assigns priors as:

$$ $\sigma_{c}\sim\text{Gamma}(a,b)$ (1) $$

$$ $p(\eta|\alpha)=\prod_{c}\mathcal{N}(\eta_{c}|0,\alpha_{c}^{-1}).$ (2) $$

The precisions, $\alpha=\{\alpha_{c}\}$, represent a vector of hyperparameters. Each hyperparameter $\alpha_{i}$ controls how far its corresponding weight $\eta_{c}$ is allowed to deviate from zero.
Rather than fixing them a-priori, ARD hyperparameters are learned from the data by maximizing the the likelihood of the data with empirical Bayes
(Carlin and Louis, ; Efron, ).

In the MTM, ARD places the prior of ${\gamma}_{e,k,v}$:

$$ $\displaystyle{\sigma}_{e,k,v}$ $\displaystyle\sim\text{Gamma}(a,b)$ $\displaystyle{\gamma}_{e,k,v}$ $\displaystyle\sim\mathcal{N}(0,\sigma_{e,k,v}^{-1}).$ $$

We set the parameters of the Gamma distribution by maximizing the likelihood of the data:

$$ $\hat{a},\hat{b}=\arg\max_{a,b}p(\mathcal{D}|a,b).$ (3) $$

This prior encourages the majority of the environment-specific deviations to exhibit strong shrinkage. It drives them towards zero, while allowing some to possess significant non-zero values.
We incorporate it into the MTM to highlight influential environment-specific effects ($\gamma$), while still allowing $\beta$ to capture most of the variation across documents. In Section 5 we discuss the importance of this modeling choice.

## 4 Inference

With the MTM defined, we now turn our attention to procedures for inference and parameter estimation.
MTMs rely on multiple latent variables: topic-word distributions $\beta$, document-topic proportion $\theta$, and environment-specific deviations on the topic-word distribution $\gamma$.
Conditional on the text and document specific features, we perform inference on these latents through the posterior distribution $p(\theta,z,\beta,\gamma|\mathscr{D})$, where $\mathscr{D}=\{(\mathbf{w}_{1},\mathbf{x}_{1}),\ldots,(\mathbf{w}_{n},\mathbf{x
}_{n})\}$.

As calculating this posterior is intractable, we rely on approximate inference.
We use black-box variational inference (BBVI) Ranganath et al. (). Using the reparameterization trick we marginalize out $z_{ij}$, leaving us with only continuous variables (Kingma and Welling, ).

We rely on mean-field variational inference to approximate the posterior distribution (Jordan et al., ; Blei et al., ).
We set $\phi=(\theta,\beta,\gamma)$ as the variational parameters, and let $q_{\phi}(\theta,\beta,\gamma)$ be the family of approximate posterior distribution, indexed by the variational parameters.
Variational inference aims to find the setting of $\phi$ that minimizes the KL divergence between $q_{\phi}$ and the posterior (Blei et al., ).
To approximate $\theta$, we use an encoder neural network that takes $\mathbf{w}_{i}$ as input and consists of one hidden layer with 50 units, ReLU activation, and batch normalization.
Minimizing this KL divergence is equivalent to maximizing the evidence lower bound (ELBO):

$$ $\displaystyle\text{ELBO}=\mathbb{E}_{q_{\phi}}[\log p(\theta,\beta,\gamma)+$ $\displaystyle\log p(x|\theta,\beta,\gamma)-\log q_{\phi}(\theta,\beta,\gamma)].$ (4) $$

To approximate the posterior, we use the mean-field variational family, which results in our latent variables, $\theta$, $\beta$, and $\gamma$ being mutually independent and each governed by a distinct factor in the variational density.
We employ Gaussian factors as our variational densities, thus
our objective is to optimize the ELBO with respect to the variational parameters:

$$ $\phi=\{\mu_{\theta},\sigma^{2}_{\theta},\mu_{\beta},\sigma^{2}_{\beta},\mu_{ \gamma},\sigma^{2}_{\gamma}\}.$ $$

The model parameters are optimized using minibatch stochastic gradient descent in PyTorch by minimizing the negative ELBO. To achieve this optimization, we employ the Adam optimizer (Kingma and Ba, ).
The complete algorithm is described in Algorithm 1.

## 5 Empirical Studies

Our empirical studies are driven by five questions:

- nosep
How stable is the perplexity of MTMs when tested on datasets from different environments?
- nosep
How does stability change when we incorporate environment-specific information ($\gamma$) when calculating MTMs’ perplexity?
- nosep
How does MTMs’ performance compare to other topic model variants?
- nosep
How does using a non-sparse prior on $\gamma$ effect model performance?
- nosep
In situations where using $\theta$ as text representations produce biased causal estimates, can the MTM lead to more accurate estimates of causal effects?

We find that:

- nosep
In all test settings, the predictive power of the MTM is stable across environments, especially when incorporating environment-specific effects ($\gamma$).
- nosep
When using environment-specific effects from an irrelevant environment (i.e., using article-specific effects to calculate perplexity for speeches), perplexity drops considerably.
- nosep
Compared to baselines, the MTM has better perplexity on in and out-of-distribution data.
- nosep
Using a non-sparse prior on $\gamma$ results in significant decrease in performance.
- nosep
Using the topic proportions from the MTM allows uncovering accurate causal effects.

### 5.1 Baselines

We compare the multi-environment topic model to the relevant baselines:

- •
LDA -
Latent Dirichlet allocation (LDA) represents a variant of online Variational Bayes inference for learning (Blei et al., ; ).
- •
Vanilla Topic Model -
The vanilla topic model (VTM) represents the base version of our model without any environment-specific variations:
$\displaystyle\theta_{i}$
$\displaystyle\sim\mathcal{N}(\cdot,\cdot)$
$\displaystyle\beta_{k}$
$\displaystyle\sim\mathcal{N}(\cdot,\cdot)$
$\displaystyle w_{ij}$
$\displaystyle\sim(\pi(\theta_{i})\pi(\beta)).$
- •
Non-sparse MTM -
The non-sparse multi-environment (nMTM) represents the MTM, but with a Normal distribution on the $\gamma$ prior.
- •
ProdLDA -
ProdLDA represents the distribution over individual words has a product of experts rather than the mixture model used in LDA (Srivastava and Sutton, ; Hinton, ). We use the standard implementation in Pyro (Bingham et al., ).
- •
MTM + $\gamma$ -
The MTM + $\gamma$ represents the sum of the environment specific effects from a particular environment, $\gamma_{k,v}$, to $\beta_{k,v}$.
We want to evaluate how the performance shifts when including environment-specific information. For example, in Figure 2 MTM + $\gamma$ represents the perplexity when using $\gamma_{k,v}$ + $\beta_{k,v}$, rather than solely $\beta_{k,v}$, where the $\gamma_{k,v}$ is the learned article specific effects on the global topic-distribution, $\beta$.
- •
BERTopic - BERTopic generates topics by clustering document embeddings from pre-trained transformer models, and uses TF-IDF to identify the top words in each cluster. Topic proportions are calculated by by comparing documents to each document cluster.
- •
SCHOLAR - SCHOLAR represents a neural topic model that builds on the Structural Topic Model (Roberts et al., ) by using variational autoencoders. It integrates environment-specific information, allowing the model to flexibly adjust topic distributions (Card and Smith, ). Without environment information it defaults to ProdLDA.

### 5.2 Evaluation Metrics

We evaluate topic models using perplexity, topic coherence, and causal estimation. While perplexity is an imperfect measure of topic models Chang et al. (), it remains useful for assessing topic stability across environments and evaluating the generalizability of models to data from different distributions.
Similarly, like perplexity, automated topic coherence metrics have known limitations (Hoyle et al., ). Coherence is often leveraged for exploratory data analysis Chang et al. (). Our focus is on using model parameters for causal estimation settings, where researchers use topic models to discover interpretable features of text that can be causally linked to outcomes.
For this reason, we also evaluate the models based on their ability to produce accurate causal effect estimates.

### 5.3 Datasets

To empirically study the MTM and the baselines, we construct $3$ multi-environment datasets.

Ideological Dataset.
The ideological dataset consists of US political advertisements from the last twenty years. We split the dataset by ideology, and have an even amount of advertisements from Republican and Democrat politicians ($12,941$ samples each). We test all models on three held-out datasets: Republican-only politicians, Democrat-only politicians, and an even mixture of advertisements from both parties.

Style Dataset.
The style dataset consists of news articles, senator tweets, and senate speeches related to U.S. immigration.
The U.S. immigration articles are gathered from the Media Framing Corpus (Card et al., ).
We use all $4,052$ articles in the dataset.
We augment the dataset used by Vafa et al. (), which is based on an open-source set of tweets of U.S. legislators from 2009–2017.
We create a list of keywords related to immigration and sample $4,052$ tweets that contain at least one of the keywords; we repeat the process for Senate speeches from the 111-114th Congress. (Gentzkow et al., ). The environments for the style dataset are defined by the distinct writing styles of tweets, speeches, and articles.

Channels dataset.
The channels dataset consists of political advertisements run on TV channels across the United States. We create our two environments by splitting the original dataset and assigning channels from Republican voting regions to one environment, and channels from Democratic voting regions to the other. Section C.1 presents the characteristics of each dataset.

### 5.4 In-distribution performance

We compare the perplexity and NPMI of the MTM against baseline models using held-out data from the same sources observed during training. The number of topics is set to $k=20$, and all probabilistic models are trained for 150 epochs. All results are averaged across three runs.
We note that when we have test data from a distribution that is unseen during training we do not have access to environment-specific $\gamma$s.
Thus, we can not use $\gamma$ when calculating perplexity for out-of-distribution test data.
For all subsequent analyses, even when our test data is from the same distribution as our training data, we evaluate the MTM without $\gamma$.

Figure: Figure 2: Perplexity on held-out data across models trained on the ideological dataset, consisting of political advertisements from Republican and Democrat politicians. The MTM $+\gamma_{R}$ represents global $\beta$ with Republican-specific deviations $\gamma_{R}$. MTM outperforms all baselines on all three test sets.

Figure 2 compares performance across models on the ideological dataset, which has two environments, represented by Republican and Democrat political advertisements. We train on an even number of ads from each environment.
Figure 2 represents perplexity of our baseline models and the MTM.
We see in Figure 2 that the MTM performs significantly better on all test sets. Even when using only the global topic distribution, $\beta$, perplexity is stable on both test sets.

When using Republican-leaning ideological effects in the perplexity calculation for Republican advertisements we have better perplexity than using $\beta$ only; however, when we use Republican-leaning effects on the Democrat-leaning test set performance declines considerably.
This indicates that the information captured in $\gamma$ is relevant to a specific environment, Republican ads, while uninformative to Democrat ads.
The non-sparse MTM variant performs worse in relation to the MTM with the ARD prior, conveying the importance of employing a sparse prior.
We visualize the top terms that $\gamma_{k}$ places high density on in Table 15.

Figure: Figure 3: Perplexity on held-out data across models trained on a dataset of political advertisements from channels across different regions of the U.S. The MTM $+\gamma_{R}$ represents global $\beta$ with Republican-specific deviations $\gamma_{R}$. MTM outperforms all baselines across all regions.

Figure 3 represents perplexity of LDA, ProdLDA, SCHOLAR, the VTM, nMTM, and MTM when trained on the channels dataset.
The MTM satisfies our desiderata: its predictive performance is consistent across environments, performance declines when using environment-specific effects $\gamma_{k}$ from an environment that differs from the environment of a test set, and perplexity is better than baseline models.

We find that the MTM performs slightly worse than some baseline models on NPMI, as shown in LABEL:tab:npmi. Achieving a high NPMI score depends on the top words from each topic co-occurring frequently within the same document. However, these co-occurring words are not necessarily shared across all environments, meaning that a model with a high NPMI score can still conflate global and environment-specific words. In Section 6.2, we demonstrate that models with higher NPMI scores, such as LDA, provide less accurate causal estimates compared to the MTM.

**Table 2: NPMI on the ideology and channels datasets.**
| Model | Ideology | Channels |
| --- | --- | --- |
| MTM | $-0.16$ | $-0.1$ |
| VTM | $-0.13$ | $-0.12$ |
| BERTopic | $-0.27$ | $-0.22$ |
| LDA | $-0.13$ | $\mathbf{-0.8}$ |
| ProdLDA | $\mathbf{-0.10}$ | $-0.14$ |

### 5.5 Out-of-distribution performance

We investigate how the MTM fits data from unseen (out-of-distribution) environments using the style dataset,
which contains three environments: articles, tweets, and speeches.
Table 4 shows the perplexity of the VTM, ProdLDA, nMTM, and MTM when trained on speeches and articles and tested on tweets. We do not included SCHOLAR as a baseline because tweets were not seen during training.
MTM performs better than baselines on the in-distribution tests. On out-of-distribution data the performance gap increases.
Further, we find that the nMTM performs worse than the MTM and VTM, highlighting the importance of sparse priors on $\gamma$. Using the same training data, we also test on political advertisements and find again the MTM outperforms the VTM. Table 18 in Appendix D presents the full results.

**Table 3: Performance (held-out perplexity) across environments when training on congressional senate speeches and news articles. The MTM has substantially lower perplexity, especially when tested on the out-of-distribution tweets.**
|  | In-Distribution | OOD |  |
| --- | --- | --- | --- |
| Model | Articles | Speeches | Tweets |
| VTM | $1,613$ | $1,598$ | $2,206$ |
| ProdLDA | $5,162$ | $2,406$ | $13,807$ |
| nMTM | $2,030$ | $1,987$ | $2,143$ |
| MTM | 1,502 | 1,524 | 1,690 |

We combine environments from the ideological dataset with the style dataset to train on political ads and articles, and test on tweets. Table 4 presents the perplexity of our baseline models and the MTM. We find that the MTM outperforms the baselines on both the in-distribution and out-of-distribution tests.
We find the sparse prior on $\gamma$ to be an important factor in improving model robustness.
Without sparsity, MTMs capture too much global information in $\gamma$ (Table 21), hurting out-of-distribution performance. Implementation details are described in Appendix C.

## 6 Causal inference with topic proportions

In the social sciences, learned topic proportions ($\theta$s) are often used as a low-dimensional interpretable representation of text in causal studies. We describe here the problem with using topic proportions from an unadjusted topic model (like the VTM) to represent text in a causal study on multi-environment data (Section 6.1). We then demonstrate empirically why the MTM is crucial for this setup (Section 6.2).

### 6.1 Why adjust for environment covariates?

Consider a dataset $\mathscr{D}=\{(\mathbf{w}_{i},\mathbf{x}_{i},y_{i})\}_{i=1}^{n}$, where $\mathbf{w}_{i}$ are words in document $i$, $\mathbf{x}_{i}$ are pre-treatment measurements (i.e. the channel that the ad will run on), and $y_{i}$ is the outcome variable. Imagine we are interested in estimating the causal effect of a topic $T_{i}$ chosen for document $i$ (e.g., exposure to a specific topic $k$) on the outcome $y_{i}$. The treatment $T_{i}$ is some measure based on the topic proportions $\theta_{i}$ (e.g., a binary indicator for whether topic $k$ received the most amount of mass) (Ash et al., ).

In the potential outcomes framework (Rubin, ), we denote $y_{i}(T_{i})$ as the potential outcome for unit $i$ under treatment $T_{i}$. The average treatment effect (ATE), controlling for pre-treatment variables $X$, is defined as:

$$ $\tau=\mathbb{E}[y_{i}(T_{i}=1)\mid\mathbf{x}_{i}]-\mathbb{E}[y_{i}(T_{i}=0) \mid\mathbf{x}_{i}],$ $$

where $T_{i}=\mathbf{1}\left\{\arg\max_{j}\theta_{ij}=k\right\}$.

A confounder is a variable that influences both the treatment and the outcome. In our context, $\mathbf{x}_{i}$ are covariates that affect the outcome $y_{i}$ (e.g., choosing which channel to run the ad on causally affects voting outcomes), and might be baked into the topic proportions $\theta_{i}$ in a topic model (e.g. when topics include channel information). If we do not adjust for $\mathbf{x}_{i}$ when learning $\theta_{i}$, our estimate of the treatment effect might be biased.

Denote the true topic proportions as $\theta_{i}$. When $\mathbf{x}_{i}$ affects topic assignment, the learned topic proportions $\hat{\theta}_{i}$
will be given by:
$\hat{\theta}_{i}=f(\theta_{i},\mathbf{x}_{i})$.
Outcome $y_{i}$ is influenced by both the topic $T_{i}$ and the confounders $\mathbf{x}_{i}$: $y_{i}=g(T_{i})+h(\mathbf{x}_{i})+\eta_{i}$,
where $g(\cdot)$ is the effect of the chosen topic, $h(\cdot)$ is the effect of the covariates, and $\epsilon_{i}$ is the error term.

Substituting this into the causal effect estimation, we get:

$$ $\hat{\tau}=\mathbb{E}[y_{i}\mid\mathbf{1}\left\{\arg\max_{j}f(\theta_{ij}, \mathbf{x}_{i})=k\right\},\mathbf{x}_{i}]-\mathbb{E}[y_{i}\mid\mathbf{1}\left \{\arg\max_{j}f(\theta_{ij},\mathbf{x}_{i})\neq k\right\},\mathbf{x}_{i}].$ $$

Comparatively, the true causal effect $\tau$ is:

$$ $\tau=\mathbb{E}[y_{i}\mid\mathbf{1}\left\{\arg\max_{j}\theta_{ij}=k\right\}, \mathbf{x}_{i}]-\mathbb{E}[y_{i}\mid\mathbf{1}\left\{\arg\max_{j}\theta_{ij} \neq k\right\},\mathbf{x}_{i}].$ $$

In any case where $\hat{\theta_{i}}$ is not conditionally independent of $\mathbf{x}_{i}$ (as in the VTM), we will get that $\hat{\tau}\neq\tau$.
By modeling $\hat{\theta}_{i}^{MTM}$ as the sum of $\beta_{i}$ and $\gamma_{k,x_{i}}$, the MTM controls for variation in $x_{i}$ and ensures that $\theta_{i}$ is conditionally independent of $x_{i}$.
We now turn to empirically test the efficacy of using topic proportions from MTM and the baseline models for causal estimation on semi-synthetic data.

### 6.2 Estimating causal effects of topics

**Table 5: The top terms for the topic distributions related to energy for the MTM, VTM, and LDA models, which were trained on the ideological dataset. The VTM identifies two distinct topics associated with energy-related discourse, each reflecting terminology predominantly used by either Democrat or Republican viewpoints. LDA identifies a topic related to energy, but it also reflects Republican viewpoints. For the MTM, variations in word association across political ideologies are captured through the $\gamma$ parameter, and it successfully learns a single topic for energy.**
| Model | Source | Top Words |
| --- | --- | --- |
| MTM | $\beta_{k}$: Global | energy, oil, choice, world, gas, prices, power, broken, coal, faith |
| $\gamma_{k}$: Republican | kill, coal, ballot, keystone, faith, destroy, domestic, face, epa, broken |  |
| $\gamma_{k}$: Democrat | oil, gouging, clean, price, climate, renewable, alternative, wind, progress, nextgen |  |
| VTM | $\beta_{k}$ (Topic 15) | tax, money, dollars, values, energy, breaks, sales, corporations, spend, increase, gas, reform |
| $\beta_{k}$ (Topic 21) | america, fight, oil, gas, world, fought, billions, foreign, military, states, coal, freedom |  |
| LDA | $\beta_{k}$ | oil, energy, gas, america, white, companies, foreign, drilling, progress, independence |

**Table 6: The top terms for the topic distributions related to senior social policies discovered by the MTM model on the ideological dataset.**
| Source | Top Words |
| --- | --- |
| $\beta_{k}$: Global | health, security, medicare, social, seniors, insurance, costs, drug, healthcare, companies |
| $\gamma_{k}$: Republican | takeover, bureaucrats, doctors, health, billion, choices, plans, canceled, skyrocketing, log |
| $\gamma_{k}$: Democrat | companies, privatize, conditions, protections, insurance, health, social, voted, aarp, age |

Based on the ideological dataset, we design two semi-synthetic experiments where we sample an outcome variable $Y$ from a Bernoulli distribution with parameter $p=0.5$.
First, we train the MTM, LDA, VTM, ProdLDA, and BERTopic on the ideological dataset with $k=30$ and extract the topic proportions.
We then model $Y$ as a function of a binary predictor $T$, where $T=1$ if the topic proportion for either the ‘energy’ or ‘senior social policies’ topic (as shown in Table 5 and Table 6) is the highest among all topic proportions in a given document, and $T=0$ otherwise. To any ad containing two keywords from the energy list [energy, oil, gas, clean] or two from the senior social policies list [health, social, security, insurance, seniors, healthcare, pension, retirement], we add $0.2$ to the outcome variable $Y$. We sample $700$ ads for each list and additional $700$, resulting in $2,100$ samples. We run separate ordinary least squares (OLS) regressions for each experiment.

We select the topic proportion corresponding to the $\beta_{k}$ that has the most overlapping words with the energy and senior social policies topics.
Since VTM learns two separate topics with equal overlap with the energy keyword list, we fit a model where $T=1$ if the combined topic proportions of the two energy topics (Topics 15 and 21) are the highest among all topics for a given document.
To estimate the causal effect of the topics, we use the following OLS regression: $Y=\delta_{0}+\delta_{1}T+\delta_{2}X+\epsilon$
where $\delta_{1}$ represents the marginal effect of the energy topic on $Y$ in one experiment, and the senior social policies topic in the other. The regression results from the experiments using the MTM, VTM, ProdLDA, LDA and BERTopic models are summarized in Table 7.
We exclude SCHOLAR from our experiments because its modeling approach allows topic distributions to be influenced by environment-specific deviations, which contradicts our goal of obtaining global topic representations. However, we include ProdLDA, which is equivalent to SCHOLAR without environment-specific information.
Using the representation from the MTM, we are able to capture the true effect of $0.2$ more accurately than any other model.
Models such as LDA, which have higher coherence scores than MTM, perform worse when estimating causal effects. This is because assigning high probability to environment-specific terms can improve coherence metrics, but high coherence does not guarantee unbiased causal estimates when data comes from multiple environments. Table 5 shows how VTM and LDA can assign high probability to terms reflecting right-leaning ideology, such as ‘military’ and ‘freedom’, within the context of energy, whereas MTM effectively separates global topics from environment-specific effects.
By separating global topics from environment-specific deviations, MTM controls for the confounding effects of environments, leading to more accurate causal estimates in the presence of data from different environments. Top words from all models are shown in Section D.3.

**Table 7: The coefficient $\delta_{1}$ from the OLS regressions using various models for the ‘energy’ and ‘senior social policies’ topics. With MTM, we are able to learn substantial effects for both topics, while other models provide mixed results. Baseline models have the propensity to misrepresent the underlying topics when trained on data from multiple environments while MTMs are able to learn the environment-specific information in the $\gamma$ parameter and capture the global information in $\beta$. Note: ${}^{***}p<0.001$, ${}^{**}p<0.01$, ${}^{*}p<0.05$.**
| Model | Energy | Senior Social Policies |  |  |
| --- | --- | --- | --- | --- |
|  | $\delta_{1}$ Coefficient | Std. Error | $\delta_{1}$ Coefficient | Std. Error |
| MTM | 0.200^∗∗∗ | 0.028 | 0.203^∗∗∗ | 0.027 |
| VTM | 0.066 | 0.041 | 0.000 | 0.000 |
| LDA | -0.263 | 0.140 | 0.149^∗∗∗ | 0.037 |
| ProdLDA | 0.150^∗∗∗ | 0.029 | 0.085^∗ | 0.041 |
| BERTopic | 0.341 | 0.410 | 0.116^∗∗∗ | 0.032 |

## 7 Discussion and Limitations

We addressed the problem of modeling text from multiple environments. To that end, we developed the multi-environment topic model (MTM), an unsupervised probabilistic model that learns a global topic distribution and adjusts for environment-specific variation.
The MTM has stable perplexity across different environments. It captures meaningful information in the environment-specific latent variable, performs better in and out of distribution and allows discovery of accurate causal effects.

The MTM has clear limitations, which opens up several avenues for future work. First, as MTMs rely on a bag-of-words representation, integrating them with more modern neural text representation models can potentially improve their predictive performance. Second, while we demonstrate that MTMs allow uncovering true causal effects in multi-environment data, we only evaluate this on semi-synthetic data. Exploring this question rigorously is out of the scope of this paper, but is an important problem to address in future work.
Finally, another potential avenue for further exploration not addressed in this paper is the connection between invariant learning and probabilistic models.

## Appendix

## Appendix A Algorithm

Figure: Algorithm 1 Multi-environment topic model (MTM)

## Appendix B The Horseshoe prior

Another way to enforce sparsity on the multi-environment topic model, is with a horseshoe prior for $\gamma$, which is defined as:

$$ $\gamma_{e,k,v}\mid\lambda_{ek},\tau\sim\mathcal{N}(0,\lambda_{e,k}^{2}\tau^{2}).$ $$

Here, $\lambda_{e,k}$ represents the local shrinkage parameter specific to each environment $e$ and topic $k$, while $\tau$ is the global shrinkage parameter that applies to all $\gamma$ variables. The horseshoe prior for $\lambda_{e,k}$ has the following characteristic form:

$$ $\displaystyle\lambda_{e,k}$ $\displaystyle\sim\mathcal{C}^{+}(0,1)$ $\displaystyle\tau$ $\displaystyle\sim\mathcal{C}^{+}(0,1)$ $$

where $C^{+}(0,1)$ denotes the standard half-Cauchy distribution, which has a probability density function that is flat around zero and has heavy tails.
As such, the prior encourages the majority of these environment-specific deviations to exhibit strong shrinkage, driving them towards zero, while allowing some to possess significant non-zero values, thereby highlighting truly influential environment-specific effects and allowing $\beta$ to maintain its ability to capture topics across documents. Thus the hMTM disentangles global from environment-specific influences by capturing the global topics in $\beta$ and environment-specific deviations in $\gamma$.

In Table 8, words under the topic, $\beta_{k}$, related to the energy such as ‘oil’ and ‘water’ receive high density across all environments in a corpus which consists of political articles, tweets and senate speeches, whereas words such as ‘projects’ and ‘infrastructure’ receive high density in the $\gamma_{k}$ representing the senate speech-specific effects, and acronyms like ‘EPA’ receive high density in the twitter specific effects. Table 9 displays the top terms the hMTM learns in a topic related to healthcare when trained on the ideological dataset.

**Table 8: The table displays the top words learned by hMTM when trained on the style dataset. The words in global topics appear in all environments when discussing a given topic, while the words that receive the top $\gamma_{k}$ values predominately appear in one environment. We observe distinctive word choices in tweets, articles, and senate speeches, reflecting different communication styles.**
| Source | Top Words |
| --- | --- |
| $\beta_{k}$: Global | energy, oil, water, jobs, air |
| card, credit, banks, financial, bank |  |
| $\gamma_{k}$: News Articles | canada, disaster, wind, property, construction |
| card, cards, fee, fraud, investment |  |
| $\gamma_{k}$: Senate Speeches | national, infrastructure, country, projects, climate |
| rules, consumers, industry, rates, regulatory |  |
| $\gamma_{k}$: Tweets | epa, climate, roll, environment, coal |
| competition, settlement, consumers, exchange, regulate |  |

**Table 9: When trained on the ideology dataset, hMTM learns interpretable environment-specific terms while simultaneously uncovering meaningful global topics.**
| Source | Top Words |
| --- | --- |
| $\beta_{k}$: Global | health, budget, debt, cost, costs |
| $\gamma_{k}$: Republican | takeover, debt, health, trillion, bureaucrats |
| $\gamma_{k}$: Democrat | health, affordable, healthcare, universal, medicaid |

## Appendix C Experimental Details

### C.1 Datasets

**Table 10: A summary of the datasets we construct for testing topic models across multiple environments.**
| Dataset | Style | Ideology | Political advertisements |
| --- | --- | --- | --- |
| Focus of text | US Immigration | Politics | Politics |
| Environments | {Tweets from US Senators, US Senate speeches, news articles} | {Republican, Democrat} politicians | Channels from {Republican, Democrat} voting regions |
| Training set size | $4,052$ per environment | $12,941$ per environment | $12,446$ per environment |

### C.2 Style Dataset

The style dataset consists of $12,156$ samples, with an even amount of samples from each environment. We constructed a vocabulary of unigrams that occurred in at least $0.6\%$ and in no more than $50\%$ of the documents. We use the same tokenization scheme for all baselines we compare to. We removed cities, states, and the names of politicians in addition to stopwords. For hMTM, we set $\lambda$ and $\tau$, parameters used in the horseshoe prior, to be $0.4$. For MTM, we set the hyperparameters of the gamma distribution, $a$ and $b$, to be $3.7$ and $0.34$ respectively. These values were determined by training our model for $50$ epochs, taking $2$ gradient steps for updating $a$ and $b$ in the empirical Bayes method for every $1$ step for the rest of the model. This approach helps guarantee that hyperparameter updates are not overshadowed by the updates of the rest of the parameters in the model. We set the number of topics, $k$, to be 20 for all experiments in this paper.

OOD experiments:

When training on speeches and articles and testing on tweets the training dataset has 8104 samples. We constructed a vocabulary of unigrams that occurred in at least $0.8\%$ and in no more than $50\%$ of the documents. For MTM, we set the hyperparameters of the gamma distribution, $a$ and $b$, to be $2.92$ and $0.25$ respectively.
These values were determined by training our model for $50$ epochs, taking $2$ gradient steps for updating $a$ and $b$ in the empirical Bayes method for every $1$ step for the rest of the model.

When training on ads and articles and testing on tweets the training dataset has 8104 samples. We constructed a vocabulary of unigrams that occurred in at least $0.2\%$ and in no more than $50\%$ of the documents. For MTM, we set the hyperparameters of the gamma distribution, $a$ and $b$, to be $2.87$ and $0.25$ respectively.
These values were determined by training our model for $50$ epochs, taking $2$ gradient steps for updating $a$ and $b$ in the empirical Bayes method for every $1$ step for the rest of the model.

### C.3 Ideological Dataset

We construct a vocabulary of unigrams that occurred in at least $0.6\%$ and in no more than $40\%$ of the documents. We remov cities, states, and the names of politicians in addition to stopwords. For hMTM, we set $\lambda$ and $\tau$, parameters used in the horseshoe prior, to be $0.5$. For MTM, we set the hyperparameters of the gamma distribution, $a$ and $b$, to be $4.0$ and $0.11$ respectively. These values were determined by training our model for $15$ epochs, taking $2$ gradient steps for updating $a$ and $b$ in the empirical bayes method for every $1$ step for the rest of the model.

### C.4 Political Ads Dataset

The style dataset consists of $24,892$ samples, with an even amount of samples from each environment. We construct a vocabulary of unigrams that occurrs in at least $0.6\%$ and in no more than $40\%$ of the documents. We remove cities, states, and the names of politicians in addition to stopwords. For hMTM, we set $\lambda$ and $\tau$, parameters used in the horseshoe prior, to be $0.4$. For MTM, we set the hyperparameters of the gamma distribution, $a$ and $b$, to be $3.8$ and $0.13$ respectively. These values were determined by training our model for $15$ epochs, taking $2$ gradient steps for updating $a$ and $b$ in the empirical Bayes method for every $1$ step for the rest of the model.

### C.5 Hyperparameters

For auto-encoding VB inference, we used an encoder with two hidden layers of size 50, ReLU activation, and batch normalization after each layer. For stochastic optimization with Adam, we use automatic differentiation in PyTorch. We used a learning rate of 0.01 based on implementation from Sridhar et al. []. These methods were trained on a T4 GPU.

## Appendix D Additional Experiments and Results

### D.1 In-distribution performance

Channels dataset.
Table 11 presents a sample advertisement from a Democrat and Republican-leaning region respectively.

**Table 11: An example of advertisements from our dataset. KSWB is a San Diego based news channel, and WKRG is a station licensed to Mobile, Alabama.**
| Source | Text |
| --- | --- |
| Alabama (WKRG) | What does Governor Bob Riley call over 70,000 new jobs? A great start. His conservative leadership’s given us the lowest unemployment in Alabama history, turning a record deficit into a record surplus. Now Governor Riley has delivered the most significant tax cuts in our history. The people get up every morning and work, they are the ones that allowed us to have the surplus. The only thing I’m saying, they should have some of it back. Governor Bob Riley, honest, conservative leadership. |
| California (KSWB) | State budget cuts are crippling my classroom. So I can’t believe the Sacramento politicians cut a backroom deal that will give our state’s wealthiest corporations a new billion dollar tax giveaway. A new handout that can only mean larger class sizes and even more teacher layoffs. But passing Prop 24 can change all that. Prop 24 repeals the unfair corporate giveaway and puts our priorities first. Vote yes on Prop 24 because it’s time to give our schools a break, not the big corporations. their corporate giveaway and puts their priorities first. Vote yes on Prop 24 because it’s time to give our schools a break, not the big corporations. |

**Table 12: Perplexity of the hMTM when trained on a dataset of political advertisements from channels in different regions of the U.S. $\gamma$ represents Republican leaning effects.**
| Model | Republican | Democrat |
| --- | --- | --- |
| hMTM + $\gamma$ | 545 | $664$ |
| hMTM | $622$ | 651 |

Style dataset.
Table 13 represents the perplexity of gensim LDA, vanilla topic model, ProdLDA, nMTM, and MTM. It also includes the performance when using environment-specific information, $\gamma$. Here $\gamma$ represents the article-specific effects on our topic-word distribution $\beta$. Notably, when using the article-specific effects for calculating perplexity on a test set consisting of only articles, the perplexity improves.
Indicating that the article-specific effects captured in $\gamma$ uncover information relevant to articles.
However, when we use article-specific effects to calculate the perplexity on speeches, the perplexity declines considerably, whereas when we use only $\beta$, our perplexity remains stable across test sets, indicating that it captures a robust distribution of topics.
The non-sparse variant of the MTM, nMTM, performs worse than the MTM and also the VTM baseline, indicating the importance of placing a sparse prior on $\gamma$. We visualize the top terms that $\gamma_{k}$ places high density on in Table 14.

**Table 13: Model perplexities when training on all three sources and testing on unseen data from each environment. $\gamma$ corresponds to article-specific effects. VTM, ProdLDA, and LDA are less stable than the MTM.**
| Model | Articles | Speeches | Tweets |
| --- | --- | --- | --- |
| LDA | $9344$ | $3007$ | $3.936\times 10^{12}$ |
| VTM | $1345$ | $1461$ | $1584$ |
| ProdLDA | $2757$ | $2427$ | $2000$ |
| nMTM | $1586$ | $1754$ | $1716$ |
| hMTM | $1215$ | $1306$ | $1309$ |
| hMTM + $\gamma$ | $1051$ | $1333$ | $1218$ |
| MTM | ${1181}$ | 1298 | ${1112}$ |
| MTM + $\gamma$ | 1048 | $1426$ | 1017 |

Table 14 reflects how MTM learns environment specific effects, and global topics when trained on the style dataset. In the topic related to immigration, $\beta$ captures words that are appear across environments like ‘country’ and ‘law’ whereas words like ‘secretary’ and ‘homeland’ are predominant in senate speeches and ‘naturalization’ is predominant in articles.

**Table 14: Top words for a particular topic distribution learned by MTM when trained on the style dataset. The words in global topics appear across environments, while the words that receive the top $\gamma$ values predominantly appear in one environment. We observe distinctive word choices in tweets, articles, and senate speeches, reflecting different communication styles.**
| Source | Top Words |
| --- | --- |
| $\beta_{k}$: Global Topics | country, law, status, policy, illegal, immigrants, immigration, border, citizenship |
| $\gamma_{k}$: News Articles | immigration, primary, illegal, immigrants, legal, naturalization, states, driver, citizenship |
| $\gamma_{k}$: Senate Speeches | immigration, border, security, gang, secretary, everify, homeland, colleagues, america |
| $\gamma_{k}$: Tweets | country, discuss, policy, immigration, reform, illegal, applications, check, plan |

Ideological dataset.
Table 15 represents the top terms the MTM learns on ideological dataset.
Table 16 reflects the perplexity of the hMTM across the different test sets.

**Table 15: When trained on the ideological dataset MTM learns meaningful terms for the Republican and Democrat environments, while simultaneously uncovering meaningful global topics.**
| Source | Top Words |
| --- | --- |
| $\beta_{k}$: Global | health, seniors, insurance, medicare, plan, costs, drug, affordable, healthcare, fix |
| $\gamma_{k}$: Republican | obamacare, health, takeover, bureaucrats, replace, medicare, supports, repeal, lawsuits, choices |
| $\gamma_{k}$: Democrat | health, companies, protections, conditions, deny, insurance, prices, voted, drug, gut |

**Table 16: Perplexity performance of hMTM when trained on a dataset of political advertisements from Republican and Democrat politicians. hMTM with $\gamma$ represents a combination of the learned topic distribution $\beta$, where $\gamma$ indicates the Republican deviations on each word distribution of $\beta$.**
| Model | Republican | Democrat | Neutral |
| --- | --- | --- | --- |
| hMTM | $547$ | 541 | $551$ |
| hMTM + $\gamma$ | 516 | $569$ | 550 |

### D.2 Out-of-distribution performance

We further investigate how the MTM performs when tested on data that was unseen during training using our style dataset.
We train on political news articles and senate speeches and then test on political advertisements. These political advertisements come from our ideological dataset.

Table 18 represents the perplexity of the VTM and MTM when trained on articles and speeches and tested on advertisements.

**Table 17: hMTM also has lower perplexity than baseline models when tested on out-of-distribution data. Here we trained on congressional senate speeches and news articles and tested on tweets from U.S. senators.**
| Model | Articles (Perplexity) | Speeches (Perplexity) | Tweets (Perplexity) |
| --- | --- | --- | --- |
| hMTM | $1,481$ | $1,451$ | $1,625$ |

**Table 18: MTM has lower perplexity than baseline models when tested on out-of-distribution data. Here we trained on congressional senate speeches and news articles and tested on political advertisements.**
| Model | Advertisements |
| --- | --- |
| VTM | $1,771$ |
| ProdLDA | $8,912$ |
| nMTM | $2,131$ |
| MTM | $1,603$ |
| hMTM | 1,503 |

### D.3 Estimating causal effects of topics

**Table 19: The top terms for the topic distributions related to senior social policies for the MTM, VTM, ProdLDA, Gensim LDA, and BERTopic models.**
| Model | Source | Top Words |
| --- | --- | --- |
| MTM | $\beta_{k}$: Global | health, security, medicare, social, seniors, insurance, costs, drug, healthcare, companies |
| $\gamma_{k}$: Republican | takeover, bureaucrats, doctors, health, billion, choices, plans, canceled, skyrocketing, log |  |
| $\gamma_{k}$: Democrat | companies, privatize, conditions, protections, insurance, health, social, voted, aarp, age |  |
| ProdLDA | $\beta_{k}$ (Topic 21) | security, medicare, social, seniors, protect, benefits, age, privatize, retirement, earned |
| VTM | $\beta_{k}$ (Topic 0) | health, medicare, seniors, insurance, costs, affordable, coverage, prescription, conditions, lower, drugs, cost, premiums, charge, deny |
| Gensim LDA | $\beta_{k}$ (Topic 8) | security, social, medicare, seniors, benefits, protect, cut, retirement, age, plan |
| BERTopic | $\beta_{k}$ (Topic 2) | health, social, medicare, insurance, security, planned, parenthood, seniors, drug, cancer |

**Table 20: The top terms for the topic distributions related to energy for the ProdLDA, LDA, and BERTopic models, which were trained on the ideological dataset.**
| Model | Source | Top Words |
| --- | --- | --- |
| ProdLDA | $\beta_{k}$ (Topic 1) | energy, oil, clean, prices, gas, foreign, alternative, renewable, economy, drilling |
| LDA | $\beta_{k}$ (Topic 10) | oil, energy, gas, america, white, companies, foreign, drilling, progress, independence |
| BERTopic | $\beta_{k}$ (Topic 19) | oil, money, case, tied, fraud, illegal, outsider, ethics, interests, denounced |

## Appendix E hMTM vs MTM

Model criticism aims to identify the limitations of a model in a specific context and suggest areas for improvement [Blei, , Gelman and Shalizi, ]. Although hMTM and MTM exhibit strong performance compared to other topic model variants, it is crucial to verify the expected behavior of the newly introduced $\gamma$ parameter.

According to Occam’s Razor principle, models with unnecessary complexity should not be preferred over simpler ones [MacKay, ]. As indicated in Table 21, hMTM is less sparse and exhibits greater uncertainty regarding its parameter values compared to MTM. Employing the ARD prior leads to a $\gamma$ parameter that is not only more sparse but also more effective in capturing environment-specific terms. This is evident from MTM’s superior performance on both in-distribution and out-of-distribution data. Besides having considerably lower perplexity, nMTM is also less sparse than both models.

We want to ensure that a given word $w$ that is highly probable in a certain environment $e_{i}$ and a specific topic $k$ occurs more frequently in documents discussing topic $k$ in environment $e_{i}$ than in documents discussing the same topic in a different environment $e_{j}$.
We introduce a metric: count opposite. It represents the number of words (from the top 10 $\gamma$ words for each environment and each topic) that have a higher frequency in the test set environment opposite to the one they are associated with.
For instance, if $\gamma$, in the context of a Republican-leaning environment, assigns a high probability to the word ’wasteful’ occurring in discussions about taxation, this word should appear more frequently in a subset of Republican-leaning advertisements about taxation than in a subset of Democrat-leaning advertisements on the same topic.
Among the words receiving high $\gamma$ values for a given environment and topic, these words are more likely to occur in the dataset corresponding to the environment represented by $\gamma$ in MTM than in hMTM for the same dataset. We find the median Count Opposite of the top 10 words for each topic and $\gamma$ environment is 1.0 for MTM and 2.0 for hMTM.
Motivating the use of the ARD prior.

**Table 21: Comparing the sparsity of different variants of MTMs we find the MTM with an ARD prior to be the most sparse. Sparsity is defined as any value less than 0.01.**
| Model | Group | Perp. | Sparsity | $\mu_{\gamma}$ | $\sigma_{\gamma}$ |
| --- | --- | --- | --- | --- | --- |
| nMTM | Republican | 949 | 3.6% | $7.1\times 10^{-3}$ | 0.4 |
| Democrat | 936 | 3.8% | $6.7\times 10^{-3}$ | 0.4 |  |
| hMTM | Republican | 662 | 41.64% | $7.13\times 10^{-4}$ | 0.21 |
| Democrat | 651 | 42.70% | $-2.92\times 10^{-3}$ | 0.24 |  |
| MTM | Republican | 598 | 79.95% | $5.45\times 10^{-5}$ | 0.03 |
| Democrat | 604 | 79.89% | $1.37\times 10^{-4}$ | 0.03 |  |

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 3
presentation: 2
questions: * Line 158: should $z$ be $z_{i,j}$?
* Lines 157 and 158: what does $\pi()$ mean?
* Eq (1): Should $\sigma_c$ be $\alpha_c$?
soundness: 3
strengths: * The introduction of environment-specific topic-word distributions is interesting, which can be seen as one strength of this paper in terms of modelling. The final categorical distribution used to generate each word combines the shared per-topic word distribution, denoted as $\beta_k$, with the environment-specific per-topic word distribution represented by $\gamma_{e, z}$.

* The application of the proposed model in causal estimation adds another interesting dimension to this work. Based on the potential outcome framework, it computes the Average Treatment Effect (ATE). In this causal estimation process, the words in a document are treated as covariates that influence the outcome when the document is processed within a specific environment. The experimental results derived from the synthetic dataset show that the proposed model can capture the effect caused by adding 0.2 to the outcome variable.
summary: Topic modelling is an interesting research area that has been explored for over a decade, evolving from probabilistic models to neural topic models. This paper introduces a probabilistic generative model designed to model documents generated from various contexts, or "environments." Unlike the traditional topic model, such as Latent Dirichlet Allocation (LDA), this model incorporates environment-specific topic-word distributions. It assumes that, in addition to words, each document is associated with an environment indicator variable. Variational inference is then used to learn the model parameters. The proposed model is evaluated against several baseline topic models across three datasets, with metrics including perplexity, topic coherence, and causal estimation.
weaknesses: * Modeling different environments or contexts through environment-specific topic-by-word matrices resembles the approach of using hierarchical structures to model various types of document collections. For instance, the paper on "Differential Topic Models" employs a hierarchical Pitman-Yor Process to model and compare different document collections, while "ContraVis: Contrastive and Visual Topic Modeling for Comparing Document Collections" also enables the comparison of distinct document collections, among others. Therefore, the technical contribution of this work appears somewhat limited.
* It is not surprising to see the perplexity improvement, given that the proposed model makes use of extra supervised information, i.e., the environment indicator variable.
* There is a lack of comparison with those models that are capable of modelling different corpora, like these two models mentioned above.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 3
questions: I am open to revisiting my score if the authors address the points outlined in the weaknesses and provide clarification.
soundness: 3
strengths: MTM is a novel addition to the family of topic models, offering a generative model that introduces a global topic-environment-word distribution, $\gamma$, to enhance adaptability across multiple environments. By using an ARD prior to enforce sparsity, MTM is carefully designed to align with the paper’s goal of interpretable, environment-specific topic modeling. The paper presents two variations, MTM and nMTM, demonstrating flexibility in approach and an attention to design that supports robust generalization. Experiments effectively highlight MTM’s capabilities, particularly its utility in applications requiring causal accuracy.

Overall, the paper is well-structured and provides a clear, detailed description of the MTM methodology and its motivation. The thorough explanation of each experimental setup, combined with baseline comparisons, enhances understanding of MTM’s strengths in multi-environment contexts. Additionally, figures and tables effectively illustrate MTM’s performance, contributing to the paper’s clarity and readability.
summary: This paper introduces Multi-Environment Topic Models (MTM) as a novel addition to unsupervised topic modeling, designed to differentiate between global and environment-specific patterns in text data–a capability that traditional models lack. MTM leverages mean-field variational inference to approximate the posterior distribution and introduce a new latent variable, $\gamma$, to isolate environment-specific information. As a hierarchical model, it employs Automatic Relevance Determination (ARD) as a prior to capture environment-based variations while preserving interpretability. MTM demonstrates stable predictive performance across diverse environments in both in-domain and out-of-domain settings and shows enhanced accuracy in causal inference tasks, particularly where distinguishing the impact of environment-specific language is essential.
weaknesses: - Some minor typos: 
    - line 266 "by by"
    - line 443 "r\ $\hat{\theta_i}$ \ ${\hat\theta}_i$"

- It would be beneficial to include a more thorough analysis of sparsity enforcement and the selection of the ARD prior versus other priors. Providing ablation studies or theoretical comparisons with alternatives (e.g., the Horseshoe prior) would strengthen the rationale behind this choice and clarify its role in enhancing MTM’s performance, as suggested by the evaluation metrics.
- Expanding the experiments beyond political and media datasets could illustrate MTM’s versatility and applicability. Datasets from scientific literature or product reviews, for example, could demonstrate the model’s adaptability and provide insights into its generalization capabilities across domains.
- While MTM generally outperforms its baselines, a more detailed exploration of MTM and nMTM would be valuable. Discussing their respective strengths and limitations, along with situations where one might be preferred, could help users understand these variations better.
- Although known techniques are employed, incorporating a detailed derivation of the ELBO alongside the algorithm would be beneficial. Topic models are widely used outside of machine learning, and a clearer explanation could make the paper accessible to a broader audience.
- The presented generative process and inference approach is novel. However, the family of topic models is extensive, and alternative baselines might provide a more comprehensive comparison. For instance, MixEHR [1,2] uses CVB and could treat each specialist type as an environment, could serve as an interesting baseline for MTM, and highlight the model’s strengths.

[1] Song, Z., Toral, X. S., Xu, Y., Liu, A., Guo, L., Powell, G., ... & Li, Y. (2021, August). Supervised multi-specialist topic model with applications on large-scale electronic health record data. In Proceedings of the 12th ACM Conference on Bioinformatics, Computational Biology, and Health Informatics (pp. 1-26).

[2] Li, Y., Nair, P., Lu, X. H., Wen, Z., Wang, Y., Dehaghi, A. A. K., ... & Kellis, M. (2020). Inferring multimodal latent topics from electronic health records. Nature communications, 11(1), 2536.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: The number of environments in the data used in the experiments (just two or three) is rather small compared to the number of topics. 
If the size of a dataset is sufficiently large, and each document in the dataset belongs to only one environment, then it can be divided into each environment-wise subset, and a topic model can be applied to each subset separately.
If they do so, they cannot obtain shared global topics across the dataset. But still, they may obtain better perplexity, higher topic coherence scores, and higher causal effects. I wonder how the proposed method scales with a larger number of environments. 

The authors find that the proposed MTM performs slightly worse than some baseline models regarding NPMI and observe that this is because co-occurring words are not necessarily shared across all environments.
However, I wonder if the top words in the global topics are still supposed to be shared across all environments
because they are in the "global" topics. Does the environment-specific variation include "negative" variation to
counteract the global "top" words in some environments?

In Table 6, the most typical word "health" appears in all the Global, Republican, and Democrat.
Does this redundancy suggest that the inference is sub-optimal?

In Section 3, $E$ is not formally defined, and both $|E|$ and $e$ are used for the number of environments.

In Section 3, $\pi$   (softmax?) is used without its definition.

In Equation (1). $\sigma_c$ must be $\alpha_c$.

At the end of Page 6, Table 15 must be Table 5.
soundness: 3
strengths: - The paper is generally well-written. 
- The motivation is clear.
- Adjusting global topic distributions for environment-specific variation sounds interesting and feasible.
- In the experiments, the perplexity results on held-out data across models show the superior performance of the proposed method.
summary: This paper proposes a new multi-environment topic model (MTM) that learns a global
topic distribution and adjusts it for environment-specific variation.
The paper is generally well-written. The motivation is clear.
In the experiments, the perplexity results on held-out data across models show the superior performance of the proposed method.
However, there are some concerns with its effectiveness.
weaknesses: - The number of environments in the data used in the experiments  (just two or three) is rather small compared to the number of topics. 
- The authors evaluate the causal effects in multi-environment only with the semi-synthetic data. The semi-synthetic data is conveniently designed for the proposed method to work as expected and better than other models that are not multi-environment aware.
- The proposed MTM performs slightly worse than some baseline models regarding NPMI.

---

confidence: 5
contribution: 3
initial_rating: 5
presentation: 3
questions: - Is there a typo in Table 2? I note that the NPMI of LDA is -0.8 over Channels, but it is marked in bold (which may indicate the best performance).

- In Section 3, should v and e be revised to |V| and |E|, respectively? If so, V and E in Algorithm 1 should also be respectively revised to |V| and |E|.

- In Equation 1, should $\sigma$ be revised to $\alpha$?

- In lines 286-287, the authors mention that they test all models on three held-out datasets, but I can not find the statistics of these held-out datasets. Can you provide the testing set size in Table 10?

- Is there a typo in “The style dataset” at the first sentence of Appendix C.4? Should it be revised to “The channel dataset” when referring to Appendix D.1 or “The political advertisements dataset” when referring to Table 10? I’m confused about distinguishing the last two datasets in Table 10.

- In lines 306-309, the authors mention that they have test data from a distribution that is unseen during training, which makes them not have access to environment-specific $\gamma$s. Besides, they cannot use $\gamma$ when calculating perplexity for out-of-distribution test data. Since I cannot find the corresponding steps in Algorithm 1, can you provide the details regarding the above strategy?
soundness: 2
strengths: - This submission clearly states its differences from the existing methods that incorporate environment-specific information, including the Structural Topic Model (STM) and SCHOLAR. This makes it easier for the reader to capture the contribution of the proposed method.

- This study is well-motivated from the social science applications, with good experimental settings in Section 6.
summary: This paper proposes the Multi-environment Topic Model (MTM), an unsupervised probabilistic model that separates global and environment-specific terms for the generated topics. This submission clearly states its differences from the existing methods that incorporate environment-specific information, including the Structural Topic Model (STM) and SCHOLAR. Besides, this study is well-motivated from the social science applications.
weaknesses: - Appendices A, B, and E are not cited in the main content of this submission, which makes some of the content hard to follow.

- The number of topics is set to 20 for all experiments, which weakens the experimental evidence.

- Some parts of this submission are hard to understand, please refer to my questions.

Meta-review: This paper concerns the development of Topic Models. This paper proposes a multi-environment topic model which can discover global and environment specific topics. This paper proposes an unsupervised model, in line with LDA and shows superior performance against baselines.
Given that topic models have been developed significantly this paper looks a little preliminary, as evidenced by the reviewer feedback. The author(s) should consider developing this line.

Decision: Reject