Ai4
Large language models fail at quantitative treatment estimation unless paired with specialized statistical libraries, while interventional causal methods allow researchers to isolate and diagnose the internal mechanisms driving model hallucinations.
AI-assisted summary of LLMs in Causal Inference With Amazon — original source. Check the original for full context.
Source published:
Detailed notes
## Background Published on YouTube by the channel Ai4 on August 26, 2025, this talk features Abhimanyu Mukerji, Manager of Economics & Applied Science at Amazon. According to the page description, the session explores how large language models (LLMs) and generative AI can be applied to causal inference, while also demonstrating how causal methodologies can enhance the explainability, robustness, and enterprise value of LLMs.
## TL;DR Mukerji contrasts predictive machine learning with causal inference, framing observational causal problems around the Rubin Potential Outcomes Framework and missing counterfactuals. He details how LLMs can transform unstructured text into structured features and assist in causal discovery, though he cautions that models often act as 'causal parrots' and struggle with combinatorial graph complexity or high-dimensional numerical estimation. To overcome these direct estimation limits, he advocates pairing LLMs as orchestration layers with specialized causal libraries like EconML or DoWhy. Finally, he demonstrates how viewing transformer architectures as structural causal models enables interventional techniques, mediation analysis, and parameter tracing to debug hallucinations and perform principled model pruning.
## Atmosphere & style The presentation carries the practical, grounded tone of an applied enterprise scientist speaking candidly to a technical conference audience. Mukerji establishes an approachable, pedagogical rapport from the opening show of hands, demystifying econometric rigor without resorting to hype or academic pretension. It feels pragmatic and methodologically disciplined—consistently puncturing generative AI overpromising by highlighting combinatorial bottlenecks, numerical estimation failures, and the necessity of specialized statistical tooling during both the structured slides and the thoughtful audience Q&A.
## Key takeaways - [00:00](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=0s) Causal inference differs fundamentally from predictive machine learning by identifying the direct counterfactual impact of an intervention rather than relying on correlation patterns. - [03:43](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=223s) Under the Rubin Causal Model, causal inference is fundamentally a missing data problem because counterfactual outcomes for treated units remain unobservable. - [06:45](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=405s) LLMs provide unique value in econometrics by extracting variables from unstructured textual data and automating feature engineering to limit researcher degrees of freedom. - [10:10](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=610s) Contextual narratives enable LLMs to assist causal discovery, but models risk behaving as 'causal parrots' by regurgitating pretraining priors rather than inferring true data-generating processes. - [12:58](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=778s) While fine-tuned LLMs achieve 90% accuracy on isolated pairwise causal benchmark decisions, accuracy drops sharply when tasked with inferring full, combinatorially complex causal graphs. - [15:37](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=937s) Enterprise decision-making requires causal estimation metrics (like ATE and CATE) to quantify effect magnitudes rather than relying solely on directional causal discovery. - [17:34](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1054s) Standalone LLMs collapse on quantitative estimation and high-dimensional spaces, requiring an orchestration architecture paired with specialized libraries like EconML and DoWhy. - [23:28](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1408s) Causal sensitivity and counterfactual analysis offer principled paths for transformer pruning and interpretability where correlation-based saliency methods fall short. - [27:59](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1679s) Formulating transformer architectures as Directed Acyclic Graphs allows practitioners to apply Judea Pearl's do-calculus to intervene directly on internal attention heads and activations. - [30:01](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1801s) Mediation analysis decomposes prompt effects into direct and mediated internal activation pathways, providing a structured mechanism for debugging model hallucinations. - [36:37](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=2197s) The most effective enterprise workflow uses LLMs to parse qualitative domain knowledge and structure feature spaces, while offloading numerical causal estimation to dedicated statistical engines.
## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=0s) Introduction: Prediction vs. Causal Inference
Abhimanyu Mukerji opens the session by taking a quick show of hands from the audience to gauge their familiarity with causal inference and its underlying modeling frameworks. Seeing that causal inference is completely new to the vast majority of attendees, he assures the room that this is entirely fine and outlines the two-way goal of the presentation: exploring how large language models (LLMs) and generative AI can solve key problems in causal inference, and conversely, how traditional causal methods can be applied back to transformer architectures to make LLMs more explainable, robust, and generalizable.
He emphasizes that causal inference represents a fundamentally different paradigm from prediction, which is where "99% of ML and AI has generally been applied towards" and where Gen AI is currently concentrated. While prediction models focus on estimating outcomes based on correlations, causal inference revolves around understanding the direct impact of an intervention or treatment on a population of interest—akin to A/B testing or randomized controlled trials (RCTs). In digital contexts like web pages or apps where experiments can be run directly, determining treatment effects is relatively straightforward. However, outside of controlled experiments, businesses and researchers are forced to rely on observational data where experiments are prohibitively expensive or impossible, making it extremely difficult to establish whether a change in an outcome $Y$ is truly caused by a particular input $X$.
```mermaid flowchart TD accTitle: Causal Inference vs Predictive ML subgraph Pred["Standard Predictive ML"] P1["Input Features (X)"] -->|Correlation & Pattern Matching| P2["Predicted Outcome (Y)"] end subgraph Causal["Causal Inference Framework"] C1["Intervention / Treatment (T)"] -->|Identifiable Causal Effect?| C2["Potential Outcomes (Y(1) vs Y(0))"] C3["Confounders / Observational Data"] -.->|Distorts| C1 C3 -.->|Distorts| C2 end ```
- **Observational Data Challenges**: Moving beyond A/B tests introduces non-random assignment, making it hard to separate true causal effects from spurious correlation. - **Traditional Requirements**: Classical statistics and econometrics demand structured formats like panel data (tracking the same units over multiple time periods) alongside specialized identification methods like instrumental variables (IV) or satisfying the backdoor criterion in causal DAGs. - **New Opportunities with LLMs**: Foundation models bring textual data capabilities and agentic causal workflows into econometrics.
---
[03:43](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=223s) The Rubin Potential Outcomes Framework as a Missing Data Problem
Mukerji introduces the dominant paradigm used by causal practitioners: the Rubin Causal Model (Potential Outcomes Framework). In this setup, an outcome variable $Y$ for any given unit (a customer, user, or patient) exists across two potential states depending on a binary treatment $T \in \{0, 1\}$: the outcome under treatment ($Y(1)$) and the outcome under control ($Y(0)$).
Framing causal inference through potential outcomes transforms the challenge into a fundamental problem of missing data. If an individual receives a treatment ($T=1$), such as a new medicine, marketing campaign, or updated web interface, only $Y(1)$ is observed, while their counterfactual outcome under control ($Y(0)$) remains completely unobservable. In randomized experiments, random assignment ensures that treatment and control groups remain balanced and comparable across their distribution. In observational settings, however, treated and untreated units often systematically differ. Traditional econometric techniques and machine learning approaches attempt to bridge this gap by predicting or imputing the unobserved counterfactual state so researchers can calculate the average treatment effect (ATE) or conditional treatment effects.
| Method Category | Common Techniques | Primary Role in Causal Inference | |:--- |:--- |:--- | | **Weighting & Matching** | Inverse Propensity Weighting (IPW), Propensity Score Matching | Balances observed covariates across treatment and control groups | | **Semi-Parametric ML** | Double Machine Learning (DML) | Uses predictive ML models for nuisance parameters while preserving root-$N$ inference | | **Structural Modeling** | Directed Acyclic Graphs (DAGs), Structural Equation Models (SEMs) | Encodes domain knowledge and explicit causal pathways to satisfy identification criteria |
---
[06:45](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=405s) Why Integrate LLMs into Causal Frameworks?
Mukerji addresses the natural skepticism about why LLMs belong in causal inference, noting that standard Gen AI concepts like RAG or vector search do not immediately seem applicable to structural econometrics. He breaks down four major functional categories where LLMs add unique value:
1. **Unstructured Textual Data Extraction**: Immense causal signal is locked in unstructured free text—such as experiment documentation, user reviews, logs, or corporate qualitative notes—which LLMs can extract and transform into usable structured variables. 2. **Automating Feature Engineering & Reducing Subjectivity**: Constructing features from complex panel data traditionally requires deep domain expertise. However, human specification introduces subjectivity, where researchers may tweak feature definitions to suit their own objective functions. LLMs can systematically automate feature generation, effectively "limiting the researcher degrees of freedom." 3. **Reasoning and Counterfactual Prompting**: Foundation models can be prompted to reason about experimental designs, data structures, and counterfactual questions ("what would happen if we executed intervention X?"). 4. **Model Explainability and Translation**: Once causal models are estimated, LLMs can articulate the underlying mechanisms, interpreting estimated parameters and statistical assumptions for non-technical business stakeholders.
---
[09:04](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=544s) Causal Discovery and Graph Disentanglement
Mukerji transitions to the specific problem of **causal discovery**, which involves learning the underlying causal graph and identifying the directional arrows between variables directly from data. A central challenge here is separating true causal relationships from simple correlation.
He illustrates this with a classic confounding thought experiment: if an underlying variable $A$ causes both $B$ and $C$, then $B$ and $C$ will appear strongly correlated in observational data, even though neither variable exerts any causal effect on the other ($B \not\to C$ and $C \not\to B$). While this distinction is obvious when the true data-generating process is known, deducing directional arrows purely from observational covariance is an exceptionally difficult computational and statistical problem that classical causal discovery algorithms have historically struggled to resolve without strong parametric assumptions.
```mermaid flowchart LR accTitle: Confounding Example in Causal Discovery A["Common Cause (A)"] -->|Causes| B["Observed Variable (B)"] A -->|Causes| C["Observed Variable (C)"] B -.-|Spurious Correlation Only| C ```
[10:10](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=610s) Enhancing Traditional Causal Discovery with Problem Context
Traditional causal discovery relies on a spectrum of classical statistical methods, but each carries distinct practical drawbacks. Constraint-based algorithms run statistical hypothesis tests for conditional independence between variables to rule out edges where two features are unlikely to be causally linked. Alternatively, score-based methods simulate data over candidate causal graphs to determine which topology best fits the observed data, while semi-parametric approaches enforce functional assumptions—such as linearity in conditional relationships—to make estimation computationally tractable. These classical frameworks are notoriously hard to scale and remain intensely fragile to how features are parameterized and structured.
```mermaid flowchart TD accTitle: LLM-Assisted Causal Discovery and the Causal Parrot Risk subgraph InputContext["Input & Context"] A["Metadata & Rich Descriptions<br/>(e.g., Clinical trial drug history)"] B["Tabular Observational Features"] end
subgraph Reasoning["Causal Reasoning Engine"] C["LLM Contextual Interpretation"] D{"Reasoning Mode"} E["Grounded Causal Discovery<br/>(Contextual Variable Links)"] F["'Causal Parrot'<br/>(Memorized Pretraining Priors)"] end
A --> C B --> C C --> D D -->|Utilizes Prompt Context| E D -->|Over-relies on Training Data| F ```
Large language models offer a way to break through these limitations by incorporating semantic problem context that cannot easily be reduced to standard feature matrices. In a clinical trial setting, for instance, a researcher can supply detailed narrative paragraphs describing a drug's mechanism, expected physiological behavior, and historical side-effect profiles of related compounds. While a conventional tabular pipeline struggles to assimilate that unstructured domain knowledge, an LLM can ingest the narrative alongside a causal discovery framework to reason through expected patient outcomes. The challenge closely mirrors retrieval-augmented generation (RAG): ensuring the model grounds its inferences in the supplied metadata rather than acting as a "causal parrot," regurgitating pretraining priors that may be entirely irrelevant to the specific problem setting.
- Classical constraint-based models prune causal links via conditional independence tests. - Score-based methods evaluate and score candidate directed acyclic graphs against observed data. - Semi-parametric models enforce mathematical restrictions (e.g., linear conditional interactions) to achieve computational tractability. - LLM ingestion of rich textual background enables reasoning over interactions that traditional structured features cannot represent.
---
[12:58](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=778s) Pairwise Link Benchmarks and the "Causal Parrot" Fallacy
Evaluating LLM performance on causal discovery exposes sharp contrasts between toy benchmark tasks and realistic structural modeling. When presented with narrative scenario benchmarks from recent literature, models are tasked with determining the causal orientation between pairs of variables. Because any given pair can only exhibit three potential states—no causal link, variable A causing B, or variable B causing A—the benchmark operates within a heavily constrained decision space. Base models display erratic performance across benchmarks, but task-specific fine-tuning dramatically closes the gap: base Mistral models benchmarked at approximately 75% accuracy jump to roughly 90% accuracy once fine-tuned on relational task structures.
```mermaid flowchart LR accTitle: Degradation from Pairwise Causal Discovery to Full Graph Inference A["Pairwise Identification<br/>3 discrete states: A→B, B→A, None<br/>Accuracy: ~75% - 90%"] -->|Scale to all pairs| B["Full Graph Discovery<br/>Combinatorial Edge Selection<br/>Substantial Performance Drop"] ```
However, pairwise accuracy masks fundamental scaling limitations. When models are evaluated on standardized causal datasets like COPA and e-CARE, asking the model to construct an entire causal graph rather than score isolated pairs causes accuracy to degrade significantly. The combinatorial complexity of selecting the correct subset of active edges from all possible variable pairs overwhelms the model. While extensive domain context and prompt optimization reliably elevate benchmark numbers, assembling that context requires deep human expertise. Consequently, an LLM tuned to infer graphs within one specialized domain cannot easily transfer that causal competence to an adjacent discipline.
- In simple pairwise discovery, models choose between only three states: no edge, forward direction, or reverse direction. - On standard benchmarks, fine-tuning improves Mistral's pairwise edge accuracy from 75% to 90%. - Performance drops sharply when models shift from isolated pairwise evaluations to inferring complete, end-to-end causal graphs. - High-performing causal discovery prompts require intensive, domain-specific contextual framing that limits cross-domain portability.
---
[15:37](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=937s) Moving Beyond Discovery to Causal Estimation
Identifying whether a causal link exists is only the preliminary half of the problem; real-world decision-making hinges on causal estimation—quantifying the precise magnitude of the effect. In enterprise environments, directional intuition is practically useless on its own: "Let's say that you ran a very expensive marketing campaign... I could tell you that you have generated some lift and that's not going to be very useful to you. What you really want to know is was it 5%, 15% or 50%." To make capital allocation decisions, teams must compute statistical measures such as the Average Treatment Effect (ATE) to evaluate population-wide lift, or the Conditional Average Treatment Effect (CATE) to isolate heterogeneous treatment impacts across specific user segments.
Beyond estimating treatment effects from user data, causal estimation is becoming a cornerstone of deep learning explainability. Engineers increasingly rely on causal methods to dissect network behavior: measuring how outputs vary when specific input tokens change, determining what occurs when internal layer connectivity is altered, or observing the impact of modifying loss functions and optimization routines. Before delving into deep model explainability, however, the immediate operational hurdle remains deploying LLMs to estimate grounded treatment effects from observational data.
- Directional causal discovery answers whether an effect exists; causal estimation quantifies its magnitude. - Key target metrics include the Average Treatment Effect (ATE) for population impact and Conditional Average Treatment Effect (CATE) for subgroup heterogeneity. - Causal estimation methods also serve as an interpretability framework for deep learning architectures by analyzing model behavior under structural and hyperparameter perturbations.
---
[17:34](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1054s) Structural Limitations and Tool-Augmented Estimation
Although fine-tuned LLMs augmented with structured prompts exhibit genuine causal reasoning traits, applying them directly to quantitative statistical estimation introduces severe architectural hurdles. A standalone language model cannot compute rigorous treatment statistics internally. Instead, it must serve as an orchestration layer paired with dedicated causal computing libraries—such as EconML or DoWhy:
```mermaid flowchart TD accTitle: Causal Estimation Architecture and Tool Orchestration subgraph Orchestrator["LLM Orchestration Layer"] L["Language Model Agent"] D{"Estimator Selection"} end
subgraph CausalEngines["Statistical Estimation Libraries"] CF["Causal Forests<br/>(e.g., EconML)"] CDL["Causal Deep Learning<br/>(e.g., DoWhy)"] end
subgraph HighDimScale["Dimensionality Bottleneck"] G["10,000+ Feature Spaces<br/>(Genomics & Biology)"] Fail["Unbounded Hallucination & Failure"] end
L --> D D -->|Algorithmic Structuring| CF D -->|Algorithmic Structuring| CDL G -.->|Unstructured LLM Execution| Fail ```
Selecting the correct statistical library and configuring the estimator—whether that requires parameterizing a causal forest or setting up a causal deep learning architecture—demands rigid algorithmic constraints. Without guardrails, the model defaults to testing random statistical configurations, introducing subtle hallucinations into the output.
Furthermore, LLMs collapse when confronted with massive feature spaces. While an LLM can parse intuitive causal pairs across a dozen variables, it cannot reliably map relationships across datasets with 10,000 continuous features, a dimensionality standard in biological and genomic applications. Empirical benchmarks underscore these weaknesses: on synthetic benchmarks featuring 10,000 ground-truth causal graphs, unassisted LLMs score barely above 60% accuracy, frequently performing worse than elementary natural language processing baselines unless constrained by meticulous prompt engineering and external estimation tooling.
- Direct statistical estimation requires pairing the LLM with specialized Python causal libraries such as EconML or DoWhy. - LLMs struggle to independently determine whether an empirical question requires a causal forest or a causal deep learning model without rigorous system constraints. - High-dimensional settings (such as biology and genetics datasets exceeding 10,000 features) exceed current LLM causal mapping abilities. - On benchmark evaluations across 10,000 ground-truth datasets, unassisted LLM causal estimation hovers around 60% accuracy, falling behind traditional NLP baselines.
[20:10](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1210s) Prompting, Knowledge Bases, and Tracing LLM Behavior
The underlying knowledge base and targeted fine-tuning remain crucial for detecting causal links, but strategic prompting can significantly boost model performance. This mirrors broader generative AI dynamics: effective prompt engineering often dictates whether an application succeeds. Beyond basic performance tuning, sensitivity analysis—evaluating how model outputs shift in response to varied inputs—provides deep insight into how generative systems reason.
One primary application is tracing generative AI behavior back to internal model mechanics. When an algorithm surfaces an association between two concepts—such as linking the "Eiffel Tower" directly to "Paris"—understanding which sub-components of the network generate that specific factual connection is essential. Research into the GPT family of models demonstrates that factual associations are often localizable to specific parameters and layers. Identifying these localized sub-networks allows practitioners to perform surgical, highly efficient parameter updates tailored to specific domain tasks without retraining the entire model.
A parallel challenge appears in mathematical reasoning, where large language models notoriously struggle with basic arithmetic. While scaling model size generally improves performance, simply increasing parameter counts is neither a sustainable nor a universally extensible strategy. Instead, analyzing causal sensitivity—such as tracing which internal parameters show high variance when modifying an input from "1+1" to "1+2"—reveals the specific architectural choke points that cause models to stumble.
- **Localized Parameter Tuning**: Tracing localized sub-networks in GPT models enables targeted parameter adjustments, drastically reducing computational overhead compared to broad fine-tuning. - **Arithmetic Sensitivity**: Analyzing parameter variance across subtle input perturbations (e.g., swapping single arithmetic operands) helps isolate the exact components driving reasoning errors.
---
[22:20](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1340s) The Problem of Causal Attribution in Large Language Models
Determining which specific internal components are responsible for an observed output is a classic causal attribution problem. In traditional settings with structured data and defined features, causal attribution relies on controlled experiments where every variable is held strictly constant while a single feature is manipulated to observe its direct effect on the outcome variable $Y$.
Translating this methodology to large language models presents fundamental obstacles:
```mermaid flowchart LR accTitle: Causal Attribution Challenge in LLMs subgraph Traditional ["Traditional Structured Data"] direction TB F["Controlled Features"] -->|"Strict Ceteris Paribus"| O["Direct Outcome (Y)"] end subgraph Generative ["Large Language Models"] direction TB P["Pre-trained Priors"] --> B["Correlation/Causation Conflation"] R["RAG Context"] --> B B --> Out["Generated Response"] end ```
Pre-trained weights act as a massive, opaque confounding prior that dictates downstream behavior. Disentangling the influence of these pre-trained representations from new context introduced via retrieval-augmented generation (RAG) is exceptionally challenging. When confronted with complex prompts, models routinely default to prior statistical correlations learned during pre-training rather than genuinely reasoning through the causal dependencies presented in the prompt.
---
[23:28](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1408s) Extending Causal Methods to Explainability and Architecture Optimization
Standard interpretability frameworks rely heavily on correlation-based feature importance metrics such as SHAP (Shapley Additive explanations). While helpful, these methods fall short of answering counterfactual questions: How would the model output change if a specific prompt feature were altered? Because language generation is inherently probabilistic, causal techniques are required to separate genuine prompt-driven causal effects from stochastic sampling noise.
Causal inference also provides a principled framework for architecture search and cost reduction. Rather than treating transformer architectures as black boxes, causal methods can evaluate the impact of modifying structural hyperparameters—such as pruning layers, removing attention heads, or consolidating feed-forward nodes. If causal sensitivity analysis proves that an output is insensitive to certain sub-networks, engineers can safely strip away model complexity, reducing operational latency and hosting costs without degrading generation quality.
- **Counterfactual Output Estimation**: Quantifies how an LLM's response would diverge under specific, isolated prompt edits. - **Stochastic Disentanglement**: Isolates whether output variations stem from probabilistic token sampling or genuine prompt interventions. - **Architectural Pruning**: Measures the causal necessity of individual attention heads, layers, and nodes to enable principled model compression. - **Data & Component Attribution**: Identifies whether a generated statement is directly traceable to specific pre-training corpora or particular transformer sub-modules.
---
[25:19](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1519s) Benchmark Challenges: Memorization, Redaction, and Saliency Limits
Evaluating causal reasoning in language models typically involves benchmark datasets containing structured question-and-answer pairs embedded with specific causal dependencies. Researchers then manipulate these prompts to observe performance degradation. However, evaluating LLMs through static benchmarks introduces two major complications: memorization and the limitations of heuristic perturbations.
| Benchmark Challenge | Mechanism | Core Limitation | |:--- |:--- |:--- | | **Data Contamination & Memorization** | The model absorbs benchmark challenges or identical QA pairs during pre-training. | The model outputs correct causal answers via rote recall rather than dynamic reasoning. Prompting the model with partial challenges reveals high variance across phrasing. | | **Input Redaction & Perturbation** | Evaluating behavior by masking, redacting, or perturbing specific prompt segments. | It is difficult to know *ex ante* which prompt tokens are functionally relevant versus which redacting actions destroy necessary semantic context. | | **Correlation-Based Saliency** | Inspecting attention heatmaps, gradient-based saliency scores, and feature attributions. | These metrics show which tokens activate during forward passes, but fail to demonstrate whether the model would have produced a different counterfactual outcome under intervention. |
---
[27:59](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1679s) Formulating Transformers as Causal Graphs and Interventional Systems
To overcome the shortcomings of simple prompt perturbation and correlation-based saliency, transformer inference can be formally cast as a Structural Causal Model (SCM). The prompt represents a treatment $T$, the generated text represents an outcome $Y$, and the intermediate transformer components act as internal mediating channels.
```mermaid flowchart TD accTitle: Transformer Formulated as an Interventional Causal Graph subgraph TreatmentStage ["Input Layer"] T["Prompt / Treatment (T)"] end
subgraph InternalNodes ["Transformer Architecture as Causal DAG"] E["Token Embeddings"] H1["Attention Head 1"] H2["Attention Head 2 (Intervened / Zeroed)"] FFN["Feed-Forward Sub-Layer"] end
subgraph OutcomeStage ["Output Layer"] Y["Generated Response (Y)"] end
T --> E E --> H1 E --> H2 H1 --> FFN H2 -.->|"do(Head = 0)"| FFN FFN --> Y ```
By mapping the transformer architecture directly into a Directed Acyclic Graph (DAG), each internal module—token embeddings, multi-head attention blocks, and feed-forward layers—functions as an explicit node. Rather than treating internal activations as a passive forward stream, researchers can apply Judea Pearl’s *do-calculus* to intervene at arbitrary intermediate stages.
Practitioners can hold specific token embeddings constant, freeze intermediate activations, or mathematically zero out the output vectors of individual attention heads (`do(Attention Head = 0)`). Systematically applying these targeted interventions allows researchers to trace exactly how causal information propagates through internal representations, providing a mathematically rigorous foundation for model explainability and circuit discovery.
[30:01](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1801s) Causal Discovery, Hallucination Debugging, and Graph Mediation in LLMs
Interventional methods provide a rigorous way to assess causal impacts inside a model by holding everything else constant and perturbing a single variable at a time. This technique proves invaluable for causal discovery and identifying the specific components or internal activations that drive downstream behavior. One area holding substantial potential is debugging large language model (LLM) hallucinations: when a model produces false information, analyzing activation patterns helps identify which pathways drove the flawed output, enabling practitioners to isolate and target specific failure modes. However, these techniques face serious computational bottlenecks. LLMs are massive, sophisticated networks; constructing the complete causal graph or running sufficient iterations to map internal components requires numerous runs, making repeatable automated workflows computationally expensive.
```mermaid flowchart LR accTitle: Mediation Analysis in LLMs accDescription: Direct and mediated causal pathways from input treatment through internal activations to output.
subgraph Inputs ["Input Layer"] T["Input / Treatment (T)"] end
subgraph Internal ["Internal Representations"] M["Activations / Mediators (M)"] end
subgraph Outputs ["Output Layer"] Y["Output / Response (Y)"] end
T -->|"Direct Effect"| Y T -->|"Mediated Effect"| M M --> Y ```
To break down transformer internals systematically, researchers treat the model architecture as a causal graph analyzed through mediation analysis. When an input is fed into the network, its influence propagates across multiple pathways, starting at an initial node and cascading through combinations of subsequent layers (such as pairs $1 \to 2$, $1 \to 3$, $1 \to 4$). By framing the input prompt as a treatment $T$, the final output as $Y$, and intermediate internal activations as mediator set $M$, researchers can decompose the total impact into the direct effect of $T$ on $Y$ and the indirect effect operating through $M$. Performing targeted interventions—holding specific activations fixed, tweaking $M$, or ablating pathways entirely—clarifies how internal mechanisms produce observed model behavior.
[32:12](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1932s) Summary: Synergies Between Causal Inference and Generative AI
Outside of tightly controlled, narrow experimental setups, causal inference remains an exceptionally difficult problem. The strongest synergies and most fruitful research areas lie in using LLMs to ingest unstructured textual data, convert it into structured statistical representations, and feed those representations into traditional causal inference models to solve real-world industry problems.
Using LLMs for causal discovery shares risks comparable to retrieval-augmented generation (RAG) and fine-tuning: while models demonstrate respectable causal learning capabilities, their performance depends heavily on meticulous context-setting. Concurrently, applying causal graph estimation, perturbation, and mediation analysis offers actionable paths toward understanding why models hallucinate. As generative models are integrated into critical enterprise workflows and customer touchpoints, reducing hallucinations while boosting explainability and reliability becomes paramount.
[33:35](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=2015s) Audience Q&A: Managing Complexity and Inferring Infrastructure Graphs from Terraform
In the Q&A session, an audience member follows up on the computational bottleneck of graph intervention. The speaker notes that the combinatorial search space can be pruned significantly when addressing targeted problems, such as auditing bias or ensuring strict adherence to prompt context. Because only a subset of network regions activate in response to specific prompt alterations, developers can focus interventions solely on sensitive sub-networks rather than the entire model, even if a universal graph mapping remains intractable.
Another attendee asks how causal techniques could help infer infrastructure dependency graphs directly from Terraform code (such as determining the causal dependency between a provisioned virtual machine and an attached disk), pointing out that raw LLM prompting causes frequent hallucinations. The speaker explains that LLM reasoning benchmarks rely on domains with established scientific ground truth (like ecology or biology), where the model leverages rich background literature.
For technical domains like Terraform code: - General pretraining corpora often contain noisy discussions, which degrades deterministic reasoning. - Reliable graph extraction requires supplying a highly specific, curated domain knowledge base via targeted context or RAG. - Practitioners must benchmark how sensitive the model is to pretraining noise before relying on raw outputs.
[36:37](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=2197s) Audience Q&A: Missing Counterfactuals and Text-Assisted Causal Estimation
An attendee asks about using LLMs to infer counterfactuals in episodic settings—such as medical treatments where the factual outcome under treatment $T_1$ is observed, but the counterfactual outcome without treatment is unknown. The question centers on whether an LLM can serve as a repository of world knowledge ("the internet in a box") to provide probabilistic estimates for unobserved potential outcomes.
The speaker explains that LLMs excel at qualitative, narrative-level extrapolations (e.g., describing typical disease progression over successive days from clinical histories when a drug is withheld), but fail when tasked with precise quantitative estimation:
| Dimension | LLM Performance | Recommended Methodology | |:--- |:--- |:--- | | **Qualitative / Episodic Logic** | High | Use LLM over a structured domain knowledge base to map general causal relationships and patient timeline narratives. | | **Numerical Trajectories & Quantified Effects** | Low (High Hallucination) | Avoid direct numerical estimation in prompts; LLMs struggle to quantify exact physiological metrics (e.g., exact daily temperature shifts). | | **Hybrid Workflow (Optimal Approach)** | Robust | Use the LLM to extract structural relationships from text, select the relevant feature space (temperature, drug status, physiological markers), and pass those features into a dedicated statistical causal model for estimation. |
[39:26](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=2366s) Integrating Autoregressive Priors and LLMs in a Bayesian Framework
Addressing an audience question about combining language models with autoregressive or probabilistic methods, Abhimanyu Mukerji candidly admits that he is not personally aware of practitioners using this setup in production and has not encountered a specific application for it in practice. However, he explores how the concept could function theoretically under a Bayesian lens. In such a conceptual setup, an autoregressive framework or external statistical model could establish the baseline prior distribution.
The LLM could then ingest contextual domain signals or unstructured text to inject additional information into the model. By combining the model-derived prior with the contextual evidence contributed by the language model, one could update the beliefs and calculate a posterior distribution over the parameters or target outcomes. While Mukerji remarks that "that might work" in principle as a valid Bayesian formulation, he caveats his thoughts by emphasizing that he has no firsthand empirical experience implementing or testing such an architecture.
```mermaid flowchart LR accTitle: Bayesian Updating with an LLM subgraph S1["Prior Estimation"] A["Autoregressive / External Model"] --> B["Prior Distribution"] end subgraph S2["Evidence Integration"] C["LLM Contextual Data"] end subgraph S3["Inference"] B & C --> D["Posterior Distribution"] end ```
- **Theoretical Bayesian formulation**: An autoregressive baseline generates the initial prior, while the LLM contributes supplemental qualitative or contextual conditioning data. - **Practical caveats**: Despite the theoretical viability of calculating a posterior from an LLM-augmented prior, Mukerji notes that real-world use cases remain untested in his direct experience.
## Notable quotes > [00:00](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=0s) 99% of ML and AI has generally been applied towards — Abhimanyu Mukerji
> [06:45](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=405s) limiting the researcher degrees of freedom — Abhimanyu Mukerji
> [10:10](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=610s) causal parrot — Abhimanyu Mukerji
> [15:37](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=937s) Let's say that you ran a very expensive marketing campaign... I could tell you that you have generated some lift and that's not going to be very useful to you. What you really want to know is was it 5%, 15% or 50%. — Abhimanyu Mukerji
> [20:10](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1210s) Eiffel Tower — Abhimanyu Mukerji
> [20:10](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1210s) Paris — Abhimanyu Mukerji
> [27:59](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=1679s) do(Head = 0) — Abhimanyu Mukerji
> [36:37](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=2197s) the internet in a box
> [39:26](https://www.youtube.com/watch?v=XJHtZWZo3RU&t=2366s) that might work — Abhimanyu Mukerji
## Mentioned Abhimanyu Mukerji, Amazon, Ai4, Rubin Causal Model, EconML, DoWhy, Mistral, COPA, e-CARE, GPT, SHAP, Judea Pearl, Terraform
## Video description Abhimanyu Mukerji, Manager, Economics & Applied Science, Amazon
Abstracts
LLMs and Gen AI have compelling applications to problems in causal inference, and recent improvements in benchmark models have increased the potential for synergies between these modeling paradigms. There are also opportunities to use causal methods to make LLMs more explainable and robust. This talk will provide an overview of research in this area, and discuss how these methods can be used to solve major business problems.
[Source](https://www.youtube.com/watch?v=XJHtZWZo3RU)