What if you could generate a synthetic version of every patient in a clinical trial – one that shows exactly what would have happened to them without treatment?
Unlearn.ai built exactly that system. Using conditional restricted Boltzmann machines, they create counterfactual patient trajectories that reduce trial sizes by 30-50% without losing statistical power.
The engineering challenge isn’t just building generative models. It’s doing so with medical data that has 15-40% missing values and irregular temporal sampling, while meeting regulatory requirements that would break most ML pipelines. The result is a production system that fundamentally changes how clinical evidence gets generated – but building it required solving problems that don’t exist in typical ML deployments.
The architecture: conditional generation at scale
Unlike standard ML models that predict P(outcome|features), this system learns P(outcomes | baseline_features, treatment_assignment, time_horizon) – essentially building a time-series generator conditioned on medical context. Think of it like dependency injection for probabilistic models: instead of hardcoding assumptions about patient populations, you inject specific patient contexts at runtime.
The breakthrough methodology, called PROCOVA (Prognostic Covariate Adjustment), transforms the entire statistical inference process. Instead of comparing treatment groups against population averages, each patient gets compared to their digital twin:
# Traditional approach
P(outcome | features)
# Unlearn.ai's conditional generation
P(outcomes | baseline_features, treatment_assignment, time_horizon)
# Per-patient comparison
Treatment_Effect_i = (Observed_Outcome_i - Predicted_Natural_History_i) / Predicted_Natural_History_i
This shifts from a between-group comparison problem to a within-patient prediction problem. The baseline heterogeneity that creates noise in traditional trials becomes useful signal for personalised modelling – turning what was previously statistical noise into valuable training data.
The conditional restricted Boltzmann machine architecture splits its internal representation across different timescales. Similar to how modern systems separate hot and cold storage paths, separate hidden unit populations capture short-term clinical fluctuations versus long-term disease progression – like having different model components specialised for high-frequency and low-frequency patterns in the same probabilistic framework.
Training requires sliding temporal windows across massive datasets: electronic health records spanning decades, clinical trial databases, real-world evidence from insurance claims. Each training example effectively answers: “Given this patient profile at this time point, here’s how their disease progressed over the following months.”
The cRBM training pipeline resembles large language model pretraining – massive datasets, GPU-accelerated optimisation, generation of synthetic outputs that preserve statistical structure from training data. The critical difference is conditioning and consequence: where language models autocomplete text, this system forecasts disease trajectories with direct clinical and regulatory implications.
Data engineering reality check
This conditional generation approach sounds elegant in theory. But like most ML systems, the mathematics are only as good as the training data – and medical data presents failure modes that would cripple models trained on cleaner domains like computer vision or natural language processing.
When a patient’s lab results are missing, it could be a clinical decision (test wasn’t ordered), operational failure (test was ordered but not performed), documentation gap (test performed but not recorded), or technical failure (test recorded but not transmitted). Each scenario carries different implications for model training, because treating systematic gaps as random missingness introduces bias that propagates through every generated trajectory.
Like handling eventual consistency in distributed databases, you can’t assume all medical data arrives on time or at all, so the system must gracefully handle partial information. The platform implements multi-layered data validation that operates continuously rather than as a preprocessing step:
Validation layer | What it does | Why it matters |
Provenance tracking | Maintains complete data lineage – source system, collection timestamp, validation status, transformations. | Weights training examples by reliability rather than treating all inputs equally. |
Cross-source validation | Flags discrepancies between multiple data sources for the same clinical event. | Applies conflict resolution algorithms prioritising most reliable source hierarchy. |
Real-time quality scoring | Dynamic scoring based on completeness, consistency, and temporal plausibility. | Adjusts confidence intervals based on baseline data quality. |
Temporal consistency | Validates medically plausible event sequences. | Prevents impossible scenarios (medications after death, biologically impossible lab ranges). |
This approach builds quality assessment directly into the generative process so that model uncertainty reflects actual data reliability rather than algorithmic confidence – ensuring that every synthetic patient trajectory is grounded in reliable medical evidence.
Production-scale engineering challenges
With reliable data pipelines established, the next challenge swiftly arises: generating thousands of synthetic patient trajectories in real-time while maintaining the statistical validity that regulators demand. This creates computational and memory constraints that don’t exist in typical ML deployments.
Distributed computation: The architecture distributes inference across GPU clusters, with each processing unit handling distinct patient cohorts. Shared model parameters ensure consistent probabilistic behaviour while enabling high-throughput trajectory generation. The parallelisation strategy accounts for the fact that patient trajectories can be generated independently once the model is trained.
Memory-efficient state management: Long-horizon simulations for conditions like cardiovascular disease can span two-year periods with dozens of clinical variables per patient. The system minimises memory overhead through trajectory compression and selective caching strategies that store only clinically significant state transitions.
Adaptive trajectory updates: As real trial data streams in, each digital twin incorporates new information to refine its predictions. A patient’s unexpected lab result or adverse event updates their model state, adjusting the synthetic trajectory moving forward. This creates a feedback loop between trial execution and generative interface – unlike typical batch prediction systems that operate on static datasets.
The regulatory requirements create constraints that most ML systems never face:
Traditional ML systems | Clinical trial systems |
Best-effort accuracy acceptable | Regulatory compliance mandatory |
Occasional downtime tolerable | Zero tolerance for data integrity loss |
Model updates on convenient schedule | Reproducible predictions required months later |
Explainability nice-to-have | Detailed audit trails legally required |
Explainability requirements: While cRBMs excel at capturing complex statistical dependencies, they don’t naturally produce the interpretable outputs that regulators require. The platform implements gradient-based attribution methods that trace outcome predictions back to specific baseline variables and prior clinical events, building transparency into a fundamentally generative system.
Technical validation at scale
All this infrastructure investment raises a critical question: how do you prove that synthetic patients are statistically equivalent to real ones? The validation approach operates under a simple principle: model sophistication cannot compensate for data unreliability, so continuous validation monitors multiple dimensions simultaneously.
This resembles chaos engineering for ML models – continuously testing edge cases and failure modes rather than assuming training performance generalises to production scenarios:
Primary validation:
- Data drift detection: Real-time comparison of incoming patient data against training distribution parameters. When new patients exhibit characteristics outside the model’s training envelope, the system flags potential extrapolation errors and adjusts confidence intervals accordingly.
- Cross-population validation: The platform maintains separate validation datasets for different demographic groups, disease stages, and treatment protocols. Before generating synthetic trajectories for any patient cohort, the system verifies that adequate training data exists for that specific population segment.
Continuous monitoring: For ongoing trials, the system continuously compares its synthetic predictions against actual patient outcomes as they become available. Significant deviations trigger automated investigation into whether the discrepancy reflects model limitations, data quality issues, or genuine clinical surprises that require model updates.
Statistical calibration: High statistical power only provides value if prediction confidence is properly calibrated across diverse patient demographics and disease stages. The platform continuously tests and adjusts its uncertainty estimates, ensuring confidence intervals reflect actual prediction accuracy rather than model confidence.
Each of these validation capabilities serves the larger goal of reducing trial sizes while maintaining statistical rigour – proving that synthetic patients can reliably substitute for real ones in clinical research.
Quantified engineering impact
This comprehensive validation framework enables Unlearn.ai to make a bold claim: their technical improvements translate into measurable changes in trial efficiency.
PHASE II ONCOLOGY TRIALS
Typical: 200-400 patients → With Digital Twins: 120-280 patients
↓ 30-40% reduction
PHASE III CARDIOVASCULAR TRIALS
Typical: 2000-4000 patients → With Digital Twins: 1400-2800 patients
↓ 30-50% reduction
TIMELINE IMPACT: 25-40% faster completion
STATISTICAL POWER: Maintained at equivalent levels
Broader engineering implications
This system demonstrates how generative modelling built on conditional probability structures enables not just inference, but simulation. It moves beyond prediction into counterfactual reasoning at population scale – a pattern that opens applications far broader than medical AI.
The technical achievement lies not in abstract algorithmic complexity, but in solving concrete real-world constraints through generative computation. The mathematics transforms a fundamental limitation in how medical evidence is generated, while the engineering makes it operationally viable at the scale required for regulatory acceptance.
For developers working on other domains requiring counterfactual reasoning – recommendation systems that need to model alternative user journeys, financial models that simulate different market conditions, or any system where you need to answer “what would have happened if” – this architecture provides a production-tested pattern for conditioning generative models on complex, multi-dimensional contexts while maintaining statistical rigour at scale.