Skip to main content
Back

Harvard's CLEF Answers Medical 'What If' Questions 65% More Accurately

Harvard's CLEF framework gives sequence models surgical control over when and where interventions take effect, unlocking counterfactual simulation for cells, patients, and clinical decisions

Pro

  • CLEF is a new framework from Harvard that adds precise temporal and variable-level control to conditional sequence generation models for biological and clinical data.
  • It introduces temporal concepts — learned vectors representing per-variable rates of change — that encode how and when an intervention alters a trajectory.
  • CLEF enables one-step delayed sequence editing, jumping directly to any future time point without autoregressive rollout, outperforming baselines by up to 65.71% MAE.
  • On zero-shot counterfactual generation of cellular trajectories, CLEF achieves up to 63.19% MAE improvement over non-CLEF models.
  • A type 1 diabetes case study shows CLEF can generate realistic "healthier" patient trajectories and capture downstream physiological effects like the glucose-WBC relationship.
  • Code, data, and models are available at github.com/mims-harvard/CLEF; paper at arxiv.org/abs/2502.03569.

Imagine asking a model: "What would this patient's lab results look like if we had started insulin therapy last month instead of today?" Or: "How would this cell's gene expression evolve if we activated a specific transcription factor on day 8 instead of day 12?" These are counterfactual questions, and answering them precisely requires something most sequence models simply cannot do: apply an intervention at a specific point in time, to specific variables, while leaving everything else untouched. That is exactly the gap that CLEF is designed to fill.

The control problem in sequence generation

Sequence models generate counterfactuals by modifying parts of a sequence based on a given condition, enabling reasoning about "what if" scenarios. While these models excel at conditional generation, they lack fine-grained control over when and where edits occur. Existing approaches either focus on univariate sequences or assume that interventions affect the entire sequence globally. In biology and medicine, that is a serious limitation. A drug is administered at a specific moment. Surgery happens on a specific day. The immune system responds to a specific trigger. While effective at generating entire sequences, these models typically lack control over the timing and scope of the edits. Most existing approaches either operate on univariate sequences or assume that the condition affects all variables and time steps. However, many scientific and clinical applications require more precise interventions, where a condition takes effect only after a specific time and influences only a subset of variables.

There is also a distinction that prior work collapses: the difference between immediate and delayed sequence editing. Immediate editing asks what happens right after an intervention is applied now. Delayed editing asks what the trajectory looks like if the intervention is scheduled for the future, skipping directly to that future time without autoregressively filling in the gap. Unlike prior models, CLEF enables one-step conditional generation at arbitrary future times, outperforming them in delayed sequence editing by up to 65.71% (MAE).

Temporal concepts: the core innovation

CLEF is a controllable sequence editing model for conditional generation of immediate and delayed effects in multivariate longitudinal sequences. CLEF learns temporal concepts that encode how and when a condition alters future sequence evolution. A temporal concept is formally defined as the ratio of a sequence's state at a future time to its state at the current time , essentially a learned representation of the rate of change for each measured variable between two time steps. The concept captures not just what will change, but by how much and in which direction, given a specific intervention at a specific time.

Architecturally, CLEF has four components that work in sequence:

  1. Sequence encoder (F): Extracts temporal features from historical data. Any encoder works here, including pretrained foundation models like MOMENT.
  2. Condition adapter (H): Maps a condition token (e.g., a drug's protein embedding from ESM-2, or a clinical ICD code embedding) into a shared latent space.
  3. Concept encoder (E): Combines the sequence representation, the time-delta embedding (the difference between now and the target forecast time), and the condition embedding via element-wise multiplication to produce the temporal concept vector c.
  4. Concept decoder (G): Applies the learned concept to the most recent observation via element-wise multiplication to generate the predicted future state.

The elegance of the decoder is its simplicity: the predicted future state is literally the current state scaled by the temporal concept. This means the concept directly encodes the multiplicative change each variable undergoes, making it both interpretable and directly manipulable by users.

What the benchmarks show

CLEF is evaluated on 7 datasets spanning cellular reprogramming and patient health trajectories, comparing against 9 state-of-the-art baselines. The datasets include simulated single-cell transcriptomic trajectories using the Waddington-OT model, real-world patient lab test trajectories from eICU and MIMIC-IV, and synthetic tumor growth trajectories for counterfactual prediction benchmarks.

The results break down across three task types:

  • Immediate sequence editing: CLEF improves immediate sequence editing accuracy by up to 36.01% (MAE).
  • Delayed sequence editing: CLEF outperforms baselines by up to 65.71% MAE by jumping directly to any future time step in a single forward pass, rather than autoregressively stepping through intermediate time points.
  • Zero-shot counterfactual generation: CLEF shows up to 63.19% (MAE) improvement on zero-shot conditional generation of counterfactual trajectories. Models are trained on "original" trajectories and evaluated on paired counterfactual trajectories they have never seen.
Bar charts comparing MAE across sequence editing methods for WOT, eICU, MIMIC-IV datasets in immediate and delayed editing scenarios

The counterfactual connection

CLEF is not just a sequence generation model , it has a formal connection to causal inference. Under standard assumptions from the potential outcomes framework (consistency, positivity, and sequential ignorability), CLEF can be interpreted as estimating counterfactual outcomes over time. Because the sequence encoder and condition adapter process historical covariates and the next treatment independently, direct temporal concept edits via CLEF enable actionable interpretability and tangible in silico hypothesis exploration. This also means CLEF can be plugged into existing counterfactual prediction architectures like CRN and CT, where it consistently improves performance under high time-varying confounding.

Type 1 diabetes: a clinical case study

In a case study of patients with type 1 diabetes mellitus, CLEF identifies clinical interventions that generate realistic counterfactual trajectories shifted toward healthier outcomes. The team used CLEF to simulate what would happen to a T1D patient's lab trajectory if their glucose levels were halved. The generated trajectories showed higher similarity to healthy individuals than to other T1D patients. Crucially, CLEF also captured the downstream effects: lowering glucose also led to a reduction in white blood cell count, consistent with the known autoimmune dynamics of T1D. When the researchers instead intervened on WBC levels, glucose levels also dropped , the model learned the joint physiological relationship between these markers without being explicitly told.

R-squared values comparing MIMIC-IV-T1D and eICU-T1D model predictions for glucose levels and forest plot of lab test differences

Where it fits and where it falls short

CLEF is most useful when you need to ask time-sensitive "what if" questions about multivariate longitudinal data. Practical use cases include:

  • Simulating the effect of drug timing on single-cell gene expression trajectories for virtual cell experiments
  • Generating counterfactual patient trajectories to explore treatment timing in ICU settings
  • In silico hypothesis testing for clinical trial design, where you want to compare outcomes under different intervention schedules
  • Augmenting counterfactual prediction models (CRN, CT) with better representation learning under confounding

There are limitations worth noting. CLEF's temporal concepts are defined per-variable, so they do not capture higher-order cross-variable interactions or hierarchical temporal patterns. The model also requires that counterfactual inference assumptions hold , no unobserved confounders , which may not be satisfied in all real-world settings. Performance also depends on the quality of the underlying sequence encoder; models using MOMENT as the backbone consistently showed higher MAE than Transformer or xLSTM variants, even with CLEF applied.

Code and data

The team introduces a new benchmarking dataset, WOT, constructed using the Waddington-OT model, which simulates single-cell transcriptomic profiles of developmental time courses of cells. They also construct a new counterfactual benchmarking dataset, WOT-CF. The full codebase is available at github.com/mims-harvard/CLEF, along with data hosted on Figshare and a project website from the Zitnik Lab at Harvard Medical School. The repository includes model implementations, data preparation scripts, and an environment file for reproducibility.

The broader ambition here is clear. As the FDA phases out animal testing requirements for therapeutic discovery, the field needs computational tools that can simulate the effects of candidate drugs with temporal precision. CLEF is a step toward that goal , a framework that treats time not as a nuisance variable to be averaged over, but as a first-class dimension of biological and clinical reasoning.