28 July 2026 · AI x Causal inference

Can an LLM turn a study description into reproducible analysis code?

A 30-minute reading pack about THESEUS, target trial emulation, constrained JSON, deterministic R generation and human review.

DifficultyC1
Time30 minutes
Main sourceJAMIA Open
Output90-second ADaM proposal

Why this reading

Interpret freely. Execute deterministically.

THESEUS converts natural-language target-trial-emulation descriptions into structured JSON specifications and executable Strategus R scripts.

The architecture is transferable to regulated programming: use the LLM for interpretation, constrain its output, validate each field and generate code through repeatable rules.

Reading order

Your 30-minute plan.

0-3 minPreview

Read the abstract numbers and predict which fields are hardest to extract.

3-15 minMain article

Read the Abstract, Conceptual Framework, Prototype and Results.

15-20 minStrategus

Note how analysis specifications are created and executed.

20-25 minTARGET

Identify what must remain explicit and transparent.

25-30 minOutput

Adapt the architecture to an ADaM specification workflow.

Open-access sources

From causal question to executable workflow.

Brief background

Standardization creates the boundary.

Target trial emulation specifies the randomized trial that would ideally answer a causal question and maps each protocol component to observational data.

THESEUS maps free text into a constrained JSON schema covering study period, time-at-risk, propensity-score adjustment and outcome-model settings. Deterministic logic then produces Strategus R scripts and a reproducible package environment.

The authors evaluated eight LLMs on 15 OHDSI and 15 non-OHDSI studies. Primary-analysis accuracy ranged from 0.93 to 0.97 in OHDSI studies and from 0.82 to 0.95 outside OHDSI. Complex descriptions produced more field-level errors.

A side-by-side interface lets researchers accept or reject individual changes before code generation. Strategus provides standardized execution, while TARGET supports transparent reporting.

Key vocabulary

Fifteen terms worth retrieving.

Term中文Meaning / use
target trial emulation目标试验模拟Emulating a hypothetical randomized trial with observational data.
causal inference因果推断Estimating the effect of an intervention or exposure.
analytic specification分析规格说明A structured description of analysis settings.
constrained schema受约束的数据模式A predefined structure limiting allowed fields and values.
deterministic conversion确定性转换Repeatable rule-based transformation.
time-at-risk风险观察窗口The follow-up period during which outcomes are counted.
propensity-score adjustment倾向评分调整A method for reducing measured confounding.
outcome model结局模型The model estimating the treatment-outcome relationship.
field-level sensitivity字段级敏感度The proportion of required fields correctly identified.
false positive假阳性An incorrectly generated field or setting.
human-in-the-loop人在回路A workflow requiring human review or control.
side-by-side comparison并排比较Reviewing original and proposed specifications together.
reproducible workflow可复现工作流A workflow rerunnable with the same code and environment.
package environment软件包环境Recorded dependency versions required for execution.
standardized substrate标准化底座A common data and analysis foundation.

Useful phrases

Language for a workflow-design discussion.

  1. translate free-text descriptions into structured specifications - The system translates free-text descriptions into structured specifications.
  2. operate within a constrained schema - The LLM operates within a constrained schema.
  3. convert validated specifications through rule-based logic - Validated specifications are converted through rule-based logic.
  4. separate interpretation from execution - The architecture separates interpretation from execution.
  5. preserve a human review gate - The workflow preserves a human review gate.
  6. perform better in standardized settings - The models performed better in standardized settings.
  7. generalize beyond the development ecosystem - The evaluation tested generalization beyond OHDSI.
  8. reduce implementation variability across sites - Standardized specifications reduce implementation variability.
  9. make assumptions explicit and auditable - Structured metadata makes assumptions explicit and auditable.
  10. remain vulnerable to field-level errors - The workflow remains vulnerable to field-level errors.

Comprehension

Five questions.

  1. What are the two major stages of THESEUS?
  2. Why is code generation deterministic after the LLM step?
  3. How did performance differ between OHDSI and non-OHDSI studies?
  4. What is the purpose of the side-by-side review interface?
  5. How do Strategus and TARGET support reproducibility and transparency?

Retelling

Say it three times.

  • 30 seconds: Problem -> two-stage solution -> result.
  • 45 seconds: Free text -> JSON -> human review -> R code -> execution.
  • 60 seconds: Adapt the architecture to an ADaM specification workflow.

5-minute output task

Design an AI-assisted ADaM spec workflow.

Your role: You are proposing a controlled specification generator to an SP lead.

  1. Minute 1: Define the fields the LLM may draft.
  2. Minutes 2-3: Separate LLM interpretation, deterministic validation and human approval.
  3. Minute 4: Define accuracy, precision, sensitivity and false-positive metrics.
  4. Minute 5: Give a 90-second recommendation and state the production-readiness threshold.

One sentence to keep

The safest path from natural language to executable analysis is structured interpretation followed by deterministic conversion and explicit human review.