The Vision: Institutionalizing Causality | WhyThat.ai
Architecture

Encode. Query. Answer.
The Vision

Institutionalizing causality — from expert knowledge
to computable counterfactual answers.

The theoretical foundations exist. The tools exist. What's missing is a general, human-curated causal model library with LLM-based natural-language I/O and real-time counterfactual pruning.

1 Knowledge · Structure
2 LLM · Translation
3 Engine · Computation
Experts encode causal knowledge once. Users query it forever. The causal model is the product; the LLM is just the interface — a bridge, not a brain. This is not "ask GPT" (pattern-matching) or "mine the data" (correlation). This is human knowledge, made computable.
1

How It Works

Humans encode knowledge. Machines compute answers.
FunctionWho Does It
Causal knowledgeHumans
Model storageLibrary
MathSCM engine
Language (interpretation, routing, translation)LLM
JudgmentUser

The LLM does:

Question interpretation, variable grounding, model selection, subgraph routing, answer translation.

The LLM does NOT:

Compute probabilities, invent causal structure, estimate parameters, or answer without a model.

The LLM routes. The model reasons. Which avoids: hallucinated causality, black-box counterfactuals, and unverifiable reasoning.

Pearl's Abduction–Action–Prediction Loop

Abduction (model instantiation)

System does: Infer latent variables, condition on observed data, choose model slice.

P(U | evidence)

"What hidden causes must have been true?"

Action (intervention)

replace equation:
Smoking = f(Genetics, U)
with:
Smoking := 0

"Force the world to behave differently."

Prediction (counterfactual outcome)

Y_cf = f'(X_cf, U_abduced)

"What would have happened instead?"

End-to-End Flow

User
"Would this patient have avoided hospitalization if we had prescribed statins?"
LLM → Engine
model: healthcare_v1 | do(Statins=1) | outcome: Hospitalization | evidence: {Age:67, Chol:240}
Answer
"Given the model assumptions, this patient's probability of hospitalization drops from 1.0 to -8.17 if statins had been prescribed."
2

The Pipeline

From natural-language question to counterfactual answer, in seven steps.
1
Global Causal Model
A comprehensive DAG encoding all known cause-effect relationships in the domain. This is an institutional knowledge asset — built once, maintained over time. Example: A healthcare model with 500+ variables covering diagnoses, treatments, outcomes, demographics, and risk factors.
Human expertsBuilt once
2
Query Understanding
The LLM parses a natural language question and identifies which variables are relevant: "Would this patient have avoided hospitalization if we prescribed statins earlier?"
{ "model_id": "healthcare_v1", "intervention": "do(Statins=1)", "outcome": "Hospitalization", "unit": "Patient_4521" }
LLMPer question
3
Subgraph Extraction
Prune the Global Model to the minimal graph needed: An(Y) ∪ De(X) ∪ Conf(X,Y). This makes the model fast, interpretable, and testable.
LLMAutomated
4
SCM Construction
Add U variables for individual-specific factors. Template rules convert the subgraph into a full Structural Causal Model.
LLMTemplate rules
5
Parameter Estimation
Fit conditional probability tables from the appropriate dataset. Structure stays fixed; only parameters update. Can use historical, recent, or segment-specific data.
Inference EngineData-driven
6
Counterfactual Inference
Abduction: Given evidence about a specific individual, infer their U values — "who this person is." Intervention + Prediction: Hold U fixed, apply do-operator, compute counterfactual outcome.
Inference EnginePer individual
7
Answer Translation
Convert the probabilistic result back into natural language with uncertainty, assumptions, and model ID.
LLMNatural language
3

Example Walkthrough

From library model to patient-specific "what if" answer, with exact prompts and screenshots.
The Question

"Would this patient have avoided hospitalization if we had prescribed statins?"

1
Start with the Library Model
"Open the healthcare causal model from the library."
The causal model is a comprehensive DAG encoding all known cause-effect relationships in the healthcare domain.
Healthcare Causal Model — 24 nodes covering demographics, risk factors, treatments, and outcomes
Healthcare Causal Model
2
Extract the Minimal Causal Subgraph
"Extract the minimal causal subgraph from Statins to Hospitalization."
Prune to only the nodes needed: ancestors of the outcome, descendants of the intervention, and confounders between them.
Minimal subgraph: 8 nodes
Extracted Subgraph
3
Add U Variables
"Add one U variable as a parent to each non-root endogenous node."
U variables capture individual-specific factors. Each endogenous node gets one U variable: no parents, exactly one child.
SCM with U variables — 12 nodes total
Subgraph with U Variables
U Variable→ ChildCaptures
U_TotalCholTotalCholesterolIndividual cholesterol factors
U_LDLLDLCholesterolIndividual LDL factors
U_HeartHeartDiseaseUnmeasured cardiac risk
U_HospHospitalizationIndividual hospitalization propensity
4
Set Evidence
"Set evidence: Age=67, Statins=0, TotalCholesterol=240, Hospitalization=1"
Enter the observed patient data as evidence.
Evidence entered for Patient 4521
Evidence Set
5
Perform Abduction
"Run inference to abduce U values."
The inference engine performs joint inference to compute the posterior means of all U variables given the observed data.
⚠️ Critical: Use Joint Inference
The system finds U values that simultaneously maximize the likelihood of ALL evidence.
Abduction results — U values inferred via joint inference
Abduction Results
U VariableAbducted ValueInterpretation
U_TotalChol40Elevated individual cholesterol factor
U_LDL24Above-average LDL propensity
U_Heart10Higher-than-expected cardiac risk
U_Hosp4Moderate hospitalization propensity

Identity is now fixed. These U values won't change when we intervene.

6
Apply Intervention & Compute Counterfactual
"Fix the abducted U values. Apply intervention do(Statins=1). Query Hospitalization."
With U values fixed: change Statins from 0 to 1, clear evidence on Hospitalization, keep Age=67, run inference.
Counterfactual result: Hospitalization = -8.17
Counterfactual Result
do(Statins=1) ↓ TotalCholesterol: 240 → 220 (Δ = -20) LDLCholesterol: 154 → 139 (Δ = -15) ↓ HeartDisease: 12.4 → 2.85 ↓ Hospitalization: 1.0 → -8.17

Counterfactual Result

Actual (Statins=0)
1.0
Hospitalized
Counterfactual (Statins=1)
-8.17
Not hospitalized
Conclusion: This patient would almost certainly have avoided hospitalization if statins had been prescribed.
4

The Model Library

A GitHub for Causal Models — version-controlled, collaboratively maintained, queryable on demand.
Nodes — all variables relevant to the domain. Edges — directed arrows indicating causal relationships. Metadata — variable types, valid states, descriptions. Groupings — logical clusters. Confidence markers — which relationships are well-established vs. hypothesized.
Structure, not parameters
The Global Model encodes which variables cause which — the arrows. It does not need fitted parameters. Parameters are estimated from data when an SCM is generated for a specific question.

Building Causal Models

This is the human-intensive part — and the most valuable. The causal structure becomes a reusable institutional asset.

SourceWhat It Contributes
Domain expertsCore causal structure, edge directions, known mechanisms
Literature reviewEstablished relationships, effect directions, confounders
Data explorationCandidate relationships to validate with experts
Causal discovery algorithmsSuggested structures to review (not to trust blindly)
Start small, grow iteratively
The library need not contain 500 variables on day one. Start with the 20–30 variables for the most important use case. Expand as new questions arise.

Model Composition

A query spanning two models requires bridging variables:

Query: "If we changed hiring policy, would patient outcomes improve?" HR Model: Hiring Policy → Staff Levels → Staff Fatigue ↓ interface Clinical Model: Staff Fatigue → Error Rate → Patient Outcomes

If bridge exists → compose into single subgraph. If no bridge → reject query, explain which connection is missing.

Watch for cross-model confounders
Modularity risks missing confounders that span model boundaries. If "Socioeconomic Status" affects both models but exists in neither, the cross-model counterfactual will be confounded.

Recommendation: Build modular, but audit holistically.
5

Query-Time Processing

What happens when a question arrives — subgraph extraction, data requirements, and SCM construction.

Extracting the Counterfactual Subgraph

For counterfactuals, causal ancestry is required: identify intervention (X) and outcome (Y), include ancestors of Y, descendants of X, and confounders between them. Exclude descendants of Y.

retain nodes in: An(Y) ∪ De(X) ∪ Conf(X,Y)

Determining the Required Data

The rule: For each variable, data is required for it and all its parents — pulled from the data warehouse at query time.

If the subgraph includes...Data is needed for...
Hospitalization (parents: Cholesterol, Age)Hospitalization + Cholesterol + Age
Cholesterol (parents: Statins, Diet)Cholesterol + Statins + Diet
LungCancer (parents: Smoking, Genetics)LungCancer + Smoking + Genetics
This is why the Global Model matters
The Global Model tells the system which parents exist — the structure. The data fills in the strengths — the parameters. Without the structure, there is no way to know what data is needed.

Adding U Variables

One U variable per endogenous variable: V = f(Pa(V), U_V). U captures individual-specific factors, unmeasured causes, noise.

StepWhat happens to U
AbductionInfer U values from observed evidence — "given what was observed, what must U have been?"
InterventionKeep U fixed, modify the structural equation for X (replace with constant)
PredictionPropagate forward with the original U values — "same person, different treatment"
Two separate rules
U variables (model construction): One per endogenous variable. The critical assumption is independence of U's.

Interventions (query execution): Only on the target X. The other U's are inferred during abduction and held fixed — that's what makes it a counterfactual about this specific individual.
6

Components

The five building blocks of the architecture.
ComponentRoleExamples
Global Model StorePersistent storage for the master causal graph.bayes files, graph database, JSON-LD
LLM LayerQuery parsing, subgraph selection, SCM construction, answer generationClaude, GPT-4, fine-tuned models
Inference EngineParameter learning, abduction, counterfactual computationBayes Server, PyMC, DoWhy
Data LayerHistorical and current datasets for parameter estimationData warehouse, feature store
OrchestratorCoordinates the pipeline, manages statePython service, workflow engine

Getting Started:

Identify your first use case → Map the relevant variables → Build a 15–30 variable subgraph → Add U variables → Test with real questions → Expand the Global Model as new questions arise.

Further Reading

Foundational texts on causal inference, counterfactuals, and LLM reasoning.

Pearl, The Book of Why (2018) — Accessible introduction to causal inference for general audiences
Pearl, Causality (2nd ed, 2009) — The technical reference for SCMs, do-calculus, and counterfactuals
Pearl, Glymour & Jewell, Causal Inference in Statistics: A Primer (2016) — Concise textbook bridging statistics and causal inference
Kıcıman et al., "Causal Reasoning and Large Language Models" (2023) — Empirical evaluation of LLM causal reasoning capabilities and limitations
Bengio et al., "Towards Causal Representation Learning" (2021) — Theoretical foundations for combining deep learning with causal structure

The causal model is the product. The LLM is just the interface.