brainworm2024 commited on
Commit
506ca47
Β·
1 Parent(s): 74f2b46

Add polished professional README

Browse files
Files changed (1) hide show
  1. README.md +213 -7
README.md CHANGED
@@ -1,3 +1,4 @@
 
1
  ---
2
  title: RustVital-AMD
3
  emoji: πŸ₯
@@ -7,13 +8,218 @@ sdk: docker
7
  pinned: true
8
  ---
9
 
10
- # RustVital-AMD: Zero‑Trust Medical AI Triage Gateway
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- **Pure Rust + AMD ROCm + Web3**
13
- PII redaction before AI inference, Filecoin CID + Base L2 on-chain audit.
 
 
 
14
 
15
- - **API:** `POST /triage`
16
- - **Stack:** Axum, Candle, alloy-rs, Qwen-72B (mock now, MI300X soon)
17
 
18
- Built for the AMD Developer Hackathon (lablab.ai)
19
- Tracks: AI Agents & Agentic Workflows | Fine‑Tuning on AMD GPUs | Hugging Face Challenge
 
1
+
2
  ---
3
  title: RustVital-AMD
4
  emoji: πŸ₯
 
8
  pinned: true
9
  ---
10
 
11
+ <div align="center">
12
+ <img src="https://img.shields.io/badge/Rust-1.95-dea584?logo=rust&logoColor=white" alt="Rust"/>
13
+ <img src="https://img.shields.io/badge/AMD-ROCm-ED1C24?logo=amd&logoColor=white" alt="AMD ROCm"/>
14
+ <img src="https://img.shields.io/badge/Model-Qwen2.5_7B-615EFF?logo=huggingface&logoColor=white" alt="Qwen2.5"/>
15
+ <img src="https://img.shields.io/badge/Chain-Base_Sepolia-0052FF?logo=ethereum&logoColor=white" alt="Base Sepolia"/>
16
+ <img src="https://img.shields.io/badge/Audit-Filecoin_CID-0090FF?logo=ipfs&logoColor=white" alt="Filecoin CID"/>
17
+ </div>
18
+
19
+ # πŸ₯ RustVital‑AMD – Zero‑Trust Medical AI Triage Gateway
20
+
21
+ **Pure Rust β€’ AMD MI300X GPU β€’ Real Web3 Audit Trail**
22
+
23
+ RustVital‑AMD is a production‑grade, zero‑trust medical triage agent that **never exposes raw patient data to the AI model**. It accepts clinical notes, strips personally identifiable information (PII) before the GPU ever sees them, runs inference on a real **Qwen2.5‑7B** model backed by an **AMD MI300X** GPU, and rehydrates the response so the clinician sees a perfectly normal clinical report. Every triage is cryptographically proven and permanently anchored on‑chain via **Filecoin CID** and **Base Sepolia**.
24
+
25
+ πŸš€ **Live Demo:** [Launch on Hugging Face Spaces](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd)
26
+
27
+ ---
28
+
29
+ ## 🧬 Key Features
30
+
31
+ - **πŸ›‘οΈ Zero‑Trust PII Shield** – Deterministic, pre‑GPU redaction of names, ages, SSN, MRN, insurance IDs, and more.
32
+ - **🧠 Real AMD MI300X Inference** – Calls a live vLLM endpoint running Qwen2.5‑7B on ROCm, with graceful CPU fallback.
33
+ - **πŸ“‘ Streaming Agent Observability** – WebSocket + SSE endpoint show every pipeline step in real time.
34
+ - **πŸ“š PubMed Enrichment** – Queries NCBI E‑utilities for relevant biomedical literature after each triage.
35
+ - **🩻 DICOM Surrogate Redaction** – Demonstrates multi‑modal PII removal from medical imaging headers and burned‑in text.
36
+ - **πŸ” Cryptographic Audit** – A ZK‑simulated proof of correct redaction is generated and verified on every request.
37
+ - **⛓️ Blockchain Immutability** – Each triage produces a Filecoin CID and an on‑chain transaction on Base Sepolia (via alloy‑rs).
38
+ - **πŸ₯ Consortium Attestations** – Simulates three independent hospital attestations, creating a decentralised trust model.
39
+ - **βš™οΈ Federated Fine‑Tuning Trigger** – Exposes an endpoint that launches a LoRA fine‑tuning job on MI300X, using only redacted data.
40
+ - **🎨 Professional Dark UI** – Built with HTMX + Alpine.js + Tailwind CSS, served from Axum with no JavaScript build step.
41
+
42
+ ---
43
+
44
+ ## πŸ”„ How It Works
45
+
46
+ ```
47
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
48
+ β”‚ Clinician β”‚ β”‚ RustVital-AMD β”‚ β”‚ AMD MI300X GPU β”‚
49
+ β”‚ (Browser) β”‚ β”‚ (Axum Server) β”‚ β”‚ (vLLM + ROCm HIP) β”‚
50
+ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
51
+ β”‚ Submit consent form β”‚ β”‚
52
+ │────────────────────────►│ β”‚
53
+ β”‚ β”‚ (1) PII Shield β”‚
54
+ β”‚ β”‚ Redact PHI from note β”‚
55
+ β”‚ β”‚ Generate ZK‑style proof β”‚
56
+ β”‚ β”‚ β”‚
57
+ β”‚ β”‚ (2) Send redacted prompt β”‚
58
+ β”‚ │─────────────────────────────►│
59
+ β”‚ β”‚ β”‚ Run Qwen2.5‑7B
60
+ β”‚ │◄─────────────────────────────│
61
+ β”‚ β”‚ (3) Clinical synthesis β”‚
62
+ β”‚ β”‚ β”‚
63
+ β”‚ β”‚ (4) Enrich with PubMed β”‚
64
+ β”‚ β”‚ (5) Compute CID + anchor β”‚
65
+ β”‚ β”‚ on Base Sepolia β”‚
66
+ β”‚ β”‚ (6) Simulate consortium β”‚
67
+ β”‚ β”‚ attestations β”‚
68
+ β”‚ β”‚ β”‚
69
+ │◄────────────────────────│ (7) Return rehydrated resultβ”‚
70
+ β”‚ View real report β”‚ β”‚
71
+ β”‚ (PII never revealed) β”‚ β”‚
72
+ ```
73
+
74
+ ---
75
+
76
+ ## πŸ› οΈ Technology Stack
77
+
78
+ | Layer | Technology |
79
+ |---------------------|-------------------------------------|
80
+ | **Language** | Rust (edition 2021) |
81
+ | **Web Framework** | Axum + Tower + Tokio |
82
+ | **Inference** | vLLM (OpenAI‑compatible) on AMD ROCm|
83
+ | **LLM** | Qwen2.5‑7B‑Instruct |
84
+ | **PII Shield** | Custom regex engine (deterministic) |
85
+ | **Crypto** | SHA‑256, ECDSA (k256), ZK‑simulated |
86
+ | **Blockchain** | alloy‑rs β†’ Base Sepolia testnet |
87
+ | **CID** | cid + sha2 β†’ Filecoin‑compatible |
88
+ | **Medical APIs** | NCBI E‑utilities (PubMed) |
89
+ | **UI** | HTMX + Alpine.js + Tailwind CSS |
90
+ | **Observability** | WebSocket + Server‑Sent Events |
91
+ | **Deployment** | Docker, Hugging Face Spaces |
92
+
93
+ ---
94
+
95
+ ## πŸ“‹ Use Cases
96
+
97
+ ### πŸš‘ Emergency Room Triage
98
+ A clinician pastes a raw ambulance report. The system redacts patient identity, runs the case through the MI300X, and instantly returns a structured clinical assessment with PubMed references – all while **maintaining HIPAA compliance** and **creating an immutable legal audit trail**.
99
+
100
+ ### πŸ₯ Multi‑Hospital Consortium
101
+ Three independent hospitals can run RustVital‑AMD nodes. After each triage, they attest to the correctness of the redaction proof. The on‑chain record shows consensus, giving regulators and insurers **cryptographic proof that PII was never exposed**.
102
+
103
+ ### πŸ“Š Continuous Federated Learning
104
+ Hospitals trigger fine‑tuning jobs on their own AMD GPUs using only **de‑identified logs**. The model improves without any raw patient data leaving the gateway. The system logs every training event, creating a **fully auditable model lineage** on‑chain.
105
+
106
+ ---
107
+
108
+ ## βš™οΈ Quick Start (Local Development)
109
+
110
+ ### Prerequisites
111
+ - Rust 1.90+ (stable‑toolchain)
112
+ - An AMD MI300X instance running vLLM (or the [Hugging Face Space](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd) for immediate testing)
113
+ - Base Sepolia wallet (optional, for on‑chain transactions)
114
+
115
+ ### 1. Clone the repository
116
+ ```bash
117
+ git clone https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd
118
+ cd rustvital-amd
119
+ ```
120
+
121
+ ### 2. Configure environment
122
+ Create a `.env` file:
123
+ ```env
124
+ VLLM_URL=http://129.212.188.154:8000/v1/chat/completions
125
+ PUBMED_EMAIL=you@example.com
126
+ PRIVATE_KEY=your_base_sepolia_private_key_hex
127
+ PORT=7860
128
+ ```
129
+
130
+ ### 3. Build & Run
131
+ ```bash
132
+ cargo build --release
133
+ cargo run
134
+ ```
135
+ The server will start on `http://localhost:7860`. Open the URL in your browser.
136
+
137
+ ### 4. Connect to real GPU
138
+ If you have a droplet running vLLM, expose it with Cloudflare Tunnel:
139
+ ```bash
140
+ cloudflared tunnel --url http://localhost:8000
141
+ ```
142
+ Then update `VLLM_URL` with the generated `https://*.trycloudflare.com/v1/chat/completions` address.
143
+
144
+ ---
145
+
146
+ ## πŸ“‘ API Endpoints
147
+
148
+ | Method | Path | Description |
149
+ |--------|---------------------------|-------------|
150
+ | `GET` | `/` | Serves the interactive UI |
151
+ | `GET` | `/health` | Liveness check (`healthy`) |
152
+ | `GET` | `/status` | GPU status, model info, triage count |
153
+ | `POST` | `/triage/html` | Form‑encoded triage request (returns HTML) |
154
+ | `POST` | `/triage` | JSON triage request (`TriageRequest` β†’ `TriageResponse`) |
155
+ | `GET` | `/triage/stream` | SSE stream of agent events (Shield β†’ Triage β†’ Audit) |
156
+ | `GET` | `/agents/status` | WebSocket for real‑time agent states |
157
+ | `POST` | `/dicom/redact` | Upload a DICOM file for metadata / burned‑in text redaction |
158
+ | `GET` | `/medical/enrich` | Fetch PubMed evidence for a given clinical note |
159
+ | `POST` | `/trigger-federated-tune` | Launch a simulated federated LoRA fine‑tuning job |
160
+ | `GET` | `/federation/round` | Show current federated learning round and nodes |
161
+ | `GET` | `/dashboard` | HTML fragment of recent triage history |
162
+ | `GET` | `/history` | JSON list of all triage records |
163
+
164
+ ---
165
+
166
+ ## ☁️ Deployment
167
+
168
+ The project is containerised with Docker. A pre‑built image is automatically deployed to Hugging Face Spaces on every push.
169
+
170
+ ### Dockerfile (production)
171
+ ```dockerfile
172
+ FROM rust:1.95-slim-bookworm AS builder
173
+ RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
174
+ WORKDIR /app
175
+ COPY Cargo.toml Cargo.lock* ./
176
+ COPY src src
177
+ COPY static static
178
+ COPY contracts contracts
179
+ RUN cargo build --release
180
+
181
+ FROM debian:bookworm-slim
182
+ RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
183
+ COPY --from=builder /app/target/release/rustvital-amd /usr/local/bin/rustvital-amd
184
+ EXPOSE 7860
185
+ ENV PORT=7860
186
+ CMD ["rustvital-amd"]
187
+ ```
188
+
189
+ ### Hugging Face Space Secrets
190
+ Set these in **Settings β†’ Secrets**:
191
+
192
+ | Key | Value |
193
+ |-----|-------|
194
+ | `VLLM_URL` | `https://*.trycloudflare.com/v1/chat/completions` |
195
+ | `PUBMED_EMAIL` | Your email for NCBI rate limits |
196
+ | `PRIVATE_KEY` | Base Sepolia hex private key (without `0x`) |
197
+
198
+ ---
199
+
200
+ ## πŸ† Hackathon Tracks
201
+
202
+ - **AI Agents & Agentic Workflows** (main)
203
+ - **Fine‑Tuning on AMD GPUs** (LoRA on MI300X)
204
+ - **Hugging Face Challenge** (Space deployed)
205
+ - **Qwen Challenge** (Qwen2.5‑7B via vLLM)
206
+ - **Build in Public** (updates on [X/Twitter](https://x.com/MoonloungeBrain))
207
+
208
+ ---
209
+
210
+ ## 🀝 Contributing
211
+
212
+ This project was built solo for the AMD Developer Hackathon (May 2026). Contributions are welcome via pull requests. Please discuss major changes first in the [Hugging Face Community tab](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd/discussions).
213
+
214
+ ---
215
 
216
+ ## πŸ“œ License
217
+
218
+ MIT License – see the `LICENSE` file (if present) or the [Hugging Face Space page](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd) for details.
219
+
220
+ ---
221
 
222
+ **Built with ❀️, Rust, and AMD ROCm for the AMD Developer Hackathon 2026.**
223
+ ```
224
 
225
+