Skip to content

Commit 4ddca59

Browse files
authored
Update WRITEUP.md
1 parent 82e0e72 commit 4ddca59

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

WRITEUP.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Zestic AI partner and builder of Terraphim.
88
Background in distributed systems (Rust, async), complex systems, and knowledge graph engineering. Built the full pipeline: entity extraction, knowledge graph, multi-agent orchestration, MedGemma integration, evaluation harness, and edge deployment config.
99
Solo submission.
1010

11+
**Why Terraphim Embeddings and Knowledge Graph**
12+
In my previous medical pipeline - The Pattern, platinum winner of $100K "Build on Redis" Hackathon at RedisConf 2021, I built an engineering marvel: with inference on CPU under 2 ms for QA-large-bert uncased model before NVIDIA Ampere architecture was released, yet while I was testing it I always thought: "If my doctor is going to be using my system, I don't want to be the patient". For the past 5 years, I have been building graph embeddings, which have enabled me to achieve 100% accuracy and grounding in medical industry knowledge. And with the industry awakening to the fact that Transformer architecture has its own limitations, Terraphim or terraphim-like graph embeddings can be a new type of tokeniser that will drive new large and small language models.
13+
1114
## Problem statement
1215

1316
### The Problem: LLMs Hallucinate Dangerous Drug Recommendations
@@ -54,6 +57,8 @@ Patient Input --> Entity Extraction (Aho-Corasick LeftmostLongest, <1ms)
5457
--> Grounded Clinical Recommendation
5558
```
5659

60+
61+
5762
**Why MedGemma specifically:**
5863

5964
1. **Medical training complements structured knowledge.** MedGemma's parametric knowledge handles clinical reasoning and natural language generation, while the KG provides hard constraints (drug-gene interactions, contraindications, trial evidence). Neither alone is sufficient.
@@ -66,9 +71,9 @@ Patient Input --> Entity Extraction (Aho-Corasick LeftmostLongest, <1ms)
6671

6772
### System 1 + System 2: Why This Architecture Works
6873

69-
This pipeline embodies the dual-process model from cognitive science. MedGemma operates as **System 1**— a fast system, intuitive, pattern-matching. It has absorbed millions of clinical documents during training and produces fluent, plausible-sounding recommendations in seconds. Like a clinician's trained intuition, it is usually directionally correct, but prone to confident errors: hallucinating a 10x dose (800mg vs 80mg), suggesting a drug outside the patient's mutation profile, or hedging with vague class-level recommendations ("consider EGFR inhibitor") instead of actionable specifics.
74+
This pipeline embodies the dual-process model from cognitive science. MedGemma operates as **System 1**— a fast, intuitive, pattern-matching system. It has absorbed millions of clinical documents during training and produces fluent, plausible-sounding recommendations in seconds. Like a clinician's trained intuition, it is usually directionally correct, but prone to confident errors: hallucinating a 10x dose (800mg vs 80mg), suggesting a drug outside the patient's mutation profile, or hedging with vague class-level recommendations ("consider EGFR inhibitor") instead of actionable specifics.
7075

71-
The Terraphim knowledge graph operates as **System 2**— slow, deliberate, evidence-based reasoning. Entity extraction with LeftmostLongest matching grounds the clinical text to precise SNOMED CT concepts. The typed graph (27 node types, 65 edge types) traces explicit evidence paths: Drug->Treats->Disease->HasVariant->Gene->CitedIn->Trial. PGx validation checks drug-gene interactions against CPIC guidelines. The safety gate verifies every recommendation against the validated treatment subgraph before it is sent to the clinician.
76+
The Terraphim knowledge graph operates as **System 2**— slow, deliberate, evidence-based reasoning. Entity extraction with LeftmostLongest matching grounds the clinical text to precise SNOMED CT concepts. The typed graph (27 node types, 65 edge types) traces explicit evidence paths: Drug->Treats->Disease->HasVariant->Gene->CitedIn->Trial. PGx validation checks drug-gene interactions against CPIC guidelines. The safety gate verifies every recommendation against the validated treatment subgraph before sending it to the clinician.
7277

7378
Neither system alone is sufficient. System 1 (MedGemma) without System 2 produces hallucinations that look authoritative. System 2 (KG) without System 1 can only retrieve explicitly encoded information -- it cannot reason about novel combinations or generate natural-language explanations. The combination is greater than either part: MedGemma generates candidate recommendations from its vast parametric knowledge, and the knowledge graph validates, constrains, and grounds them in traceable clinical evidence. The result is a system that thinks fast and checks carefully -- the same cognitive architecture that makes expert clinicians effective, implemented as a reproducible, auditable pipeline.
7479

@@ -108,7 +113,7 @@ Terraphim uses **symbolic graph embeddings** rather than vector embeddings for c
108113

109114
**Demonstrated safety gate behaviour:** During real inference, MedGemma recommended "Pembrolizumab 200mg IV every 3 weeks" for an EGFR L858R+ NSCLC patient. The knowledge graph safety gate correctly **blocked this recommendation** -- Pembrolizumab (a PD-1 checkpoint inhibitor) is not in the validated EGFR-NSCLC treatment subgraph. The KG instead grounds the recommendation to Osimertinib per the FLAURA trial. This is not a failure mode -- it is the system working as designed. Across 36 real inference calls (18 CPU + 18 GPU), the safety gate maintained 100% detection of ungrounded recommendations while passing all clinically appropriate ones.
110115

111-
The `find_similar()` function enables clinical decision support beyond direct lookups: querying "what is similar to NSCLC?" returns SCLC (high similarity -- sibling lung cancers sharing treatment pathways) over breast cancer (lower similarity -- different organ, different treatment graph). This graph-structural similarity is impossible to replicate reliably with dense embeddings trained on general medical text.
116+
The `find_similar()` function enables clinical decision support beyond direct lookups: querying "what is similar to NSCLC?" returns SCLC (high similarity -- sibling lung cancers sharing treatment pathways) over breast cancer (lower similarity -- different organ, different treatment graph). This graph-structural similarity cannot be reliably replicated with dense embeddings trained on general medical text.
112117

113118
**Built on the terraphim-ai crate ecosystem.** The graph embeddings are not a competition-specific prototype -- they are part of [terraphim-ai](https://github.com/terraphim/terraphim-ai), a production Rust library for knowledge graph-powered semantic search. Two crates are load-bearing in every end-to-end demo:
114119

@@ -179,7 +184,7 @@ Live mode verified with 8 Playwright e2e tests covering:
179184
+----------------------------------------------------------------------+
180185
```
181186

182-
**11 Rust crates, 543+ tests, 0 failures, 9 Playwright e2e tests (8 functional + 1 video recording).** The system is implemented in Rust for performance-critical components (entity extraction, KG queries, PGx validation all <1ms) with MedGemma inference via Vertex AI (cloud) or GGUF quantized model (edge). The API server (`terraphim-api`) uses Axum with shared state to serve REST endpoints, WebSocket streaming, and the interactive demo UI.
187+
**11 Rust crates, 543+ tests, 0 failures, 9 Playwright e2e tests (8 functional + 1 video recording).** The system is implemented in Rust for performance-critical components (entity extraction, KG queries, PGx validation, all <1ms) with MedGemma inference via Vertex AI (cloud) or GGUF quantised model (edge). The API server (`terraphim-api`) uses Axum with shared state to serve REST endpoints, WebSocket streaming, and the interactive demo UI.
183188

184189
### Performance
185190

0 commit comments

Comments
 (0)