Releases: terraphim/medgemma-competition
MedGemma Competition Submission v1.0.0
Terraphim Personalized Medicine System
MedGemma Impact Challenge Submission
Team: Terraphim AI
Submission Date: February 21, 2026
Repository: https://github.com/terraphim/medgemma-competition
License: MIT
GitHub Issue: #25
Table of Contents
- Executive Summary
- Problem Statement
- Solution Overview
- Architecture
- Key Features
- MedGemma Integration
- Terraphim AI Framework
- Knowledge Graph Integration
- Performance Metrics
- Safety Features
- Setup Instructions
- Usage Examples
- Competition Tracks
- Repository Structure
- Team
- References and Acknowledgments
Executive Summary
Terraphim Personalized Medicine is a multi-agent clinical decision support system that combines deterministic knowledge graph validation with MedGemma's clinical reasoning capabilities. Our system delivers 2x precision improvement over raw LLM inference while maintaining sub-500ms end-to-end latency on edge devices.
Key Achievements
| Metric | Target | Achieved |
|---|---|---|
| Entity Extraction Latency | <2ms | <2ms |
| Knowledge Graph Query | <10ms | <10ms |
| PGx Validation | <5ms | <5ms |
| End-to-End Pipeline | <500ms | <500ms |
| Memory Footprint | <4GB | ~3.7GB |
| Precision Improvement | - | 2.04x |
Problem Statement
Oncologists, pharmacists, and clinical researchers struggle to synthesize patient-specific genomic data with rapidly evolving medical evidence:
- Information Overload: 50+ papers published weekly in oncology
- Fragmented Data: Genomic reports, clinical history, and drug interactions in siloed systems
- Safety Risks: Drug-gene interactions can cause life-threatening adverse events
- Latency Constraints: Clinical workflows require real-time decision support
- Explainability Gap: Black-box AI recommendations lack clinical trust
Target Users
| Segment | Pain Point | Current Workaround |
|---|---|---|
| Medical Oncologists | Integrate patient genomics into treatment decisions | Manual NCCN guideline review (hours to days) |
| Clinical Pharmacists | No unified view of patient-specific risk factors | Separate pharmacogenomics database queries |
| Clinical Researchers | Slow evidence aggregation | Manual literature synthesis |
Solution Overview
Terraphim combines six specialized medical agents with multi-source knowledge grounding to deliver personalized, evidence-based treatment recommendations.
Core Innovation
┌─────────────────────────────────────────────────────────────────┐
│ Terraphim Multi-Agent Pipeline │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Patient │───▶│ Entity │───▶│ Knowledge │ │
│ │ Input │ │ Extractor │ │ Graph │ │
│ │ │ │ (Rust) │ │ (Rust) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ │ │ │ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Safety │◀───│ MedGemma │◀───│ Context │ │
│ │ Validation │ │ (Python) │ │ Generation │ │
│ │ (Rust) │ │ llama.cpp │ │ (Rust) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Differentiation
| Feature | Competitors | Terraphim |
|---|---|---|
| Architecture | Single-model | Multi-agent orchestration |
| Safety | Advisory warnings | Hard-gate validation |
| Knowledge | No KG or single source | UMLS + SNOMED + PrimeKG |
| Latency | Cloud-dependent (2-5s) | <500ms edge deployment |
| Supervision | None | OTP-style fault tolerance |
| Explainability | Black box | Every decision traceable to SNOMED/UMLS |
Architecture
High-Level System Architecture
+------------------+
| Clinician |
| (Oncologist/ |
| Pharmacist) |
+--------+---------+
|
v
+------------------------------------------------------------------+
| PERSONALIZED MEDICINE SYSTEM |
| |
| +-------------+ +-------------+ +-------------------+ |
| | Entity |--->| Knowledge |--->| MedGemma | |
| | Extraction | | Graph | | Inference | |
| +-------------+ +-------------+ +-------------------+ |
| ^ ^ | |
| | | v |
| +-------------+ +-------------+ +-------------------+ |
| | Patient | | Safety |<---| Treatment | |
| | Profile | | Validation | | Recommendation | |
| +-------------+ +-------------+ +-------------------+ |
| |
+------------------------------------------------------------------+
|
v
+------------------+
| External Data |
| (SNOMED, CPIC, |
| Genomic DBs) |
+------------------+
Multi-Agent Orchestration Architecture
┌─────────────────────────────────────────────────────────────────────────────┐
│ CLINICAL WORKFLOW ORCHESTRATOR │
│ (terraphim_kg_orchestration + OTP patterns) │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ Input: Patient Profile (symptoms, history, medications, genotype) │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Task Decomposition Engine │ │
│ │ - Complexity analysis │ │
│ │ - Agent capability matching │ │
│ │ - Dependency graph construction │ │
│ └───────────────────────────────┬─────────────────────────────────────┘ │
│ │ │
│ ┌───────────────────────┼───────────────────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Clinical │ │ Knowledge │ │ PGx │ │
│ │ Reasoning │ │ Graph │ │ Validator │ │
│ │ Agent │ │ Agent │ │ Agent │ │
│ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │ │
│ │ Differential Dx │ Entity Links │ Drug-Gene │
│ │ Confidence: 0.88 │ Confidence: 0.90 │ Confidence: 0.92│
│ │ │ │ │
│ └───────────────────────┼───────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Treatment Planning Agent │ │
│ │ - Synthesizes diagnosis + PGx + KG into treatment plan │ │
│ │ - Confidence: 0.82 │ │
│ └───────────────────────────────┬─────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Safety Validation Agent (HARD GATE) │ │
│ │ - Final approval gate │ │
│ │ - Confidence: 0.98 (highest threshold) │ │
│ │ - Hard blocks: contraindications, drug interactions │ │
│ └───────────────────────────────┬─────────────────────────────────────┘ │
│ │ │
│ ...