Causal Effect Estimation with Latent Textual Treatments
Authors: Omri Feldman, Amar Venugopal, Jann Spiess, Amir Feder
Organizations: School of Computer Science and Engineering, The Hebrew University of Jerusalem · Department of Economics, Stanford University · Graduate School of Business, Stanford University
Understanding the causal effects of text on downstream outcomes is a central task in many applications. Estimating such effects requires researchers to run controlled experiments that systematically vary textual features. While large language models (LLMs) hold promise for generating text, producing and evaluating controlled variation requires more careful attention. In this paper, we present an end-to-end pipeline for the generation and causal estimation of latent textual interventions. Our work first performs hypothesis generation and steering via sparse autoencoders (SAEs), followed by robust causal estimation. Our pipeline addresses both computational and statistical challenges in text-as-treatment experiments. We demonstrate that naive estimation of causal effects suffers from significant bias as text inherently conflates treatment and covariate information. We describe the estimation bias induced in this setting and propose a solution based on covariate residualization. Our empirical results show that our pipeline effectively induces variation in target features and mitigates estimation error, providing a robust foundation for causal effect estimation in text-as-treatment settings.
Figures & tables
Figure 1: An overview of our methodology. We start with a dataset of text documents, with labels classifying the semantic concept we want to intervene on. We run probes on SAE representations and identify the most persistent and semantically relevant SAE features that serve as our hypotheses. We then steer texts to generate quasi-counterfactuals that are used in downstream experiments. Finally, we present a novel residualization approach for CATE estimation in such text-as-treatment setting, alongside theoretical guarantees and empirical evidence.
Figure 2: Our residualization pipeline. We assume that natural language is generated from latent semantic concepts, which serve as inputs to the LLM. By applying SAE steering interventions, we modify the model’s generation process and produce quasi-counterfactual texts. We then measure their ex-post intensity I , and use embedding model for representing the text use as controls. Finally, using our measured intensity, we residualize the embeddings to remove the target concept C1 , which ensures that the treatment information is separated from the rest of text.
Figure 3: CATE simulation from Dataset C, using Llama-3.1-8B-Instruct, layer 23 feature 53435, and all-MiniLM-L6-v2 embeddings. Top: distribution of true (black) and estimated CATE based on raw (red) and residualized (blue) covariates. Bottom: scatter of true vs. estimated CATE values based on raw (red) and residualized (blue) covariates, with the 45-degree line in black. Residualization performed via dimension-by-dimension strategy.
Figure 4: Examples of features intensity as measures by the mean cosine similarity for Gemma-2-9b-IT. Left: a high intensity features that follow a linear trend with a relatively high slope, making it a good candidate for causal interventions. Center: a medium intensity feature with a reversed ‘L’ shape, where there is no response to steering at first, followed by a sudden spike, making their suitability for downstream experiments limited. Right: a low intensity feature with a constant slope despite increasing steering factors, making it completely ineffective for experimentation. Plots include only valid texts and steering factors with more than 75% validation rate.
Layer Position
I∗(ϕ)
J∗(ϕ)
IC(ϕ)
Gemma-2-9B-IT
Early (9)
0.44
2.59
1.16
Middle (20)
1.71
2.41
4.20
Late (31)
0.92
2.51
2.25
Llama 3.1 8B Instruct
Early (7)
0.81
2.33
1.91
Table 1: Mean Intensity ( I∗ ), Coherence ( J∗ ), and IC scores grouped by model and layer depth (layer number in parentheses), after removing invalid texts. Middle-layer features are generally preferred for causal interventions as they achieve high intensity scores while maintaining high coherence scores.
Figure 5: Distributions of the out-of-sample predictive accuracy of treatment between raw and residualized embeddings, where residualization is conducted dimension-by-dimension (solid) and by dropping the first principle component (dashed), taken over all tested LLMs, datasets, SAE features, and embedding models.
Figure 6: (a) Distributions of the performance gap in predictive accuracy between raw and residualized embeddings across PCA components. (b) IC scores and accuracy improvements in the first principal component (correlation r=0.463 ).
Figure 7: Distribution of magnitude of bias (solid) and RMSE (dashed) for raw (red) and residualized (blue) covariates, across all tested DGP functional forms, SAE features, LLMs, datasets, and embedding models. Residualization performed via dimension-by-dimension strategy.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Table 9Table 10
LLM
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
Gemma 2 9B IT
4.25±0.7
1.22±0.9
1.18±0.7
4.58±0.5
2.06±0.9
2.12±0.8
Llama 3.1 8B Instruct
3.89±1.0
1.44±1.1
1.01±0.7
4.36±0.7
2.39±1.0
1.97±0.7
Qwen 2.5 7B Instruct
4.08±1.0
1.58±1.1
1.13±0.7
4.47±0.7
2.48±1.1
2.13±0.8
Appendix
Table 2: CATE estimation performance by LLM (averages ± standard deviations).
Embedding Model
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
EmbeddingGemma-300m
4.43±0.7
1.56±1.0
1.17±0.8
4.69±0.5
2.45±0.9
2.1±0.8
all-MiniLM-L6-v2
3.99±0.9
1.20±0.9
1.08±0.7
4.46±0.7
2.14±0.9
2.09±0.7
all-mpnet-base-v2
3.80±1.0
1.47±1.2
1.07±0.6
4.26±0.7
2.33±1.1
2.03±0.7
Appendix
Table 3: CATE estimation performance by embedding model (averages ± standard deviations).
Dataset
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
Local Govt Speech
3.89±1.0
1.0±0.7
0.78±0.5
4.33±0.8
1.94±0.8
1.74±0.7
Political Ads
4.38±0.5
2.14±1.1
1.37±0.8
4.67±0.4
2.95±1.0
2.27±0.9
Us vs. Them
3.99±1.0
1.17±0.8
1.2±0.6
4.43±0.7
2.1±0.9
2.24±0.6
Appendix
Table 4: CATE estimation performance by dataset (averages ± standard deviations).
Feature Depth
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
Early
3.88±0.9
1.59±1.3
0.95±0.7
4.37±0.6
2.49±1.2
1.97±0.8
Middle
4.27±0.7
1.42±0.8
1.15±0.7
4.6±0.5
2.34±0.8
2.08±0.8
Late
4.0±1.1
1.26±1.0
1.17±0.6
4.39±0.8
2.12±1.0
2.14±0.7
Appendix
Table 5: CATE estimation performance by layer position (averages ± standard deviations).
LLM
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
Gemma 2 9B IT
2.33±1.9
0.27±0.2
0.62±0.3
2.91±1.7
1.18±0.4
1.51±0.5
Llama 3.1 8B Instruct
1.76±0.8
0.47±0.5
1.07±0.5
2.88±0.9
1.57±0.7
2.24±0.6
Qwen 2.5 7B Instruct
1.78±1.2
379.38±1278.9
0.8±0.7
2.7±1.1
1.74e5±5.0e5
1.71±0.8
Appendix
Table 6: CATE estimation performance by LLM (averages ± standard deviations).
Embedding Model
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
EmbeddingGemma-300m
2.2±1.4
219.95±1058.4
0.99±0.8
2.98±1.2
9.07e4±3.6e5
1.95±0.8
all-MiniLM-L6-v2
1.84±1.3
1.0±1.4
0.76±0.4
2.8±1.3
2.0±1.3
1.77±0.7
all-mpnet-base-v2
1.79±1.3
206.55±889.2
0.73±0.4
2.68±1.3
1.05e5±4.1e5
1.72±0.7
Appendix
Table 7: CATE estimation performance by embedding model (averages ± standard deviations).
Dataset
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
Local Govt Speech
3.14±1.1
568.13±1531.9
1.01±0.7
3.84±0.8
2.61e5±6.0e5
2.07±0.8
Political Ads
0.88±0.7
0.38±0.5
0.59±0.4
1.85±1.0
1.32±0.7
1.52±0.7
Us vs. Them
2.48±1.1
0.97±1.3
1.01±0.5
3.37±0.9
1.9±1.2
2.03±0.6
Appendix
Table 8: CATE estimation performance by dataset (averages ± standard deviations).
Feature Depth
∣ Bias ∣ ( X )
∣ Bias ∣ ( XDD )
∣ Bias ∣ ( XDrop )
RMSE ( X )
RMSE ( XDD )
RMSE ( XDrop )
Early
2.38±1.0
227.84±1007.8
1.03±0.6
3.35±0.8
1.04e5±4.0e5
2.1±0.7
Middle
4.50±0.1
0.48±0.1
0.69±0.1
4.77±0.1
1.51±0.3
1.84±0.2
Late
0.55±0.4
0.21±0.3
0.46±0.4
1.38±0.5
1.02±0.5
1.24±0.5
Appendix
Table 9: CATE estimation performance by layer position (averages ± standard deviations).
Predicting the effect of interventions with many possible variations, e.g., therapeutic content that affects mental health outcomes or an earnings call transcript that drives movement in share price, is useful across several domains. However, classical causal estimators tend to assume that all possible interventions are observed, which is infeasible when interventions vary widely, for instance, in the space of all text strings. We adapt a well-known approach of recasting causal inference as a learning problem to address such settings, assuming realizability of the learned function and no unobserved confounding. We show that causal error decomposes into moment-balancing errors of increasing order and exploit structure of the conditional outcome in the confounders to design objectives that directly improve causal estimation. We also show how to project the effect of a high-dimensional treatment onto coarser attributes, which allows a single model to answer several causal questions without additional attribute-specific training. We empirically evaluate our estimators in settings with high-dimensional continuous, discrete, and text treatments. Our experiments demonstrate generalization to held-out treatments, benefits of balancing higher-order moments when required, and projected causal estimates that are competitive with attribute-specific ones.
Nikita Dhawan, Arnav Paruthi, Andrew Kim +3
University of Toronto, Vector Institute · University of Toronto · Vanguard
Estimating causal effects of linguistic properties from observational text is difficult because the same document can contain both the treatment of interest and the non-treatment textual attributes needed for adjustment. Existing approaches often learn representations from the full text to capture latent confounding, but when treatment status is itself encoded by words in the text, these representations can directly encode treatment. This creates a confounder trap: richer representations can make treated and control documents separable, inducing overlap violations even when the underlying causal problem satisfies overlap. We study latent text treatments that are encoded through lexicons or other treatment-defining lexical information, and propose masking-based adjustment representations that remove this lexical treatment signal before representation learning. We formalize representation-induced overlap failure, prove that deletion masking preserves overlap for bag-of-words/topic-model representations, and characterize replacement masking as a natural relaxation for large language models that hides treatment-defining tokens while preserving word order and context. Across simulations, masking improves overlap diagnostics, stabilizes treatment effect estimates, and reduces bias relative to adjustment methods that learn from the unmasked text.
Marie Neubrander, Graham Tierney, Alexander Volfovsky
Department of Statistical Science Duke University Durham, NC, 27705
Because large language models (LLMs) are impressively successful in predicting text, it appears that they must have access to a 'world model' representing causal and definitional structure. However, the dominant formalisms of modern causal inference -- Judea Pearl's interventionist approach and the Neyman-Rubin potential outcomes framework -- struggle to illuminate how LLMs learn causal structure. I resolve this puzzle by arguing that LLMs employ a specific inductive approach based on a difference-making logic -- sometimes called variational induction. I demonstrate how central aspects of this logic are realized during training, where LLMs require enormous amounts of text data from a wide range of contexts to identify difference- and indifference-makers within word sequences. Furthermore, I analyze specific architectural features of LLMs -- such as token embeddings and self-attention -- to determine their roles in variational induction. The difference-making logic of LLMs fundamentally parallels the experimental method, where causal relations are derived by systematically varying individual circumstances to determine their influence on a phenomenon.