Inspiration AI can be factually right — and still be wrong in time. Clinical AI systems can retrieve information that is completely real, from the correct patient, and from a valid medical record — yet still use it in the wrong temporal context. A statement such as: “The latest calcium result is lower than the previous one.”
may sound plausible, even when the patient’s actual longitudinal record shows: Previous: 8.84 → Latest: 9.82 The values are real. The patient is correct. The data source is correct. But the claim is false. That failure mode inspired ContextBind.
What it does ContextBind is a pre-action temporal verification layer for clinical AI systems. Before an AI-generated clinical claim is written back to an EHR or allowed to trigger a downstream workflow, ContextBind checks whether the claim is actually supported by the patient’s longitudinal FHIR timeline. As clinical AI moves beyond answering questions toward drafting handoffs, summaries, and other EHR-bound content, a temporally incorrect claim can become part of a downstream workflow. ContextBind is designed to place a verification boundary between generated language and consequential execution. The pipeline is: AI-generated clinical claim → Semantic claim binder → Structured temporal predicate → Symbolic verification against FHIR evidence → PASS / BLOCK / HOLD → Write-back or downstream action
- PASS — the longitudinal evidence supports the claim.
- BLOCK — the source record contradicts the claim.
- HOLD — ContextBind cannot verify the claim confidently enough to allow execution. The goal is not to replace clinicians or let another AI decide whether a medical statement is true. Instead, ContextBind separates language understanding from source-of-truth verification.
How I built it I generated a reproducible synthetic longitudinal patient cohort using Synthea and processed the resulting FHIR resources into a structured timeline. The dataset includes:
- 575 synthetic patients
- 356,000+ FHIR resources
- 277,000+ observations
- 30,000+ encounters
- patient-disjoint training, validation, and held-out test splits No real patient data is used. I then defined four objective temporal verification tasks:
- Trend direction — increasing vs. decreasing
- Temporal relation — before vs. after
- Latest vs. previous comparison — higher vs. lower
- Current/latest state verification Ground truth is derived deterministically from the underlying patient timeline. For language understanding, ContextBind uses a hybrid approach. A deterministic rule-based binder handles claims it can interpret reliably. When that layer cannot resolve an open-form claim, a DistilBERT-based semantic fallback maps the language into the same structured predicate representation. Crucially, the AI model does not determine clinical truth. The resulting predicate is passed to a deterministic symbolic verifier, which checks it directly against the longitudinal FHIR evidence. A confidence gate ensures uncertain or structurally incomplete claims fail closed into HOLD.
Challenges I ran into The hardest part of the project was not making a model produce a high score. It was determining whether the problem was genuinely difficult. My first hypothesis focused on metadata and context-misbinding attacks. Strong deterministic baselines solved much of that benchmark, so I rejected the easy version of the problem instead of weakening the baseline to make ML look better. I then tested surface-level machine learning approaches. They performed well on familiar language but degraded sharply on open-form phrasing. That led me to semantic representation learning. During final evaluation, I also discovered an interface contract mismatch between binder outputs and the symbolic verifier. Instead of changing the model, threshold, test set, or task definitions after seeing the results, I froze the scientific system, audited the runtime path, repaired only the deterministic adapter contract, and reran the same persisted test claims. That process became one of the most important lessons of the project: A safety layer should not only question an AI system’s assumptions — it should survive the same scrutiny itself.
Accomplishments that I’m proud of On a held-out controlled test set of 1,000 claims, the final system achieved:
- 98.6% coverage
- 98.58% selective accuracy
- 97.2% utility accuracy
- 0.0% unsafe-action rate
- 95.8% counterfactual pair consistency The symbolic oracle achieved 100% coverage and 100% accuracy, confirming that the temporal verification tasks were deterministically solvable from the source timeline. I then stress-tested ContextBind on a separate 1,000-claim adversarial open-form language set. Rule-only coverage was 54.8%. With the semantic AI fallback, coverage increased to 74.7%. That is a +19.9 percentage-point coverage gain. The open-form evaluation also exposed an important limitation: the final hybrid system still had an 8.6% unsafe-action rate under adversarial language variation. I chose not to hide that result. ContextBind is a research prototype, not a clinically validated safety system. The evaluation shows both where semantic AI adds value and where stronger calibration, human review, and real-world validation are still required. The open-form evaluation uses manually authored adversarial paraphrases and controlled language-generation templates rather than real clinician or production-agent outputs, so real-world generalization remains an open question. I am also proud of the evaluation discipline behind the project: patient-disjoint splits, frozen test artifacts, leakage checks, counterfactual pairs, deterministic ground truth, and an explicit audit trail for evaluation bugs.
What I learned ContextBind taught me that more AI is not always the answer. For controlled language, deterministic rules were extremely strong. Semantic AI became valuable specifically where natural-language variation caused those rules to abstain. Symbolic verification remained necessary because interpreting a claim and proving it against source evidence are two different problems. The final architecture reflects that lesson: AI interprets. Evidence decides. I also learned that a good safety system needs to know when not to act. In ContextBind, uncertainty does not silently become execution — it becomes HOLD.
What’s next for ContextBind Future work includes:
- evaluation on independently authored and real-world clinical language
- external validation on additional FHIR datasets
- stronger semantic calibration and abstention
- clinician-centered usability testing
- shadow-mode deployment before any real EHR integration
- broader temporal and provenance-aware claim verification My long-term goal is not to make clinical AI autonomous. It is to make consequential AI actions more accountable to the evidence they depend on. AI can be factually right but temporally wrong. ContextBind checks the evidence before that mistake becomes an action.
Research prototype. Not for clinical use or autonomous medical decision-making.
Built With
- agentic-ai
- ai-safety
- audit-logging
- bootstrap-statistics
- clinical-nlp
- distilbert
- electronic-health-records-(ehr)
- formal-verification
- guardrails
- healthcare
- hl7-fhir
- hugging-face
- hybrid-ai
- loinc
- medical-ai
- multi-task-learning
- neuro-symbolic-ai
- python
- pytorch
- scikit-learn
- snomed-ct
- sqlite
- synthea
- temporal-reasoning
- transformers
Log in or sign up for Devpost to join the conversation.